Microsoft KB Archive/305965

= HOW TO: Consume XML Web Service Methods by Using SOAP Toolkit 2.0 =

Article ID: 305965

Article Last Modified on 9/30/2003

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition Service Pack 5
 * Microsoft XML Core Services 4.0
 * Microsoft SOAP Toolkit 2.0

-



This article was previously published under Q305965





IN THIS TASK
SUMMARY
 * Create an Application in Visual Basic
 * Troubleshooting



SUMMARY
This step-by-step article describes how to make simple calls to an XML Web service by using Simple Object Access Protocol (SOAP) Toolkit version 2.0.

back to the top

Create an Application in Visual Basic
 Download and install the SOAP Toolkit from the following Microsoft Developer Network (MSDN) Web site:

http://msdn.microsoft.com/downloads/default.asp?URL=/code/sample.asp?url=/msdn-files/027/001/580/msdncompositedoc.xml

This includes downloads for the Toolkit, the Toolkit samples, and a merge module for redistributing the underlying objects that you can include with the setup program for your application. Make a local copy of the Web Services Description Language (WSDL) file.NOTE: Although this step is not required, you should make a copy on your local computer. It is possible to specify the URL for the WSDL on the remote server, but it can be more convenient to copy the file locally.

 : Although this step is not required, you should make a copy on your local computer. It is possible to specify the URL for the WSDL on the remote server, but it can be more convenient to copy the file locally.In your Visual Basic project, add a reference to the Microsoft SOAP Type Library. To do this, select References on the Project menu, and then be sure that Microsoft Soap Type Library is selected in the list. Click OK.  : Although this step is not required, you should make a copy on your local computer. It is possible to specify the URL for the WSDL on the remote server, but it can be more convenient to copy the file locally.Create an instance of the SoapClient object, as follows: Dim oSoapClient As New MSSOAPLib.SoapClient   : Although this step is not required, you should make a copy on your local computer. It is possible to specify the URL for the WSDL on the remote server, but it can be more convenient to copy the file locally.Initialize the SoapClient object with the WSDL file that you copied in Step 2 by using the mssoapinit method, as follows: oSoapClient.mssoapinit &quot;C:\CLIENTWSDLS\CALC.WSDL&quot;, &quot;Calc&quot;, &quot;CalcSoapPort&quot; The first parameter is the path to the WSDL file. The second parameter is the value of the name attribute for the service element in the WSDL file that corresponds to the XML Web service that you want to call. The third parameter is the port type for the service element that corresponds to the XML Web service that you want to call. This parameter indicates the type of connection that will be made to the XML Web service.   : Although this step is not required, you should make a copy on your local computer. It is possible to specify the URL for the WSDL on the remote server, but it can be more convenient to copy the file locally.Call the XML Web service method by using the SoapClient object as if it were a method that is exposed by the SoapClient object itself. For example, if you attempt to call an XML Web service method called Add that takes two integers as parameters, your code may resemble the following: Dim Sum As Integer Sum = oSoapClient.Add(3, 4) </li> : Although this step is not required, you should make a copy on your local computer. It is possible to specify the URL for the WSDL on the remote server, but it can be more convenient to copy the file locally.Build and run the program.</li></ol>

back to the top

Troubleshooting
If the methods require complex parameters, you may need to handle them differently. For more information, see the &quot;Handling Complex Types&quot; topic in the online documentation for SOAP Toolkit 2.0.

back to the top

Keywords: kbhowto kbhowtomaster KB305965

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.