SoapUI responds with 400 bad request

I need to make a post request to a web service. The web service has the following structure:

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:kn="http://..//soapAction">
   <soap:Header/>
   <soap:Body>
    <kn:InsertOrders>
      <!--Optional:-->
      <kn:XmlOrders>?</kn:XmlOrders>
      <kn:stringLength>?</kn:stringLength>
      <!--Optional:-->
      <kn:LoadListId>?</kn:LoadListId>
   </kn:InsertOrders>
 </soap:Body>
</soap:Envelope>

XmlOrders accepts a string and I'm trying to pass the following xml String in it:

    <?xml version="1.0" encoding="utf-8"?> <EXAMPLE xmlns="EXAMPLE"> <HEADER> <ID>G112233</ID> <TR>AB123</TR> </HEADER> <HEADER> <ID>G123123</ID> <TR>AB1234</TR> </HEADER> <DETAIL> <DETAILID>123123123</DETAILID> <TXT>ATR_123</TXT> </DETAIL> <DETAIL> <DETAILID>123123123</DETAILID> <TXT>ATR_123</TXT> </DETAIL> </EXAMPLE>

However, SoapUI returns 400 bad request:

    Wed May 16 12:41:19 EEST 2018:DEBUG:Receiving response: HTTP/1.1 400 Bad Request
    Wed May 16 12:41:19 EEST 2018:DEBUG:Connection can be kept alive indefinitely

Does anyone have any idea about it?

Upvotes: 1

Views: 11378

Answers (2)

I post this answer here because this is what solved my problem. I wrapped the XML String inside: "<![CDATA[" + myXMLString + "]]>" It actually parsed the XML String without encoding it,or escaping the characters > , < , & , ', ".

Upvotes: 2

Red Boy
Red Boy

Reputation: 5739

Yes, you could convert XML into String and set it into Method call.

Eventually, When XML gets converted into String

' is replaced with &apos;

" is replaced with &quot;

& is replaced with &amp;

< is replaced with &lt;

> is replaced with &gt;

refer XML escaping for more details.

Your example XML will become--

 &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;EXAMPLE xmlns=&quot;EXAMPLE&quot;&gt; &lt;HEADER&gt; &lt;ID&gt;G112233&lt;/ID&gt; &lt;TR&gt;AB123&lt;/TR&gt; &lt;/HEADER&gt; &lt;HEADER&gt; &lt;ID&gt;G123123&lt;/ID&gt; &lt;TR&gt;AB1234&lt;/TR&gt; &lt;/HEADER&gt; &lt;DETAIL&gt; &lt;DETAILID&gt;123123123&lt;/DETAILID&gt; &lt;TXT&gt;ATR_123&lt;/TXT&gt; &lt;/DETAIL&gt; &lt;DETAIL&gt; &lt;DETAILID&gt;123123123&lt;/DETAILID&gt; &lt;TXT&gt;ATR_123&lt;/TXT&gt; &lt;/DETAIL&gt; &lt;/EXAMPLE&gt;

Upvotes: 0

Related Questions