Reputation: 51
I'm trying to invoke some WS. I have server and client on my local machine. I'm 100% sure about content of message and it comes from server to client with no changes. Problem is that the client creates not correct SOAPMessage
object which have envelope field under soapPart equals to null.
Client side code:
SOAPMessage responseMsg = conn.call(msg, urlEndpoint);
Server side code:
SOAPEnvelope envelope = sp.getEnvelope();
SOAPHeader hdr = envelope.getHeader();
SOAPBody bdy = envelope.getBody();
bdy.addBodyElement(envelope.createName("response", "soa", "http://www.sbg.com"));
return msg;
Id debug window I see the following:
1) Server side debug window
2) Client side debug window
I'm using SAAJ for communication and JDK 1.6.
Can anybody assist with the issue?
Upvotes: 1
Views: 4730
Reputation: 5193
Try this:
SOAPMessage sm = MessageFactory.newInstance().createMessage();
sm.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");
sm.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, "UTF-8");
SOAPPart sp = sm.getSOAPPart();
SOAPEnvelope se = sp.getEnvelope();
se.setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding/");
se.setAttribute("xmlns:SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/");
se.setAttribute("xmlns:soa", "http://www.sbg.com");
SOAPBody sb = sm.getSOAPBody();
SOAPBodyElement el = sb.addBodyElement(new QName("http://www.sbg.com", "response", "soa"));
el.setAttribute("_ctxID", "cid=xref_members,cn=admin");
el.setAttribute("status", "OK");
SOAPElement in = el.addChildElement("response_code");
in.setValue("0000");
sm.writeTo(System.out);
Upvotes: 0
Reputation: 35829
Are you responsible for both (client and server)? What is the message that the client sends?
In my experience, it helps to use a tool like SoapUI to test the message:
Upvotes: 1