0 Replies Latest reply on Jan 7, 2008 1:14 AM by hstoessel

    Java - Axis2: How to get an error code / error message from the Javascript via SOAP

    hstoessel Level 1
      Hi

      In our Java applicsation we call a Javascript in a Indesign CS Server using the following code:

      --- SNIP BEGIN ---

      // calls the remote service on the indesign server
      try {
      // create service

      ServiceStub oIndsgnSrvStub = new
      ServiceStub(sIndesignServer);

      // create service parameter
      ServiceStub.RunScriptParameters
      oIndsgnSrvRSParams = new ServiceStub.RunScriptParameters();

      // create arguments with source- and target-file for parameter
      ServiceStub.IDSPScriptArg[] oIndsgnSrvSArgs = new ServiceStub.IDSPScriptArg[2];
      oIndsgnSrvSArgs[0] = new
      ServiceStub.IDSPScriptArg();
      oIndsgnSrvSArgs[0].setName("xml-input");
      oIndsgnSrvSArgs[0].setValue(sSourceFile);

      oIndsgnSrvSArgs[1] = new
      ServiceStub.IDSPScriptArg();
      oIndsgnSrvSArgs[1].setName("output-file");
      oIndsgnSrvSArgs[1].setValue(sTargetFile);

      // define service parameter

      oIndsgnSrvRSParams.setScriptArgs(oIndsgnSrvSArgs);

      oIndsgnSrvRSParams.setScriptFile(sScriptFile);

      oIndsgnSrvRSParams.setScriptLanguage("javascript");
      oIndsgnSrvRSParams.setScriptText("");

      // create runscript
      ServiceStub.RunScript oIndsgnSrvRS = new ServiceStub.RunScript();

      // set parameter

      oIndsgnSrvRS.setRunScriptParameters(oIndsgnSrvRSParams);

      //$$$ there should be an answer returned by the InddSrvr
      // execute SOAP call
      ServiceStub.RunScriptResult oIndsgnSrvRes = oIndsgnSrvStub.RunScript(oIndsgnSrvRS);

      if(oIndsgnSrvRes.getErrorNumber() == 0) {

      oServerProdJob.setProdState(CBP_Constant.REMOTEPRODUCTIONSTATE_SUCCESS);
      bOK = true;
      } else {

      oServerProdJob.setProdState(CBP_Constant.REMOTEPRODUCTIONSTATE_FAILURE);
      bOK = false;
      }
      //$$$ should be set, if there is something returned by inddsrvr
      //oServerProdJob.setErrorMsg(sErrorMsg);
      } catch(Exception e) {
      sError += e.getMessage() + "\n";
      bOK = false;
      }

      --- SNIP END -----

      The problem is that we don't get the error code and/or the error message from the Javascript in oIndsgnSrvRes. The error code is always 0 if I set an Integer value as return in the Javascript. If I set a String, there is an Exception in the Java application.

      Here is the Java script we use:

      --- SNIP BEGIN ---

      main();

      main()
      {
      var sError = "";
      var sXMLInput = "";
      var sLayoutPath = "";

      // get the SDKCodeSnippetRunner object
      var cbpAdapter = app.cbpCbpadapterObject
      if (cbpAdapter) {
      sXMLInput=app.scriptArgs.get("xml-input");
      sLayoutOutputFile=app.scriptArgs.get("output-file");

      sError = cbpAdapter.doProcess(sXMLInput, sLayoutOutputFile);
      }
      return sError; // This give an Exception; if I return an Integer the ScriptResult is always 0
      }

      --- SNIP END -----

      If I try this with the test application from Adobe I get the error code correctly. But in the Java application, using SOAP, I can't get the error code.

      What could be wrong?
      Any ideas?

      Thanks a lot for the support.

      Kind regards
      Hans