Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Script LiveCycle Web Services long lived

Avatar

Former Community Member
Hi,



I have a script to call web services (in fact short-lived livecycle process).



I want to call a long lived process with script to. So I try to use the asynchronous method with soap.request but I'm lost.



I wonder if anybody has an example of how to script a call to a long lived process in adobe script because all process use the invoke method.



Any help would be appreciated.



Thanks
11 Replies

Avatar

Former Community Member
You must make multiple calls. The long lived process wil immeadiately return a process ID when the process starts. It exposes a number of other methods (other than Invoke). You have to make subsequent calls that will give you the status (the proces id is used as an input) status can be complete, running, stalled etc. You can also make a call to get Results once the process is complete. That call will return all output params to you.



The reason for this is that as a long lived process you have no idea how long the process will run so it is up to the caller to poll the process and get the results when it is done. The short lived process will force your caller to wait until it is complete so know there is a place to return the results.



Make sense?

Avatar

Former Community Member
I understand the global meaning but I don't know how to do that.



I will explain what I want to do because I'm not sure It's a good idea.



I have a form with multiple page.



The first page is a kind of "menu". There are buttons on it.



I have a button who set visible a page to consult orders by numberId. I can go back to menu from here.



I have a button who set visible a page to consult,modify or add provider in the database.



Etc ... All of the pages use Webservices calls(short lived process) and works. There is no workflow behind.



What I try to do is to create an order (that will follow a workflow).

From my menu page I click on a button to set visible the page of creating order. Once it's filled I don't want to click on the "Complete" button in the workspace but on a custom button to call the long lived service and the Form still is open and accessible to the user.



So I thought to call it by web services but I'm not sure it's a good idea.



First I have issue with scripting the call to long lived process. I just want to start it. Don't care about what append next in my script.

I give it the xml data in parameter and that all.



Second, I wonder how to see this process in the tracking tab of the workspace user who click on the custom button.



Thanks

Avatar

Former Community Member
Calling the long lived process is not an issue ....you have been able to do that by calling its invoke method. The only thing you wil lget back is the Process ID. This is the only indicator that the server recieved your call. You could activate a message on the client that says Your submission has started process: returned proces ID from web service



You will not be able to see it from the tracking tab because that user has nothing to do with the process. It was started from a web service that had an anonymous access ...unless you turn security on and have the user authenticate when they call the web service we will not know who started the process and who to give access to the tracking information.



Hope that helps

Avatar

Former Community Member
Hi,



I create a long lived process with an input string and one step, an assign task to Alex Pink.



I script in a script object the call to the Web Service like this :



var cWSLong = "http://myServer:8080/soap/services/LongWS?wsdl";



function callWS(URL){



try

{

var mySync = {

isDone: false,

val: null,

// Generates the result of the web method:

result: function(cMethod)

{

this.isDone = false;

var name = "http://sw0052.phys.pack:8080/soap/services/LongWS/:" + cMethod + "Response";

xfa.host.messageBox("name : "+name);

if (typeof this.val[name] == "undefined"){

xfa.host.messageBox("val est indéfini");

return null;

}

else

return this.val[name]["return"];

},

// The method called by the web service after completion:

response: function(oResult, cURI)

{

this.val = oResult;

this.isDone = true;

},

// While the web service is not done, do something else:

wait: function()

{

while (!this.isDone) doSomethingElse();

}

};



var myAuthentication = {

Username: "administrator",

Password: "password"

};



var response = SOAP.request(

{

cURL: URL,

oRequest: {

"http://myServer:8080/soap/services/LongWS/:invoke": {

inputString: "jerome"

}

},

oAsync: mySync,

oAuthenticate: myAuthentication

});

//var result = response["http://sw0052.phys.pack:8080/soap/services/LongWS/:invokeResponse"]["return"];

var result = mySync.result("invoke");

xfa.host.messageBox("Result : "+result);

}catch(e) {



xfa.host.messageBox("exception "+e);

}

}



And in the button click event :



myForm.variables.Soap.Test();



But my OResult Object is still null. I received no Processus ID and the process doesn't start.

Avatar

Former Community Member
Where do you set the cMethod? You shodul be calling the invoke method.



Why are you using code to call the web service do you know that you can make the connection through the data connection wizard and it takes care of all of this for you.

Avatar

