Reputation: 213
I want to post xml to a webservice using postman. Below is the raw body xml. The parameter "xml" is a string value that I'd like to pass through, however, the request status returns 400 due to bad syntax. I suspect that its because the parameter value is being formatted as xml.
Everything works fine in my real applications, I just cannot get this to work if I want to test using postman.
How can one send this parameter as string?
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header/>
<soap:Body>
<SaveLead xmlns="http://tempuri.org/">
<xml>
<enquiry><Lead Ref='1234' Source='SourceDesc'><Contact FirstName='TestN' Surname='TestS' Email='[email protected]' Mobile='0830000000' /></Lead></enquiry>
</xml>
</SaveLead>
</soap:Body>
</soap:Envelope>
A sample of the webservice soap request
POST /webservice1.asmx HTTP/1.1
Host: xxxxx
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/SaveLead"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<SaveLead xmlns="http://tempuri.org/">
<xml>string</xml>
</SaveLead>
</soap:Body>
</soap:Envelope>
Upvotes: 2
Views: 14109
Reputation: 213
As per Danny's comment above, escaping the XML string with the CDATA section solved this.
Definition: CDATA sections may occur anywhere character data may occur; they are used to escape blocks of text containing characters which would otherwise be recognized as markup. CDATA sections begin with the string
<![CDATA[ " and end with the string " ]]>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header/>
<soap:Body>
<SaveLead xmlns="http://tempuri.org/">
<xml>
<![CDATA[ <enquiry><Lead Ref='1234' Source='SourceDesc'><Contact FirstName='TestN' Surname='TestS' Email='[email protected]' Mobile='0830000000' /></Lead></enquiry> ]]>
</xml>
</SaveLead>
</soap:Body>
</soap:Envelope>
Upvotes: 6