Import the WSDL File Into Your Development Platform
Once you have the WSDL file, you need to import it into your development platform so that your development environment can generate the necessary objects for use in building client Web service applications in that environment.
The following two sets of instructions in this document provide sample instructions. One set is for Apache Axis Java; the other is for Microsoft Visual Studio. For instructions about other development platforms, see that platform’s product documentation.
Instructions for Java Environments (Apache Axis)
Java environments access the API through Java objects that serve as proxies for their server-side counterparts. Before using the API, you must first generate these objects from your organization’s WSDL file. Each SOAP client has its own tool for this process. For Apache Axis, use the WSDL2Java utility. (See http://ws.apache.org/axis/java/user-guide.html#UsingWSDLWithAxis for additional background and guidance).
The basic syntax for WSDL2Java is:
java –classpath pathToJAR/Filename org.apache.axis.wsdl.WSDL2Java -a pathToWsdl/WsdlFilename
The -a switch generates code for all elements, referenced or not, which may be necessary depending on your WSDL. For more information on this, see the WSDL2Java online reference guide.
If you have JAR files in more than one location, list them with a semicolon separating the files. For example, if the Axis JAR files are installed in C:\axis-1_3, and the WSDL is named loyalty.wsdl and is stored in C:\mywsdls: java –classpath.
c:\axis-1_3\lib\axis.jar;c:\axis-1_3\lib\axi-ant.jar;c:\axis-1_3\lib\axis-schema.jar; c:\axis-1_3\lib\commons-discovery-0.2.jar;c:\axis-1_3\lib\commons-logging-1.0.4.jar; c:\axis-1_3\lib\jaxrpc.jar;c:\axis-1_3\lib\log4j-1.2.8.jar;c:\axis-1_3\lib\saaj.jar; c:\axis-1_3\lib\wsdl4j-1.5.2.jar; org.apache.axis.wsdl.WSDL2Java -a C:\myswdls\loyalty.wsdl
This command will generate a set of folders and Java source code files in the same directory in which it was run. After these files are compiled, they can be included in your Java programs for use in creating client applications. For most Java development environments, you can use wizard-based tools for this process instead of the command line. For a WSDL2Java Reference, see http://ws.apache.org/axis/java/reference.html#WSDL2JavaReference.
Instructions for Microsoft Visual Studio
Visual Studio languages access the API through objects that serve as proxies for their server-side counterparts. Before using the API, you must first generate these objects from your organization's WSDL file. Visual Studio provides two approaches for importing your WSDL file and generating an XML Web service client: an IDE-based approach and a command line approach.
In addition, you need to have generated the WSDL file, as described in Generate or Obtain the Web Service WSDL File.
An XML web service client is any component or application that references and uses an XML web service. This does not necessarily need to be a client-based application. In fact, in many cases, your XML web service clients might be other web applications, such as web forms or even other XML web services. When accessing XML web services in managed code, a proxy class and the .NET framework handle all of the infrastructure coding.
To access an XML web service from managed code:
- Add a web reference to your project for the XML web service that you want to access. The web reference creates a proxy class with methods that serve as proxies for each exposed method of the XML web service.
- Add the namespace for the web reference.
- Create an instance of the proxy class and then access the methods of that class as you would access the methods of any other class.
To add a web reference:
- On the Project menu, choose Add Web Reference.
- In the URL box of the Add Web Reference dialog box, type the URL to obtain the service description of the XML web service you want to access, such as: C:\WSDLFiles\loyalty.wsdl.
- Click Go to retrieve information about the XML web service.
- In the web reference name box, rename the web reference to LoyaltyAPI, which is the namespace you will use for this web reference.
- Click Add Reference to add a web reference for the target XML web service. For more information, see the topic “Adding and Removing Web References” in the Visual Studio documentation.
- Visual Studio retrieves the service description and generates a proxy class to interface between your application and the XML web service.