Hello.
Trying to write the simplest Java client to connect to the SOAP web service.
Checked option with SOAP SAAJ. It works, but it does not suit the fact that it is necessary to compose its own SOAP object model for each SOAP request.
Are there other similar options for forming a SOAP request that are completely identical to the type of SOAP SAAJ.
I tried to replace it
MessageFactory messageFactory = MessageFactory.newInstance ();
SOAPMessage soapMessage = messageFactory.createMessage ();
SOAPPart soapPart = soapMessage.getSOAPPart ();
String serverURI = "http://ws.cdyne.com/";
// SOAP Envelope
SOAPEnvelope envelope = soapPart.getEnvelope ();
envelope.addNamespaceDeclaration ("example", serverURI);
/ *
Constructed SOAP Request Message:
mutantninja@gmail.com
123
* /
// SOAP Body
SOAPBody soapBody = envelope.getBody ();
SOAPElement soapBodyElem = soapBody.addChildElement ("VerifyEmail", "example");
SOAPElement soapBodyElem1 = soapBodyElem.addChildElement ("email", "example");
soapBodyElem1.addTextNode ("mutantninja@gmail.com");
SOAPElement soapBodyElem2 = soapBodyElem.addChildElement ("LicenseKey", "example");
soapBodyElem2.addTextNode ("123");
MimeHeaders headers = soapMessage.getMimeHeaders ();
replaced by
MessageFactory msgFactory = MessageFactory.newInstance(); String reqEnv = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:example=\"http://ws.cdyne.com/\"><SOAP-ENV:Header/><SOAP-ENV:Body><example:VerifyEmail><example:email>mutantninja@gmail.com</example:email><example:LicenseKey>123</example:LicenseKey></example:VerifyEmail></SOAP-ENV:Body></SOAP-ENV:Envelope>"; SOAPMessage soapMessage = msgFactory.createMessage(null, new ByteArrayInputStream(reqEnv.getBytes())); and
SOAPMessage message = MessageFactory.newInstance().createMessage(); SOAPPart soapPart = message.getSOAPPart(); soapPart.setContent(new StreamSource(new FileInputStream("c:\\musor\\1.xml"))); despite the fact that the resulting SOAP request is the same everywhere I get an error in the remaining 2 cases
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <soap:Fault> <faultcode>soap:Client</faultcode> <faultstring>Server did not recognize the value of HTTP Header SOAPAction: .</faultstring> <detail /> </soap:Fault> </soap:Body> </soap:Envelope> BUT only the object first method works on SAAJ.
Are there other similar methods? if so what.
Thank you in advance for your response.