on 2014 Aug 12 2:58 AM
Hi Everyone,
Build version M33.104.
We have a scenario where we have to call an asynchronous web service.
From the documentation i understand that the Redwood job will be in status Running until the web service completes.
How does the call back work from the web service to Redwood? How does Redwood know the asynchronous web service job completed?
From the documentation, the per-requisite is:
thanks
Nanda
Request clarification before answering.
Hi Nanda,
Basically, you create a RedwoodScript job definition with the following code:
{
//Set completion strategy to external
jcsJobContext.setCompletionStrategy(CompletionStrategyType.External);
}
It needs the following Out parameters:
ServerAddress
JobId
On the Published Web Services tab of the job definition editor dialog, you click Add and then Save, the job definition now has a web service. Go to Scripting > Published Web Services to inspect published web services, UpdateJob1 is available in Scripting > Built-In Web Services. You can retrieve the WSDL and the URL to the web services from there.
Your web service now calls the web service for your RedwoodScript job definition (CPS uses basic authentication), then does its work, finally, when it has finished, it must update the job, it will call the UpdateJob1 web service with the job Id it got back when it initially called your RedwoodScript job and set the status to Completed.
Regards,
HP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thousands of thanks HP.
I was guessing along the same line, that adding the completion strategy should have some impact (like activating the UpdateJob1 webservice), since that is the only difference between calling a synchronous and asynchronous web service from Redwood job definition perspective.
I will test this and update this thread.
Thanks
Nanda
Hello,
I want to add something to this discussion.
1) it is not required to publish your job as a web service in order to make the UpdateJob1 service work, as described above, the UpdateJob1 web service is build in and activated by default.
2) Adding out parameters JobId and ServerAddress does not make sense at all.
3) Don't assume everything is automatic here. Your consuming webservice needs to accept the JobId and ServerAddress (you can dynamically retrieve this URL with req.getUpdateJobURL(jcsSession, null) in your code (be aware this is based on the ContextURL registry entry in your system)) fields as part of the SOAP request to make sure you send the context information of the job to the webservice. Now the webservice can do it's thing and once it is finished call the UpdateJob1 webservice through the ServerAddress URL (this way you can make your solution transparent from a remote perspective) and update the provided JobId with the correct end status and potential other information (job notes, set out parameters etc).
4) Make sure you have set the Completion strategy on your job to external, otherwise it can not be finished from the outside. The only thing this does is make the job stay in status Running after the code is finished.
Regards Gerben
Hi HP,
I included the following snippet in job source:
{
//Set completion strategy to external
jcsJobContext.setCompletionStrategy(CompletionStrategyType.External);
}
I get the following error when compiled:
JCS-102183: Compile failed for Job Definition SOAP_GlobalWeatherSoap_GetCitiesByCountry (Latest Version): SOAP_GlobalWeatherSoap_GetCitiesByCountry.java:user code 24:40:cannot find symbol symbol : variable CompletionStrategyType location: class com.redwood.scheduler.custom.SOAP_GlobalWeatherSoap_GetCitiesByCountry jcsJobContext.setCompletionStrategy(CompletionStrategyType.External);
I am not able to find any information from the API documentation on the method setCompletionStrategy, so I'm not able to figure what type of variable am i passing, so that i can initialize it. Please shed some light on it.
Also there is no path called Scripting > Built-In Web Services
I have only Scripting>Published Web Services
Thanks
Nanda
Hi Gerben,
Thanks a lot for your valuable additions.
the UpdateJob1 web service is build in and activated by default
But the web service URL for UpdateJob1 is not available/visible by default anywhere in the system or the documentation. Is there a specific location in the CPS UI, where we can check the UpdateJob1 URL?
I ran the req.getUpdateJobURL(jcsSession, null), and printed the output to get the update job URL, and have to append ?WSDL string at the end of it to obtain the WSDL.
In the api documentation, there is no mention of SOAP packages, hence no information on the classes/interfaces/methods. Can you please let us know where can we find that information?
What type of parameter(s) is expected by the setCompletionStrategy() method?
Thanks
Nanda
Hello Nanda,
The build in web services are described in the help file in http://<host>:<port>/scheduler/help/user_guide/scripting/soap/soap_inbound.html
In the API documentation there is a SOAP and SOAPRequest class in the com.redwood.scheduler.api.soap package. You can find the CompletionStrategyType class in the com.redwood.scheduler.api.model.enumeration package, so you might need an additional import for that class or package.
The setCompletionStrategy method is on jcsJobContext with is of type UserJobContext. Tip: there are a lot of useful methods in this class!
Regards Gerben
Hi Nanda,
I forgot the imports ....
try:
import com.redwood.scheduler.api.model.enumeration.CompletionStrategyType;
{
jcsJobContext.setCompletionStrategy(CompletionStrategyType.External);
}
To find this, we know that jcsJobContext is an instance of UserJobContext, so we look at the UserJobContext class in the APIDOCS. There we find setCompletionStrategy(CompletionStrategyType newStrategy), now you can click on "CompletionStrategyType" to get to the class, that is the class you need to import. We are using the External constant of that class.
Regards,
HP
Thanks a lot HP.
I did include the imports like below:
import com.redwood.scheduler.api.*;
may be i should have been more specific. It worked when i used your specific import line.
SAP provided us with an older version of the API documentation, and now when requested for details on the SOAP package, they provided us the latest API documentation which contains more information.
Thanks
Nanda
User | Count |
---|---|
49 | |
6 | |
5 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.