Basic Understanding of WSDL documentsAndHow to Use a WSDL File to Access a SOAP Service&nbs ...
How to Use a WSDL File to Access a SOAP Service What is WSDL?
Web Service Description Language (WSDL). These files are used to describe in great detail each web service and what operations it knows how to perform. A WSDL file consists of several main sections:
- Services
The service element(s) of a WSDL file defines a collection of ports, and points to a particular binding for each port.
- Ports
Ports are methods that can be used to access the service.
- Bindings
Each binding element of a WSDL file points to a corresponding port type and describes the data format and protocol for each (including a sneak peak at the operations).
- PortTypes
Each portType element of a WSDL file describes the operations that the service can implement. Each operation description defines the input and output message that it uses.
- Messages
The message elements of a WSDL file contain information about particular messages passed to and from a web service. There are exactly one input and one output message for every operation.
| | | Ã | Operation 1 | I/O messages |
| Port 1à | Binding à | PortType 1 à | Operation 2 | I/O messages |
| | | Ã | Operation 3 | I/O messages |
| | | | | |
Service | Port 2 | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
So each service (more than one can be defined in a WSDL file) can define one or more ports. Ports basically define how the service can be accessed. The three most common ports at this point are SOAP, HTTP Get, and HTTP Post. In this document, I am going to concentrate on the SOAP port. Each port points to a binding, each binding points to a portType, and each portType defines the operations it can perform. These operations can be anything from addition to supplying a stock quote. Each of these operations then defines its input and output messages.
So each piece of the file contains valuable information that will tell you how to use the service that it describes.
Let’s take a look at an example service borrowed from www.xmethods.net. Xmethods lists a domain name checker service that will determine if a particular domain name is available. The WSDL for this particular service is located at http://services.xmethods.net/soap/urn:xmethods-DomainChecker.wsdl.
First, let’s examine the <service> element:
<service name="net.xmethods.services.domainchecker.DomainCheckerService">
<documentation>net.xmethods.services.domainchecker.DomainChecker web service</documentation>
<port name="net.xmethods.services.domainchecker.DomainCheckerPort" binding="tns:net.xmethods.services.domainchecker.DomainCheckerBinding">
<soap:address location="http://64.39.29.211:9090/soap" />
</port>
</service>
This service, named net.xmethods.services.domainchecker.DomainCheckerService contains one port definition (as well as a name) that points to a binding called (for short) DomainCheckerBinding. The port definition also contains a soap:address location, which will be the end point URL we’ll use to access the service. Make a note of this endpoint URL.
Next, we can check out the binding that this service points us to.
<binding name ="net.xmethods.services.domainchecker.DomainCheckerBinding" type ="tns:net.xmethods.services.domainchecker.DomainCheckerPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="checkDomain">
<soap:operation soapAction="urn:xmethods-DomainChecker#checkDomain" />
<input>
<soap:body use="encoded" namespace="urn:xmethods-DomainChecker" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body use="encoded" namespace="urn:xmethods-DomainChecker" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
This binding defines one operation named checkDomain, which of course has an input and output message. An important piece here is the method URI of each operation. Notice the namespace="urn:xmethods-DomainChecker" . This is the method URI for the operation checkDomain. The binding includes a binding style, encoding style and transport protocol definition, and also a portType. Let’s take a look at this portType.
<portType name ="net.xmethods.services.domainchecker.DomainCheckerPortType">
<operation name="checkDomain" parameterOrder="symbol">
<input message="tns:checkDomainRequest1" />
<output message="tns:checkDomainResponse1" />
</operation>
</portType>
This portType (just like the binding) describes the operations and the operation input/output messages. However, here rather than describing what encoding styles and transport methods to use, we see how to find the actual definitions of these messages.
<input message="tns:checkDomainRequest1" />
This input message is called checkDomainRequest1. Now we can go to the <message> element that corresponds with this message name and see exactly what it is.
<message name="checkDomainRequest1">
<part name="symbol" type="xsd:string" />
</message>
Here we can see that the Request message contains 1 part named symbol which is a string. Each message can include more than one part or parameter.
Now through examining the WSDL file we have gathered some important pieces of information about this web service:
- End point URL
- Method URI
- The Operation that we want to perform, or Method name.
- Input parameters (messages)
So we are ready to use this information to form our SOAP request to access the service. I am going to form this request with the IP*Works! SOAP component. For those of you who are not familiar with this particular component you can download a fully functional free trial version at /n software.
This component is made to be extremely easy to use. All I have to do from here on is fill in the blanks with the information I have gathered:
SOAP1.URL = http://64.39.29.211:9090/soap ‘The Endpoint URL
SOAP1.MethodURI = "urn:xmethods-DomainChecker" ‘The Method URI
SOAP1.Method = "checkDomain" ‘The Method Name
SOAP1.AddParam "symbol", Microsoft.com ‘The input message
Here I’ll use Microsoft.com as my symbol to perform the domain check on. Now I simply send the request:
SOAP1.SendRequest
And retrieve the value from the SOAP1.ReturnValue property.
Response.write Domain: + SOAP1.ReturnValue
Here, the output I receive is:
Domain: unavailable
Now I can incorporate this service into my ASP application, .Net app, VB app, Delphi app, Java app, or whatever.
More Information
For information about the author, please contact lancer@nsoftware.com.
For more information about IP*Works! or the SOAPcomponent, please visit /n software.
Copyright © 2002, Lance Robinson - All Rights Reserved. For publishing permissions, contact lancer@nsoftware.com.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More ASP Code Articles
More By aspfree
developerWorks - FREE Tools! |
Join this webcast, to learn how the Rational Process Library can help with compliance issues, drive process improvement, and assist in service-oriented architecture (SOA) or Agile development. We will take a peek into the Rational Process Library with content around software and systems engineering (including RUP), operations and systems management, program and portfolio management, and asset and SOA governance. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download IBM DB2 Express-C 9.5, a no-charge version of DB2 Express 9 database server. DB2 Express-C offers the same core data server base features as other DB2 Express editions and provides a solid base to build and deploy applications developed using C/C++, Java, .NET, PHP, and other programming languages. FREE! Go There Now!
|
|
|
|
Learn how to implement a build management system that uses and extends your existing automation technologies. This tutorial shows, step-by-step, how to install and configure IBM Rational Build Forge to manage builds for Jakarta Tomcat from source code. FREE! Go There Now!
|
|
|
|
Because access to government information continues to be an area of concern for many U.S. citizens with disabilities, the U.S. government enacted Section 508 of the Rehabilitation Act in 2001 to ensure that government agencies create accessible Web content, enabling all citizens to access the information they need. A fully accessible Web site makes Web content accessible to all individuals, including those with disabilities, who may be accessing Web content via a variety of user agents. Common user agents include standard Web browsers, text-only browsers, assistive devices and mobile devices such as cell phones or personal digital assistants (PDAs). FREE! Go There Now!
|
|
|
|
Join this webcast to discover the key requirements for successful change and release management. Learn how to extend your .NET environment to improve productivity and collaboration, and address core problems afflicting team development. In this webcast, we’ll review typical challenges faced by customers and how to resolve them with the IBM Rational Change and Release Management solution, including Rational ClearCase, Rational ClearQuest and Rational Build Forge. Replay is available for 9 months. FREE! Go There Now!
|
|
|
|
Informix Dynamic Server (IDS) Express Edition offers outstanding online transaction processing (OLTP) database performance, while helping to simplify and automate many of the tasks associated with deploying databases for small business applications. IDS 11 further extends the ease of management and applications integration with the Admin API and Scheduler, high availability with Continuous Log Restore for backup server recovery in case of a primary server failure, and column level encryption to protect personal and company private data. FREE! Go There Now!
|
|
|
|
You can now evaluate IBM Rational Asset Manager V7.0 online without installing or configuring it on your own system! Rational Asset Manager helps create, modify, govern, find, and reuse any type of development assets, including SOA and systems development assets. Rational Asset Manager helps you reduce software development costs and improve quality by facilitating the reuse of all types of software development-related assets. Visit developerWorks to learn more about this product and register to explore its capabilities online. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to try the IBM SOA Sandbox for connectivity. The SOA Sandbox for connectivity provides a trial environment with the tooling and components to help you explore how to effectively connect your infrastructure and integrate all of the people, processes and information in your company. Use the hosted sandbox to explore SOA techniques that streamline connecting existing IT assets together, as well as learn how to connect them to new business logic. FREE! Go There Now!
|
|
|
|
Join the IBM Watchfire team for an informative discussion on techniques and best practices to proactively manage Web application security and how to effectively build application security testing into the software development lifecycle (SDLC). In this Software Delivery Platform webcast you will learn: How to better understand potential web application security vulnerabilities, best practices and how to effectively integrate application security testing into the software development lifecycle, the importance of detecting and removing software vulnerabilities during application development. FREE! Go There Now!
|
|
|
|
With IBM Rational Systems Development Solution, you can deliver products faster with higher quality. Within this kit, Read the “Model Driven Systems Development” white paper to see how to improve product quality and communication. Then check out the rest of the e-Kit to learn more about important topics that can affect the success of any software project through customer examples, tutorials, informative Webcasts, and best practices for designing, building and managing systems. From start to finish, at every stage in your projects, Rational Systems Development Solution can help your company reach its full potential. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |