on 2013 Mar 04 12:15 PM
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()
{
@Override
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: "com.sap.document.sap.soap.functions.mc_style" doesnt contain ObjectFactory.class or jaxb.index
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:356)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:204)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:197)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:152)
at src.main.zzzMain.main(zzzMain.java:81)
Caused by: javax.xml.bind.JAXBException: "com.sap.document.sap.soap.functions.mc_style" 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 ?
Regards,
Mathieu
Request clarification before answering.
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");
message.saveChanges();
SOAPMessage reply = connection.call(message, 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;
Regards
Mathieu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Srikanth,
SOAPMessage reply = connection.call(inputSOAPmessage, 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).
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.