Skip to content

How To Use Wsdl In Postman

API Testing Blog

Understanding WSDL and its Role in API Testing

WSDL (Web Services Description Language) is an XML-based language used to describe web services. It outlines the operations, data types, and communication protocols of a web service. When testing APIs built using WSDL, understanding its structure and utilizing it effectively can significantly simplify and enhance your testing process.

How to Import WSDL into Postman

Postman offers a convenient way to import WSDL files directly, automatically generating requests and collections based on the WSDL description.

Step 1: Download the WSDL File

Obtain the WSDL file from the service provider. You can usually find it by appending ?wsdl to the URL of the web service endpoint.

Step 2: Import the WSDL in Postman

  1. Open Postman and click on the New button to create a new request.
  2. From the dropdown menu, select Import.
  3. Click on From Link and paste the WSDL file URL.
  4. Postman will automatically parse the WSDL and generate requests and collections based on the service definition.
  5. You can review the generated requests and collections, customize parameters, and run tests.

Using the Generated Requests and Collections

Postman creates requests based on the operations defined in the WSDL. Each request includes:

  • URL: The endpoint for the corresponding operation.
  • Method: The HTTP method specified in the WSDL (e.g., GET, POST, PUT, DELETE).
  • Headers: The required headers for communication with the web service.
  • Body: The request payload structure based on the WSDL’s data type definitions.

You can modify these requests based on your specific testing scenario.

Example: Testing a Simple Weather API

Let’s assume we have a WSDL file describing a simple weather API with operations like GetWeatherByCity and GetWeatherByCoordinates.

Step 1: Import the WSDL

Import the WSDL file using the steps outlined above. Postman will generate requests for each operation.

**Sample WSDL (Simplified) **

<definitions ...>
<message name="GetWeatherByCityRequest">
<part name="city" type="xsd:string" />
</message>
<message name="GetWeatherByCityResponse">
<part name="weather" type="tns:WeatherInfo" />
</message>
<portType name="WeatherServicePortType">
<operation name="GetWeatherByCity">
<input message="tns:GetWeatherByCityRequest" />
<output message="tns:GetWeatherByCityResponse" />
</operation>
...
</portType>
</definitions>

Step 2: Send the “GetWeatherByCity” Request

  1. Choose the generated request for the GetWeatherByCity operation.
  2. Set the “city” parameter in the request body to the desired city name (e.g., “London”).
  3. Click Send.

Sample Request Body:

{
"city": "London"
}

Step 3: Analyze the Response

The response will contain the weather data for the specified city in the format defined by the WSDL.

Sample Response:

{
"weather": {
"temperature": 20,
"condition": "Sunny"
...
}
}

Creating Custom Requests for Testing

While Postman automatically generates requests based on the WSDL, it’s possible to create custom requests for specific scenarios. This allows you to test edge cases or explore different aspects of the API.

Step 1: Create a New Request

Create a new request in Postman.

Step 2: Set the URL

Use the correct endpoint for the operation you want to test. This information is available in the WSDL file.

Step 3: Define the Request Method

Choose the appropriate HTTP method (e.g., GET, POST, PUT, DELETE) based on the operation’s requirements.

Step 4: Provide Request Headers and Body

Use the WSDL to determine the required headers and body structure for the request. You can manually set them in Postman.

Example Custom Request:

// Manually Constructed Request
POST http://example.com/weather/forecast
// Request Headers
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
// Request Body
{
"latitude": 51.5074,
"longitude": 0.1278
}

Using WSDL for API Testing: Advantages

  • Increased Efficiency: WSDL provides a clear and concise definition of the API, allowing you to automatically generate requests and collections. This saves time and effort compared to manual request construction.
  • Improved Consistency: By utilizing WSDL, you ensure that your tests are consistently aligned with the API’s structure and functionality.
  • Enhanced Reusability: Once you have a collection of generated requests based on the WSDL, they can be reused for future testing, even if the API evolves.
  • Stronger Test Coverage: WSDL definitions help you identify all the operations and their variations, enabling you to create comprehensive tests.

Conclusion

WSDL plays a crucial role in API testing by providing a structured and standardized way to define web services. By leveraging Postman’s integration with WSDL, you can streamline your testing process, improve efficiency, and ensure higher test coverage. This approach ensures that your APIs are consistently tested against the intended functionality and specifications.

API Testing Blog