Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Call a Web Service from within an e-Sourcing script

Hi Guys

I would like to know wether anyone has successfully been able to call a Web Service from within an

e-Sourcing script? If you have, can you please share your experience and code?

Thank You

Former Member replied

Hi Faaiez -

As with any use of Web Services, however, you should carefully consider the security issues that may come up. How, for example, will the Web Service server validate that the Web Service client (E-Sourcing) is properly authenticated? Will password information be included in the web service call? You will find that it is very easy to make a web service call, but I would encourage you to carefully consider security before implementing a productive solution.

Web service calls can be made using raw Java web service APIs from the open source Axis library which is included with E-Sourcing; this approach is slightly more difficult to code, but very dynamic. Web service calls can also be made using proxies. In one solution that I worked on, we generated java proxies for the web service, compiled those proxies into a Jar file, and included that jar file as a custom jar in E-Sourcing. Let me provide a few more details on each of these approaches.

Using raw java web service APIs that are part of the Service and Call classes, I prototyped a web service call to Googles sample spell checker web service. Here is the code:

import org.apache.axis.client.Call;

import org.apache.axis.client.Service;

import org.apache.axis.encoding.XMLType;

import javax.xml.rpc.ParameterMode;

import javax.xml.namespace.QName;

String endpoint = "";

Service service = new Service();

Call call = (Call) service.createCall();

call.setTargetEndpointAddress( new );

call.setOperationName( "doSpellingSuggestion" );

call.setOperationName(new QName("urn:GoogleSearch", "doSpellingSuggestion"));

call.addParameter("key", XMLType.XSD_STRING, ParameterMode.IN);

call.addParameter("phrase", XMLType.XSD_STRING, ParameterMode.IN);

call.setReturnType( XMLType.XSD_STRING );

String ret = (String) call.invoke( new Object[] { "googlekey", doc.getDocumentDescription()} );


This block of code does a very simple calls the Google "doSpellingSuggestions" web service with two parameters: a key provided by Google, and a string for which the spelling suggestions should be generated. I used the current document description as my sample string for the web service and I put the results back into the document description - remember, this is just showing how you can call the web service, not doing anything really intelligent or useful from a business perspective

There is nothing special to E-Sourcing about the above code...this is really just using the Axis java classes to call a web service.

The second approach that can be used is to generate Java proxies for the web service calls. The open source Axis library includes a tool called "wsdl2java". Using the WSDL for the web service, you can generate Java proxies. Java classes will be generated by the tool; these Java classes will then need to be compiled and included in E-Sourcing as a custom jar. Once they are part of the E-Sourcing deployment, they can be called like any Java API. If you were to examine the generated code, you would notice that it looks a lot like the raw web service code shown above...the generated classes really just provide a simpler interface to the same functionality.

You can see this information and other E-Sourcing information at my blog at:


0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question