Search code examples
javasoapapache-axistalend

Talend Open Studio exporting job as a webservice and calling it without URL parameters


I am working with Talend for the first time. I have created a Talend Job and exported it as an AXIS webservice war file. I have deployed this on a tomcat container.

Now in order to call this webservice, by passing values for the context parameters, I need to build a URL with the values set on it.

For example the URL might look similar to this:

http://localhost:10080/StandardParcellor_0.1/services/StandardParcellor?method=runJob&arg1=--context_param%20DeliveryParcelMetadataFileLocation=C:\dev\temp\DMS\b2345678-2234-1234-1234-123456789123\a2345678-2234-1234-1234-123456789123\metadata.xml&arg2=--context_param%20WorkingPath=C:\dev\temp&arg3=--context_param%20DeliveryParcelID=db604807-8606-4107-8d3e-aff08c95db1c&arg4=--context_param%20PackageWorkingFolder=C:\dev\temp\DMS\b2345678-2234-1234-1234-123456789123\a2345678-2234-1234-1234-123456789123

If you notice my URL is awfully long and there are characters in the URL that need to be encoded properly. This is causing me a lot of grief. Even if it works now, it could break later on either on the basis of the length of the URL or encoding that I am doing right.

I was wondering and hoping that since this is a web service call, especially a SOAP call, can't we set these parameters in an XML? Create a soap envelope and pass this into the webservice? Probably even generate classes that I can use from the WSDL and call the webservice the right way, as opposed to this horrible looking URL.


Solution

  • IN order to call Talend web service, you can construct a post XML and send it out as below:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tal="http://talend.org">
       <soapenv:Header/>
       <soapenv:Body>
          <tal:args>
             <!--Zero or more repetitions:-->
             <tal:item>--context_param DeliveryParcelMetadataFileLocation=C:/dev/temp/DMS/b2345678-2234-1234-1234-123456789123/a2345678-2234-1234-1234-123456789123/metadata.xml</tal:item>
             <tal:item>--context_param WorkingPath=C:/dev/temp</tal:item>
             <tal:item>--context_param DeliveryParcelID=3a91335b-4789-48c5-b6dc-8fac9c20a8d0</tal:item>
             <tal:item>--context_param PackageWorkingFolder=C:/dev/temp/DMS/b2345678-2234-1234-1234-123456789123/a2345678-2234-1234-1234-123456789123</tal:item>
          </tal:args>
       </soapenv:Body>
    </soapenv:Envelope>
    

    The above seems to work. Was hoping someone could confirm it.