SOAP Requests with Postman
Postman is a clean, easy-to-use REST client, but it also works well for sending SOAP message via HTTP. Configuring Postman for a SOAP request is similar to a REST configuration.
It might help if you already understand:
- Sending REST API requests with Postman
- SOAP APIs
For the purpose of this walkthrough we’ll use a mock company called Robot Lenders. We will send a SOAP request, or message, containing applicant information for a loan pre-qualification.
VERB and URL
We’ll submit a POST request to the Robot Lenders API using the following URL and endpoint: of https://www.robot-lending.com/quick-loan
HTTP Headers
Next we’ll set the HTTP headers (not to be confused with headers in the SOAP envelope).
Let’s set the ContentType
header. Below the URL:
- Click on
Body
- Check
raw
- Select
XML text/xml
By selecting XML(text/xml)
Postman automatically adds a ContentType
header with the value text/xml
.
Now we’ll take a look at the SOAPAction
header. This seems to be point of confusion for developers working with SOAP APIs… and for good reason.
Read more about SOAPAction in this article by Mark Baker.
Read about using SOAPAction in the comments in the Postman Blog.
In our example, if we send the request without a SOAPAction
header we may get an error: <faultstring>no SOAPAction header!</faultstring>
Though our example does not require a specific SOAPAction
it will fail if we leave the header out completely, so we have to include the header and enter a value of ""
(an empty string).
If you are not familiar a SOAP Message, check out: Anatomy of a SOAP Message.
The Body
Click on Body
and enter the XML/text body.
We should be ready. Let’s fire off our request by hitting Send
Important: You should be aware this is a mock demonstration and not a working API. Entering the data from this tutorial into Postman will not produce results. Apply these principals to your real data and API
Success!?
If our response is a success we’ll see: Status 200 OK
(below the request body in the upper right corner of the response section)…
… and the response may be something like this:
As we can see the loan was pre-approved and we received an account number and amount in the params.
Not-a-success!?
If our response is not successful we may see something like Status 500 Internal Server Error
…
… and the response may be something like this:
Troubleshooting
- Remember that even if a specific
SOAPAction
is not required by the API, the header may still be necessary for the request to work. - If you are using a timestamp, be sure it meets the specs from the API docs. Check that it is set to GMT and on a 24 hour cycle (i.e. if it’s afternoon, it should read 15:30, not 3:30).
- Also, make sure the timestamp is current. Timestamps are used to ensure the request is current and the request may be denied if the timestamp is even a few minutes old.
- If you are using a nonce, make sure it is unique with each request.
- Check the SOAP message format.
- Ensure that the schema URLs are correct.
- 99% of my errors are typos and incorrect spelling.
We hope this helps!
Please feel free to leave kind comments, suggestions, corrections and better solutions!