Skip to content

Can We Use Postman To Test Soap Web Service

API Testing Blog

Can Postman Test SOAP Web Services?

While Postman is primarily designed for RESTful API testing, it can also be used to test SOAP web services, albeit with a little extra configuration. Here’s a comprehensive guide on how to achieve this:

Understanding SOAP and Postman

SOAP (Simple Object Access Protocol) is a messaging protocol built on XML for exchanging structured information. It relies on web services that follow specific standards for communication. Postman is a powerful tool for API testing, offering a user-friendly interface for sending requests, receiving responses, and managing test cases.

Setting Up Postman for SOAP Testing

  1. Installing the SOAP Plugin: Postman doesn’t natively support SOAP requests. You need to install a plugin called “SOAP Request Builder.” It adds a new “SOAP” tab to Postman’s request builder, allowing you to send SOAP requests.

  2. Creating a New Request: Open a new tab in Postman. Switch to the “SOAP” tab. You’ll be presented with a pre-populated XML structure:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soapenv:Header/>
    <soapenv:Body>
    <ns1:yourOperationName xmlns:ns1="yourNamespace">
    <!-- Add your request parameters here -->
    </ns1:yourOperationName>
    </soapenv:Body>
    </soapenv:Envelope>
  3. Modifying the Request Structure:

    • soapenv:Envelope: The root element of the SOAP message.
    • soapenv:Header: Contains optional header information for the request.
    • soapenv:Body: Holds the payload or request data.
    • ns1:yourOperationName: Represents the specific operation you’re calling (e.g., “GetWeather”). Replace yourNamespace and yourOperationName with the values from your SOAP service definition.
    • Request Parameters: Define the parameters required for your SOAP operation within the ns1:yourOperationName element.

Example: Testing a Weather Service

Let’s test a hypothetical weather service using Postman:

  1. Service WSDL: Assume the service’s WSDL (Web Services Description Language) is available at: http://example.com/weather/weather.wsdl.

  2. Request:

    • Open a new tab in Postman.
    • Switch to the “SOAP” tab.
    • Replace the example XML structure with:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:wfs="http://www.webservicex.net/weather">
    <soapenv:Body>
    <wfs:GetWeather>
    <wfs:CityName>New York</wfs:CityName>
    </wfs:GetWeather>
    </soapenv:Body>
    </soapenv:Envelope>
    • Set the request method to “POST”.
    • Enter the service’s URL in the “Request URL” field. This is typically the URL of the WSDL file.
  3. Sending the Request: Click on the “Send” button. Postman will send the SOAP request to the server.

  4. Response: The response will be displayed in the response pane. You can view the XML response to verify the success of the request and analyze the weather data returned from the server.

Advanced Techniques

  • Authorization: Use the Authorization tab to authenticate with the SOAP service if required (e.g., using Basic Authentication, OAuth, etc.).

  • SOAP Headers: Add headers to your request by clicking on the “Headers” tab. Use them to pass additional information like session tokens or authentication tokens.

  • Validation of Responses: Postman allows you to validate the response using assertions. You can use built-in assertions (like “Status code is 200”) or JavaScript code to perform complex validation checks on the XML response.

  • Test Collections: Organize your tests into collections for better management and reusability. You can create collections specifically for SOAP test cases.

  • Environments: Use Postman environments to store variables like API URLs and other sensitive data, making your tests more adaptable.

Exploring the SOAP Request Builder Functionality

  • WDSL Import: The “SOAP Request Builder” plugin lets you import the WSDL file of your SOAP service. This automatically generates the SOAP request structure based on the service’s definition.

  • Operation Selection: The plugin often provides a dropdown list of operations defined in the WSDL, making it easy to choose the specific operation you want to test.

  • Code Generation: Some versions of the “SOAP Request Builder” plugin can even generate code snippets in different programming languages (e.g., JavaScript, Python) to interact with your SOAP service programmatically.

Conclusion

Postman, even with its focus on REST APIs, can also handle SOAP testing effectively with the “SOAP Request Builder” plugin. By using the plugin’s features and leveraging Postman’s other capabilities like test collections, environments, and assertions, you can effectively test SOAP web services and ensure their functionality and reliability.

API Testing Blog