Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to escape ampersand (&) in soap UI

I am using soap UI (from smartbear) to send soap requests in xml format as :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsg="http://wsg.hpos.om.hp.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <wsg:abc>
      <wsg:contract>
         &lt;request&gt;

         &lt;request-attributes&gt;
            &lt;message&gt;"this &amp; and that"&lt;/message&gt;                
         &lt;/request-attributes&gt;             
         &lt;/request&gt;             
         </wsg:contract>
      </wsg:abc>
   </soapenv:Body>
</soapenv:Envelope>

and the response is : Invalid request. Could you please throw light on how to escape &? Thanks

like image 440
akc Avatar asked Sep 23 '13 11:09

akc


People also ask

How do you escape ampersand in HTML?

If you want one to appear in text on a web page you should use the encoded named entity “ &amp; ”—more technical mumbo-jumbo at w3c.org. While most web browsers will let you get away without encoding them, stuff can get dicey in weird edge cases and fail completely in XML.

How do you handle an ampersand in a URL?

For example, to encode a URL with an ampersand character, use %24. However, in HTML, use either &amp; or &#38;, both of which would write out the ampersand in the HTML page.


1 Answers

You could wrap the payload inside <![CDATA[]]> and not worry about escaping:

<![CDATA[<request>
    <request-attributes>
        <message>"this & and that"</message>
    </request-attributes> 
</request>]]>
like image 105
AlexandrosD Avatar answered Oct 16 '22 09:10

AlexandrosD