0


I am implementing a Client Web Service call to a SOAP Web Service implemented using .NET.
I used the WSDL provided and I am happy with what I send, e.g.:

POST /publicws/query.asmx HTTP/1.1
Host: www.blablabla.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.blablabla.com/WebServices/Query"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Query xmlns="http://www.blablabla.com/WebServices/Query"> <- <Query> tag #1
      <string_XML>
        <Query>                                                <- <Query> tag #2
          <Param1>param1value</Param1>
          <Param2>param2value</Param2>
        </Query>
      </string_XML>
    </Query>
  </soap:Body>
</soap:Envelope>

But, I get an error response:

<faultcode>soap:Client</faultcode>
  <faultstring>Server was unable to read request. --> There is an error in XML document (6, 2). --> 'Element' is an invalid node type. Line 6, position 2.</faultstring>

However, by sending the following message (html-encoded inside), it is successful:

[...]
    <Query xmlns="http://www.blablabla.com/WebServices/Query">
      <string_XML>
        &lt;Query&gt;&lt;Param1&gt;param1value&lt;/Param1&gt;&lt;Param2&gt;param2value&lt;/Param2&gt;&lt;/Query&gt;
      </string_XML>
[...]

Note that adding CDATA around the tag #2 is also successful.

The fix described above seems quite dirty to me.

My question is about the server side.
I thought that the routing was performed using the SOAP Action and that the SOAP Body shall only contain the business relevant data.

However, in my case, it does not seem to work that way:
-The Query tag is there twice (I guess once too much)
-And the string_XML tag is certainly not there for business

[...]
 <Query xmlns="http://www.blablabla.com/WebServices/Query">  <- <Query> tag #1 useless ?
   <string_XML>           <- useless ?
     &Query&...           <- <Query> tag #2 should be pure xml ?
[...]

Both the Query tag #1 and the string_XML tag seem totally useless from a business perspective.

Why couldn't I just send pure XML in the SOAP Body ?
Is there a first service that parses the request until string_XML and then passes the content to another piece of code that handles the business ?
What is the architecture behind the scene responsible for this ?

Thanks in advance for your help,
Nicolas.

1 Answer 1

1

Why couldn't I just send pure XML in the SOAP Body ?

Because that's the way SOAP was designed. The outer part of your xml is just a format defined by the SOAP protocol. You try to pass a string (xml is not a soap data type) via that protocol, so the string has to be encoded. And if you do that properly, your code obviously works.

It's not clear to me, why you care about those implementation details. Usually you should you client library handle these details. You shouldn't even care, that XML is involved at all. If you think for some reason, that SOAP has to much overhead, then you're probably right. But then you should try to change SOAP. Just use REST.

1
  • Thanks for your reply, I am not sure to understand. I am fine with using a SOAP Envelope and a SOAP Body if this is what you mean by overhead. But in the SOAP Body, I want to put only business relevant data as the routing is performed through the SoapAction in the http header. What kind of architecture impose the SoapBody to have the business data encapsulated in useless XML tags (Query #1, string_XML in my case) ?
    – user727504
    Apr 27, 2011 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.