Integration: Outbound SOAP Message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 01:33 AM - edited 03-21-2025 01:58 AM
Hi Team,
I am trying SOAP integration where I have been provided with the WSDL but the client is just having the API Key. How can I establish the connection using token? When asked about the user name and password for the authentication client mentioned to use API token in header.
Can anyone help in providing a way forward?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 02:10 AM - edited 03-21-2025 05:36 AM
Hi @Ankur Bawiskar ,
Yes, I have the sample request body and end point along with the API key. When we asked about the user name and password for authentication they said use the API key in the header. So I am not sure how to use API key in header (since we don't have option to add header as we have in REST API).
For now I have created a record in Outbound SOAP message use the link in WSDL field and Authentication type none. When I hit Generate Sample SOAP message related link then I get an info message unable to load WSDL.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 05:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 05:41 AM
ask them how it can be consumed via SOAP UI which is an external tool to test SOAP endpoints
this link should help
New to SOAP, no clue what I'm doing
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 01:48 AM
Hi Rohit,
As your client has provided only an API token and expects it to be used in the header, you need to modify your SOAP request to include this token in the HTTP headers. Here’s a step-by-step guide:
1. Understand Authentication Type
Since the client has asked to use the API token in the header, it likely means Bearer Token Authentication or a Custom API Key Authentication.
2. Modify Your SOAP Request
Typically, SOAP authentication uses WS-Security headers for username/password, but in your case, you need to pass the token in the HTTP headers.
Option 1: Using a Custom API Token in Headers
If the API token is expected as a custom header, include it in the request headers:
Header Name: Authorization
Value: Bearer <API_TOKEN> (or whatever format the API provider expects)
Example: SOAP Request with Token in Headers using Python (Requests Library)
import requests
wsdl_url = "https://example.com/service?wsdl" # Replace with actual WSDL URL
soap_endpoint = "https://example.com/service" # Replace with actual endpoint
api_token = "your_api_token_here" # Replace with the provided API token
# Sample SOAP Request Body (Modify as per WSDL)
soap_body = """<?xml version="1.0"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://example.com/">
<soapenv:Header/>
<soapenv:Body>
<web:YourRequest>
<web:Parameter>Value</web:Parameter>
</web:YourRequest>
</soapenv:Body>
</soapenv:Envelope>"""
# Headers for SOAP request with API token
headers = {
"Content-Type": "text/xml;charset=UTF-8",
"Authorization": f"Bearer {api_token}", # Using API token for authentication
"SOAPAction": "YourSOAPActionHere" # Check the WSDL for required SOAP action
}
# Sending the SOAP request
response = requests.post(soap_endpoint, data=soap_body, headers=headers)
# Print response
print(response.status_code)
print(response.text)
Option 2: API Token as a Custom Header (Alternative)
Sometimes, APIs expect tokens as a custom header instead of Authorization. If your client specifies a different header, replace "Authorization" with their expected header, e.g.:
headers = {
"Content-Type": "text/xml;charset=UTF-8",
"X-API-KEY": api_token, # Some APIs require a different header
"SOAPAction": "YourSOAPActionHere"
}
3. Testing and Debugging
Test the API using Postman first by adding the API token in the request headers.
If authentication fails, confirm with the client whether:
The token should be prefixed with "Bearer " or another keyword.
A specific header name is required instead of "Authorization".
The API requires additional headers.
This should solve your issue!
Kindly mark it as "Accepted Solution"/"helpful", as it resolves your query. Please press like button for the resolution provided.
With Regards,
Krishna Kumar M - Talk with AIT3ch
LinkedIn: https://www.linkedin.com/in/mkrishnak4/
YouTube: https://www.youtube.com/@KrishAIT3CH
Topmate: https://topmate.io/mkrishnak4 [ Connect for 1-1 Session]