This article has been copied and reformatted from the below website:
https://hi.service-now.com/kb_view.do?sysparm_article=KB0690780
Description:
- Scope of this article is to describe how to make a SOAP call to an instance using the CURL command. This will help troubleshooting customer related issues when using the SOAP API.
Step 1:
- Create the SOAP Envelope that contains the request that has to be sent
- Note: The soap request parameters depend on the parameters that the WSDL expose.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inc="http://www.service-now.com/incident">
<soapenv:Header/>
<soapenv:Body>
<inc:get>
<sys_id><enter_sys_ID_of_record_to_retrieve</sys_id>
</inc:get>
</soapenv:Body>
</soapenv:Envelope>
- Save it in a file as .xml (example test.xml)
Step 2:
- Create the CURL command that you will input in the terminal.
- curl –username:password –header “Content-Type: text/xml;charset=UTF-8” –header “SOAPAction: ACTION_YOU_WANT_TO_CALL” –data @FILE_NAME URL_OF_THE_SOAP_WEB_SERVICE_ENDPOINT
- Example 1 – If you are consuming the WSDL from an Instance
- curl –user xyz:abc123 –header “Content-Type: text/xml;charset=UTF-8” –header “SOAPAction:Get” –data @test.xml https://.service-now.com/incident.do?SOAP
- Example 2 – If you are consuming the WSDL from a Node
- curl –user xyz:abc123 –header “Content-Type: text/xml;charset=UTF-8” –header “SOAPAction:Get” –data @test.xml https://.service-now.com:/incident.do?SOAP
- Execute the command in Terminal or command prompt.
Troubleshooting – Tips
- If ever you see that you are not receiving the expected output, then add the verbose parameter to the curl command and this shall give you more information.
- Example of the curl command with verbose:
- curl –user xyz:abc123 –header “Content-Type: text/xml;charset=UTF-8” –header “SOAPAction:Get” –data @test.xml https://.service-now.com/incident.do?SOAP -v
Troubleshooting – Possible Error 1
- Error – The file containing the request is not readable
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring>Unable to parse SOAP document</faultstring>
<detail>Error completing SOAP request</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
- Solution – Check the content and format of the file that contains the SOAP Request
Troubleshooting – Possible Error 2:
- Error – The credential of the user specified is wrong or user is not authorized to access the WSDL
< HTTP/1.1 401 Unauthorized
< Set-Cookie: JSESSIONID=5C48D05E518DC37DA6502440F2FD8361; Path=/; HttpOnly;Secure
* Authentication problem. Ignoring this.
- Solution : Check the user credential and if there is any ACL blocking the user from accessing the record
Troubleshooting – Possible Error 3:
- Error – The WSDL is incorrect/wrong
* Could not resolve host: <URL_OF_THE_SOAP_WEB_SERVICE_ENDPOINT>
* Closing connection 0
curl: (6) Could not resolve host: URL_OF_THE_SOAP_WEB_SERVICE_ENDPOINT
- Solution: Check if the correct URL is specified in the curl command.