Transplaying from SOAP Toolkit to Web Services Upgrade to Microsoft. Netpeter Vogelph & V Information Service Company Overview: This article discusses how to access Web services from Microsoft Visual Basic 6.0 and Visual Basic .NET, how to convert existing SOAP applications to Microsoft .NET platform. Target Learn SOAP Tools in Microsoft® Visual Studio® .NET Reviewed the use of SOAP and Microsoft Visual Basic® 6.0 access COM / COM Components Accessing Web Services from Microsoft Visual Basic .NET Transfer SOAP Kit Applications to Web Service requirements To take advantage of this article, readers must have the following foundation: Understand What is Web Services Use Visual Basic 6.0 and SOAP, know how to create Microsoft ActiveX® DLL project Familiar with Visual Studio .NET Basic Directory Web Services, SOAP and Your own Tools Web Services Description Tool SOAP Toolkit 2.0 Introduction Visual Basic .NET Create a client from SOAP Toolkit to Visual Studio .NET Summary Web Services SOAP and User's own Tools Web Services provides functions, accessible over the Internet Function - Call the web service and get the return result. The new content in the Web service is to link to these services through the world's largest network -InetNet. However, as a Visual Basic programmers web service will handle all of the cumbersome details that utilize the Internet. This article discusses how to use Visual Studio .NET to access Web services and review the process of creating a web service using Visual Basic 6.0 and SOAP Toolkit 2.0. Also discuss how to convert the SOAP Toolkit application to use web services in the .NET framework. There is a very simple function CreateCustomUStomer in the web services used in this article. This function receives the customer's name and return to the customer identity. Functions in the web service are not required for discussion here, but should pay attention to how to create and access Web services using Visual Basic 6.0 or Visual Basic .NET. Visual Basic and SOAP can communicate with Web services by sending and receiving SOAP documents. In Visual Basic 6.0, there are two ways to create a SOAP document: 1. Assembly document through the series string 2. Use SOAPCLIENTSOAPCLIENT in Soap Toolkit 2.0 not only creates SOAP documentation with Web service communication, but also send documents to Go to the web service. In the transfer of the web server, you need to use the SOAP receiver to capture and process the document sent by the client. SOAP Toolkit 2.0 contains SOAPSERVER, which can process SOAP documents using this program receiver application. The receiver is a separate application that independently implements a web service component. It is simple to use Visual Studio .NET, create and access Web services. In Visual Studio .NET, creating a Web service does not need to build a separate receiver application. When accessing the web service, the code will be created automatically, which is like accessing other objects using a Web service. Web Services Description Tool Web Services Description Language (WSDL) is an XML language specifically designed to describe Web services. WSDL has been submitted to W3C with SOAP, which is only part of the web service into an open standard. The WSDL description of the service contains WSDLSPEC TMODEL, which provides all the necessary information that can be created and sent to the service and send SOAP documentation for the service.
Here is a WSDLSPEC TMODEL file that supports createCustomer function: XML Version = '1.0' encoding = 'UTF-8'?>
output message = 'wsdlns: Custservices.createCustomerResponse' /> operation> portType>
Visual Studio .NET also uses this information to create a proxy class for web services. As a result, you can: Ways to call the web service, just like these methods are the method of agents. Before sending the message, the call is verified according to the WSDL description of the web service. Interaction with proxy, not familiar with the content of the WSDL file or the generated SOAP Document Figure 1 shows the relationship between different components, including the Web Service Molin Language (WSML), only Visual Basic 6.0 requires WSML, and in Visual Basic 6.0 Describe it. Figure 1. Web services and customer structure In SOAP, SOAP Toolkit and Visual Studio .NET IDE perform similar features. However, the SOAP Toolkit object does not provide full support desired by Visual Basic developers. In Figure 2, you can see that the Visual Basic programmers think the INTELLISENSE® support for it. The IntelliSense drop-down list automatically displays the CreateCustomer method for the CustomerServices COM object. Figure 2. IntelliSense support for COM / DCOM / COM objects can see IntelliSense support provided by the SOAPCLIENT Web service in Figure 3. All SOAPCLIENT methods are listed, but SOAPCLIENT does not appear (ie, CreateCustomer) as the method of the agent running as a proxy. Figure 3. IntelliSense of SOAPCLIENT supports in Visual Studio .NET, the proxy class created by IDE compared to SOAPCLIENT compared to SOAPCLIENT. From Figure 4, you can see IntelliSense Support for accessing the web service. The CreateCustomer method shows the method of objects interact with the web service. Figure 4. Branch of Web Services in Visual Studio .NET Holding SOAP Toolkit 2.0 Introduction This section quickly created a web service described in Web Services, SOAP, and your own toolbar. Create and access Web Services with SOAP Toolkit 1. In Visual Basic 6.0, create a new Visual Basic ActiveX DLL project, named CustCP, the class module in the web service code is named CustomerServices. Public Function CreateCustomer (Byval First As String) AS String
CreateCustomer = "A" & CSTR (Len (LAST)) End Function2. Create a WSDL and WSDM file using the WSDL wizard in SOAP Toolkit (WSML file contains SOAPSERVER to map web service mapping Information for the ActiveX COM object). 3. Create a SOAP Receiver - a ASP page that uses SOAPSERVER. <% @Language = VBScript%> <% Option Explicit Dim SS DIM WSDL DIM WSML RESPONSE.CONTENTTYPE = "Text / XML" WSDL = Server.MAppath ("Cust.WSDL") WSML = Server.MAppath ("Cust.WSML" ) SET SS = Server.createObject ("mssoap.soapserver") SS.INIT WSDL, WSML SS.SOAPINVOKE Request, Response, ""%> 4. Create a customer who calls Web services, which will use SOAPCLIENT. Private Sub Cmdcreate_Click () DIM SC AS MSSOAPLIB.SOAPCLIENT
Set sc = New SoapClientsc.mssoapinit "http: //vogel2/cust/cust.wsdl" Me.txtCustId.text = _ sc.createCustomer (Me.txtFirstName.text, _ Me.txtLastName.text) End SubVisual Basic .NET vertical Look at this section how to learn: Create a web service in Visual Studio .NET. Access the web service from the Visual Studio .NET application. When you create a web service in Visual Studio .NET, you will automatically generate a discovery file for the web service. This file is used to add a reference to the Web service to other Visual Studio .NET applications, including WSDL description. Note that the file type of Discovery file is. VsDisco for Visual Basic and C # projects, is .disco for C-project. Create a Web Service in Visual Studio .NET 1. Select New from the File menu, display the New Project dialog, as shown in Figure 5. Figure 5. Visual Studio .NET New Project dialog 2. Select the ASP.NET Web service in the Visual Basic Projects section. 3. In the Name box, the project specified name (MigrateToDotNetService). 4. Enter the URL (LocalHost / Customer) of the Web Service website. 5. Click OK to create a project. By default, the project will contain a module service1.asmx named. 6. Right-click the Service1.asmx module and select View Code from the menu. 7. Add the following code to the PUBLIC CLASS Service1 statement at the upper part of the module:
Creating a customer does not have to create .NET Customer - Visual Basic 6.0 application created with SOAP Toolkit can access XML web services. The following steps demonstrate how to create a .NET customer for the web service, without having to consider the Web service written in Visual Basic .NET: 1. From the File menu, select New, then select Project, display Add Project dialog. 2. From the Visual Basic Projects section, select Windows Application. 3. Specify the project name (MigrateToWebClient in the Name box, click OK to create projects. 4. Right-click on the project in the scenario manager and select Add Web Reference. The Add Web Reference dialog box appears, as shown in Figure 6. Figure 6. Add Web Reference dialog 5. Enter the URL of the .vsdisco file in the Address box. Click the drop-down arrow at the end of the Address box, select the reference. Note You can get the URL of the web service engineering .vsdisco file by dragging the .vsdisco file from the scenario manager to the code module. Then cut the URL in the module and paste it into the Address box in the Add Web Reference dialog. 6. Click the Add Reference button to return to the project. The reference to the web service appears in the Scenario Manager, as shown in Figure 7. Figure 7. Visual Basic Windows Application after reference to the Web service 7. On the form, text box txtfirstname and txtlastname are used to save customer names, buttons code call Web services. 8. Add code, declare the variable, use this variable reference to process the proxy class of the web service (the default class named server name and web service name component): private subdcreate_click () DIM CC as localhost.service19. Add code initialization agent class, call WEB service method: set cc = new localhost.service1me.txtCust.Text = _ cc.createcustom (me.txtfirstname.text) End Sub10. Press F5 to run the client application to access Web services. Switch from SOAP Toolkit to Visual Studio .NET utilizes SOAP Toolkit or XML Web services to comply with SOAP guidelines. For SOAP-based applications, the link between the customer and the Web service is specifically defined by the WSDL file. Web services built with SOAP Toolkit can be called with the web service built by .NET, and vice versa. This allows the WSDL definition of the service constant to port the SOAP Toolkit application to .NET batch. For example, customers accessing Web services can still use the SOAPCLIENT client in SOAP Toolkit while converting web services to .NET. The easiest way to keep the web service constant WSDL file is the structure of the web service from the WSDL file created by SOAP Toolkit. If you pass the following parameters to this application, the .NET WSDL.EXE utility generates a Visual Basic .NET structure for the web service: / L parameter. Control the language of generating code. The default is C #. Pass / l: VB parameters generate Visual Basic code. / Server parameter.
Indicates server-side code for generating web services (original text is residual). By default, the client agent is generated. WSDL file name. To create a code for the sample web service from a Cust.WSDL file, use: WSDL.EXE / L: VB / Server Cust.WSDL generated structural code will be saved in a Cust.vb file. You can copy the code from this file and copy the Visual Basic 6.0 code to the same program in the ASMX module. If you want to create a complete .NET version of Web service, the WSDL file generated by SOAP Toolkit can be used to generate a structural code for the web service. Different client applications accessing Web services can be converted from SOAP Toolkit to .NET from SOAP Toolkit. Even a single client conversion to .NET can also be done in stages, because SOAP guidelines provide interactive operationality. In the client, the application SOAP Toolkit is converted to the Visual Studio .NET, you must replace the reference to SOAPCLIENT with reference to the web service agent. Summary This article has learned how to access Web services from Visual Basic 6.0 and Visual Basic .NET, and discuss how to convert existing SOAP applications to the .NET platform. The main points that you need to remember are: WSDL files are used to describe the SOAP document sent to the web service. In Visual Basic 6.0, you can create this file using WSDL Generator in SOAP Toolkit. In Visual Studio .NET, this file will be created automatically. When you create a Web service in Visual Basic 6.0, you need a Microsoft WSML file and a stand-alone ASP receiver web page. When you create a web service in Visual Studio .NET, both files do not need. Customers and services can be freely mixed regardless of the platform. Use SOAPCLIT to call Visual Basic .NET services from the Visual Basic 6.0 client or ASP page. Visual Basic 6.0 Web services can also use SOAPSERVER to process requests from Visual Studio .NET customers. The WSDL.exe utility is used to create a structure from the WSDL file used by the SOAP application for the .NET version. About the author Peter Vogel (MBA, MCSD) is the main person in charge of the PH & V information service company. Ph & V specializes in designing and developing a system based on COM / COM . Peter has been designed to build and install a system based on enterprise internal networks and components for Bayer AG, Exxon, Christie Digital, and Canadian Imperial Bank of Commerce. He is also the editor of the SMART ACCESS AND XML Developer newsletter, with the book of the Visual Basic Object and Component Handbook (Prentice Hall), is currently writing books. Peter is still taught in Learning Tree International. His article is committed to publishing on the major magazines developed by Visual Basic and deposited in the Microsoft Developer NetWork® (MSDN) library. Peter also often attended in North America, Australia and Europe. About Informant Communication Group Informant Communications Corporation (www.informant.com) is a diversified media company in the field of information technology. It was founded in 1990 and focused on software development publications, seminars, catalog issuance and websites. There is a business in the United States and the United Kingdom, and ICG becomes a popular media company, and sells catalog integrators to meet the growing demand for high quality technical information.