Thursday, April 2, 2009

Accessing SAP XI Web Service through simple Axis 1 client

This a code for accessing SAP XI Web Service through Axis1, One can suggest Axis2 code for this.

Service service = new Service();
Call call = (Call) service.createCall();
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://sap.com/xi/WebService/soap1.1");
call.setEncodingStyle(null);
call.setOperationName("YOUR_OPERATION_NAME_IN_WSDL");

Options opts = new Options(args);
args = opts.getRemainingArgs();
if (args != null) {
opts.setDefaultURL(args[0]);
} else {
opts.setDefaultURL("YOUR_SERVICE_URL_IN_WSDL");
}
//if athonticated service set
call.setUsername("YOUR_USERNAME");
call.setPassword("YOUR_PASSWORD");

call.setTargetEndpointAddress(new URL(opts.getURL()));

//requestString is soap envelope as a string
SOAPEnvelope env = new SOAPEnvelope(new ByteArrayInputStream(requestString.getBytes()));

call.invoke(env);

No comments:

Post a Comment

Search