Former Community Member
In the SOAP.request method, there is the ORequest object with the invoke method.<br /><br />The cMethod is set at the line : var result = mySync.result("invoke"); <br /><br />----------------------------------------<br /><br />I scripted my short-lived web services (with the .invoke() method ) because I cannot drag and drop the result by the data connection wizard.<br /><br />I will test the connexion wizard for the long Lived process call. It's true, I don't need to script.<br /><br />-----------------------------------------------------------<br /><br />I try to rewrite my script for the short lived process call. Because I used this kind of code : <br /><br />function callWS(URL,objet){<br /><br /> var service = SOAP.connect(URL);<br /><br /> if(typeof service != "object")<br /><br /> xfa.host.messageBox("Couldn't get WSDL object");<br /><br /> if(service.invoke == "undefined")<br /><br /> xfa.host.messageBox("Couldn't get webservicex.invoke Call");<br /> <br /> var param;<br /> <br /> param =<br /> {<br /> nom_client:objet,<br /> };<br /> <br /><br /> var e;<br /> var cXMLDoc;<br /> var nb = 0;<br /><br /> try<br /> { <br /> var result = service.invoke(param);<br /> <br /> if((result == "") | (result == null)) {<br /> <br /> result = "<no results returned>";<br /> return (false); <br /> <br /> }else{ <br /> <br /> for(var nItemCount in result)<br /> {<br /> cXMLDoc = result[nItemCount];<br /> }<br /> myXML = XMLData.parse( cXMLDoc,false);<br /> }<br /><br /> }catch(e) {<br /> <br /> xfa.host.messageBox("exception "+e); <br /> }<br />}<br /><br />But with this code, I cannot use the authenticator object.<br /><br />With SOAP.request, I can use the authenticator object but I don't know how to get the result of my web service.<br /><br />For example : <br /><br />function callWS(URL){<br /><br /> var cXMLDoc;<br /><br /> try<br /> { <br /> console.show();<br /> SOAP.wireDump = true;<br /> <br /> var myAuthentication = {<br /> Username: "administrator",<br /> Password: "password"<br /> };<br /> <br /> var response = SOAP.request({<br /> cURL: URL,<br /> oRequest: {<br /> "http://sw0052.phys.pack/soap/services/:invoke":{}<br /> },<br /> oAuthenticate: myAuthentication<br /> });<br /><br /> }catch(e) {<br /> <br /> xfa.host.messageBox("exception "+e); <br /> }<br />}<br /><br />In the javascript Console there is the XML I need But I don't know how to retrieve the value.<br /><br /><?xml version="1.0"?><br /><SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><br /> <SOAP-ENV:Body><br /> <ns0:invoke SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="http://sw0052.phys.pack:8080/soap/services/NumeroDemande/"/><br /> </SOAP-ENV:Body><br /></SOAP-ENV:Envelope><br /><br /><?xml version="1.0" encoding="UTF-8"?><br /><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><br /> <soapenv:Body><br /> <invokeResponse xmlns="http://sw0052.phys.pack:8080/soap/services/NumeroDemande/"><br /> <ns1:resultat xsi:type="ns1:XML" xmlns:ns1="http://adobe.com/idp/services"><br /> <ns1:document><?xml version="1.0"?><br /> <Formulaire><br /> <NumeroDemande><br /> <Numero type="int">17</Numero><br /> </NumeroDemande></Formulaire><br /> </ns1:document><br /> </ns1:resultat><br /> </invokeResponse><br /> </soapenv:Body><br /></soapenv:Envelope><br /><br />I tried several methods with response with no results. <br /><br />Thanks

Avatar

Former Community Member
Does the service need to be long lived?



You coudl setup additional dataconnections to the other web service operations and drag and drop as required.

Avatar

Level 6
Jerome,



I also have that kind of requirement. When you say:



"I create a long lived process with an input string and one step, an assign task to Alex Pink.



I script in a script object the call to the Web Service like this"



The script object is a execute script service in workbench? Also, the data connection wizard you are talking about is the webservice service from the foundation category?



Thank you

Avatar

Former Community Member
Hi,



What I tried to do is from a form, by clicking on a button to call and run a long-lived process I created in workbench.

I was not in the process design mode but in the designer mode at form level.



The script I talked was in the form.



I'm not sure to understand what you want to do. You want in your process design call a web service ? Or use an other long-lived process in your process ?

Avatar

Former Community Member
When you call a long lived process you will see that you have a couple of additional methods to the web service. In the short lived process you only have one method (invoke). So calling the long lived process you woudl use the invoke method and it will return a process id. Now that you have the process id you can make subsequent calls to get the status as well as the result of th eweb service call. The secondary call requires that you pass in the process id that you recieved from the 1st step.



Remember that the long lived process is set up that way because it will take time to get the result as opposed to the short lived process which will return the result in a short period of time.

Avatar

Level 2

Which web service call can be used to get the results of the long lived process? The JobManager doesn't seem to provide this functionality...