I am having a problem sending my SOAP message back. I have taken an example from the Sun application server. It has a simple JSP that submits to a sending servlet whcih constructs the outgoing SOAP message, opens a connection and sends it out. The receiving servlet exists on the same application server and recieves the messgaes, gets parts of the content from the SOAP message and then builds a simple response to send back.
When I run the Sun sample on the Sun application server, it works fine. When I run it under WebSphere application server, my reply message is constructed correctly but when it gets sent back to the sending servlet, the body content has disappeared.
In the receiving servlet I receive the SOAP message with no problem and can extract data from it. I then build the SOAP response and print it to to System.out just before writing it to the output stream:
System.out.println("\n************** message being sent back***************\n"); reply.writeTo(System.out);
// Write out the message on the response stream. OutputStream os = resp.getOutputStream(); reply.writeTo(os);
Here is what my System.log file looks like. You can see the Body contains <Response xmlns="">This is a response</Response>.
************** message being sent back***************
<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <Response xmlns="">This is a response</Response> </soapenv:Body> </soapenv:Envelope>
Immediately upon return from the SOAPConnection.call method in my sending servlet, I take the SOAP response message and again write it to System.out:
When this code executes on the Sun application server, I get body content like this: <Response>This is a response</Response>. When I execute on WebSphere I get body content like this: <Response xmlns="">This is a response</Response> with with the xmlns=�� being added (I assume by the WebSphere soap implementation).
Can anyone explain why my body content is being removed? Any suggestions on how to fix this problem?
I've tried with an without a namespace on the body text nodes. I've tried using addBodyElement and addChildElement but no lcuk there either.
I am using WebSphere 5.1 and have not added any additional jars to WebSphere (e.g. from Java WS Dev Pack 1.6)
Joined: Aug 08, 2001
I have found a solution to this problem. This is a WebSphere specific problem. It works fine under other application servers (Sun).
The response message contained one element with data.
<soapenv:Body> <Response xmlns="">This is a response</Response> </soapenv:Body>
However, for some reason, the WebSphere SOAP processing was stripping out the text of the Response element and returning an empty node (e.g., <Response xmlns=""/> .
To get around this problem, I moved the text node down one element
<soapenv:Body> <Response xmlns=""> <ResponseData xmlns="">This is a response</ResponseData> </Response> </soapenv:Body>
By adding the extra element and moving the data down to that element, the SOAP response comes back correctly.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: SOAP response is losing Body content data