views:

137

answers:

1

I am trying to send special (&, ' (single quote)) characters in the Soap Request. I am using axis 1.4. The webservice client is in weblogic server and the webservice server is an ibm mainframe (COBOL program).

The request data from the client contains special character (& symbol) which is converted to &

I tried to enclose it with CDATA as

<![CDATA[Some Name & Some Data ]]> which got converted to

&lt;![CDATA[Some Name &amp; Some Data]]&gt; 

The webservice client is generated from wsdl, so I couldn't use CDATA api to construct the request. I am able to set it as string value, and it is getting converted.

Any help on this would be greatly appreciated. Please let me know if you need any more information on this.

+1  A: 

The web service client stubs are doing the XML encoding for you. The web service expects XML, and it is encoding the & and ' into entity references so that you will be sending valid XML.

To an XML parser, it will "see" the &amp; as & and you don't have a problem.

If the server is unable to handle the entity references, then the COBOL "web service" isn't doing what it is supposed to be doing. That makes it difficult for you(and standards based tools) to generate client stubs from the WSDL, which is essentially a contract that describes the rules for data format and interchange.

What is the point of providing a WSDL and a SOAP service if it doesn't adhere to it's prescribed interface rules?

Mads Hansen
Ok, ignoring the part that the COBOL program is not able to parse my content.How do I send a CDATA in the request without it getting encoded?
SKS
I'm not sure if the AXIS stubs will allow you to set the content and specify that it should be CDATA. It looks as if others have had similar issues: http://osdir.com/ml/axis-user-ws.apache.org/2009-12/msg00095.html You may have to either hack the generated stub code, look for a different tool to generate stubs, or hand-construct your SOAP request and post.
Mads Hansen
True. I also ended up doing the same, looking at axis stub to handle this specific case. I haven't figured out yet, I will post again if I find something. Thanks for your help.
SKS