Showing results for 
Search instead for 
Did you mean: 

Call web service in CLM script

Former Member
0 Kudos

Dear all,

I'm working on a script where I need to call a WebService. We are using SAP soursing 9 on the project so I can't use Axis and I need to use CXF.

The WSDL for the WebService is protected with an Http authentication.

Locally I can run the script by using the Authenticator object, after that I get the error listed bellow. On the CLM environement I can't use this kind of authentication (failled to import the librairy).

I'm stacking with the following issues :

HTTP Authentification :

Locally by using a Java IDE I can call the service after using :

Authenticator.setDefault(new Authenticator()



                                        protected PasswordAuthentication getPasswordAuthentication() {

                                                  return new PasswordAuthentication(username, password.toCharArray());



I try to use the Dynamic client factory but the following error is sent back :

java.lang.IllegalStateException: Unable to create JAXBContext for generated packages: "" doesnt contain ObjectFactory.class or jaxb.index

          at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(

          at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(

          at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(

          at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(

          at src.main.zzzMain.main(

Caused by: javax.xml.bind.JAXBException: "" doesnt contain ObjectFactory.class or jaxb.index

Dynamic Client Factory :

                              JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();

                              Client client = dcf.createClient(wsdlHTTP);

                              Object[] res = client.invoke("urn:ZfclCheckContractAccass01");

Someone have an idea how to solve this issue ? Or If someone have an example how to contact a webservice with a CLM script ?



Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Finally I have created personaly my SOAP message using standard lib like that :

Message creation :

SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory.newInstance();

SOAPConnection connection = soapConnFactory.createConnection();

MessageFactory messageFactory = MessageFactory.newInstance();

SOAPMessage message = messageFactory.createMessage();

SOAPPart soapPart = message.getSOAPPart();

SOAPEnvelope envelope = soapPart.getEnvelope();

SOAPBody body = envelope.getBody();

envelope.addNamespaceDeclaration("urn", "urn:sap-com:document:sap:soap:functions:mc-style");

SOAPElement bodyElement = body.addChildElement(envelope.createName("urn:UrnName"));

SOAPElement bodyElement2 = bodyElement.addChildElement(envelope.createName("codeName"));


For the authentification part :

MimeHeaders mime = message.getMimeHeaders();

                              mime.setHeader("Authorization", "Basic user+pwd encoded64");


SOAPMessage reply =, serviceUrl);

Lib used to create and decode the message :

import javax.xml.soap.MessageFactory;

import javax.xml.soap.MimeHeaders;

import javax.xml.soap.SOAPBody;

import javax.xml.soap.SOAPConnection;

import javax.xml.soap.SOAPConnectionFactory;

import javax.xml.soap.SOAPElement;

import javax.xml.soap.SOAPEnvelope;

import javax.xml.soap.SOAPException;

import javax.xml.soap.SOAPMessage;

import javax.xml.soap.SOAPPart;

import org.w3c.dom.DOMException;

import org.w3c.dom.Element;

import org.w3c.dom.NodeList;



Former Member
0 Kudos

Hi Mathieu,

Can you explain the steps involved...even i have the same requirement. Any help would be appreciated.

Thanks in advance.

Srikanth Emani

Former Member
0 Kudos

Hi Srikanth,

  1. The first step is done to create a Java SOAP message using the Oracle API. You can find information about SOAP items on the oracle java doc :
  2. This step will set some specific parameters using the Mimeheader object. The HTTP context need to be updated in my case, if you have HTTP authentification for the service you are calling just add a the authorization parameter with the user and password base64 encoded. Other parameters can be found on wikipedia by example :
  3. When you have set your SOAP message and the HTTP context with the MIME info you can make the call using the SOAPConnection object . The call will return a SOAP response object.

SOAPMessage reply =, webServiceUrl);

On our system it was linked to a toolbar event and it's working perfectly. We are sending objects for validation and the response is containing error messages and the updated objects.

When you will retriev the response you will need to decode the SOAP message using the same classes (SOAP api).


Answers (0)