EndpointReference targetEPR1 = new EndpointReference("https://your URL");
XMLStreamReader parser = XMLInputFactory.newInstance()
.createXMLStreamReader(new FileReader("E:\\DartMouth\\Version2\\V3\\Test\\SOAPEnvelope"));
System.out.println("aaaa "+parser.getVersion());
OMXMLParserWrapper wrapper = new StAXSOAPModelBuilder(parser);
ServiceClient sc = new ServiceClient();
Options options = new Options();
options.setTo(targetEPR1);
//authentication
HttpTransportProperties.Authenticator basicAuth = new HttpTransportProperties.Authenticator();
basicAuth.setUsername("username");
basicAuth.setPassword("pwd");
options.setProperty(HTTPConstants.AUTHENTICATE, basicAuth);
options.setAction("soap_action");
System.setProperty("javax.net.ssl.trustStore","path to truststore\\test.jks");
System.setProperty("javax.net.ssl.trustStorePassword","test123");
sc.setOptions(options);
OperationClient res = sc.createClient(ServiceClient.ANON_OUT_IN_OP);
MessageContext mc = new MessageContext();
SOAPFactory sf = OMAbstractFactory.getSOAP11Factory();
mc.setEnvelope((SOAPEnvelope)wrapper.getDocumentElement());
res.addMessageContext(mc);
res.execute(true);
MessageContext outMsgtCtx = res.getMessageContext("In");
System.out.println("results "+outMsgtCtx.getEnvelope().toString());
No comments:
Post a Comment