OPEN SOURCE - Job Scheduler - Job Solutions using Web Services
|
|
|
|
| |
| |
Web Services for Jobs
| |
Any job in the Job Scheduler can be exposed as a Web Service:
see the
Web Service Implementation Tutorial
(HTML)
(PDF)
for details.
It is important here to differentiate between the two types of Web Service requests:
- Asynchronous Web Service Requests
The caller receives an acknowledgement that his request has been accepted and will be processed.
Job execution is done asynchronously i.e. at a later run time.
This is useful if batch jobs need execution time or should start at a predefined point in time.
No changes to job implementations are required with asynchronous Web Services processing.
- Synchronous Web Service Requests
Should a request be received then it will be instantly processed.
The caller receives the job execution result on the fly.
Jobs must be prepared to handle this kind of request.
Configurations for sample jobs are given in the
scheduler_samples_webservice.xml file.
These configurations can be included into the scheduler.xml configuration file using
<base file="scheduler_samples_webservice.xml"/>.
Use of the Job Scheduler's own graphical Job Configuration Editor is recommended for changing these configurations.
First, let's look at a Web Service request such as:
<?xml version="1.0" encoding="ISO-8859-1"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsa:To xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
http://www.sos-berlin.com:10110/hello_service
</wsa:To>
<wsa:ReplyTo
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
<wsa:Address>
http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
</wsa:Address>
</wsa:ReplyTo>
</soapenv:Header>
<soapenv:Body>
<addOrder xmlns="http://www.sos-berlin.com/scheduler">
<xml_payload>
<myns:hellos xmlns:myns="http://www.mydomain.com/MyNamespace">
<myns:hello id="001">world</myns:hello>
<myns:hallo id="002">welt</myns:hallo>
</myns:hellos>
</xml_payload>
</addOrder>
</soapenv:Body>
</soapenv:Envelope>
Besides the standard SOAP headers, this request contains the <addOrder> element.
When sent to the Job Scheduler's web server, this element would be automatically transformed
by the Job Scheduler into an order for a job chain for an asynchronous web request. Note that within this element
there is an <xml_payload> element. This element may in turn contain XML elements that are part of a
different namespace. Other XML requests can also be accepted, instead of the <xml_payload> element.
However, in this case you would have to create an individual style sheet for the request transformation.
Web Service with Asynchronous Processing
For an asnynchronous Web Service you do not have to change your jobs or job chains, just configure a Web Service
in your scheduler.xml file like this:
<web_service name = "hello"
url_path = "/hello"
request_xslt_stylesheet = "config/scheduler_soap_request.xslt"
response_xslt_stylesheet = "config/scheduler_soap_response.xslt">
<params>
<param name = "jobchain" value = "hello"/>
</params>
</web_service>
This configuration exposes a Web Service that can be addressed with
http://host:port/hello,
where host and port
are the values from the Job Scheduler configuration.
/hello is the URL path in the above sample.
Incoming requests are automatically transformed with a default style sheet
and - should an order be part of the request - an order will be created in the job chain that
has been specified using the jobchain parameter.
An outgoing response is immediately created that returns the ID that has been
assigned to the order. Later requests from the caller such as <show_history/> could
address the order by this ID.
Further processing is then handed over to the job chain.
The result of such an asynchronous request could simply be:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<sos:orderId xmlns:sos="http://www.sos-berlin.com/scheduler">42</sos:orderId>
</soapenv:Body>
</soapenv:Envelope>
This seems much ado for a result as 42 but it is an important technique
that integrates classic batch processing and legacy applications into Web Service architectures.
Web Service with Synchronous Processing
In this case the SOAP request is directly processed by a job chain that implements the following steps:
- Receive and process Web Service Request
- Execute a job using the content from the request
- Process and forward the Web Service Response
The following jobs, for example, could be used to implement this job chain:
- Job: Receive and Process Web Service Request (sample_hello_request)
This job receives the XML request content,
optionally transforms the content and
creates order parameters for the next job in the job chain.
Show Job Documentation
Show Job Source Code
- Job: Process Orders for a Web Service (sample_hello_world)
This job accepts orders and logs the value of any order parameters or the value of any XML payload.
(Note that this is just a simple example job - to demonstrate how order processing can be implemented.)
Show Job Documentation
Show Job Source Code
- Job: Process and Forward Web Service Response (sample_hello_response)
This job uses the results from the execution of an order that have been stored in the order payload,
transforms this payload content and forwards the response to the calling Web Service.
Show Job Documentation
Show Job Source Code
The result of a synchronous request could be:
<?xml version="1.0"?>
<sos:order xmlns:sos="http://www.sos-berlin.com/scheduler">
<sos:id>636</sos:id><sos:state>response</sos:state>
<sos:initialState>request</sos:initialState>
<sos:jobChain>hello_service</sos:jobChain>
<sos:job>sample_hello_response</sos:job>
<sos:task>2073</sos:task>
<sos:inProcessSince>2006-05-01 12:21:21.156</sos:inProcessSince>
<sos:created>2006-05-01 12:21:20.421</sos:created>
<sos:priority>0</sos:priority>
<sos:webService>hello_service</sos:webService>
<sos:params>
<sos:param>
<sos:name>hello</sos:name><sos:value>world</sos:value>
</sos:param>
</sos:params>
<sos:xml_payload/>
</sos:order>
Part of this result is processing information from the Job Scheduler such as the timestamp and duration
of execution. The <xml_payload> could contain arbitrary XML elements such as
the result from the execution of a job.
In addition to this example, you are free to create style sheets that transform job execution results
into different XML formats. You are not bound to use SOAP but could even create binary output
if the requesting Web Services is prepared for this response.
|
|
|
|
| |
|
| |
| |
Office Automation - Document Delivery - Job Scheduling - Systems Integration - Output Management - Enterprise Application Integration - Connectivity |
|