Perspective and adjust your business and business system (III: SOAP, WebService, Server)

zhaozj2021-02-17  77

Perspective and adjust your business and business system (III: SOAP, WebService, Server)

Small gas god 2001-10-12

Ok, I can finally start using Microsoft SOAP Toolkit to convert the build bus_authors above to a Webservice. I use Microsoft Soap Toolkit 2.0 SP2. Simple Version (), I jump, no more nonsense, MS Random help has this instructions. Because I am more interested in AdoDB.Recordset, but disappointment is that WSDL generated using WSDL Generator cannot support the type of adoDb.recordset

In the generated WSDL file, this XML is generated:

According to the description of the random document, in particular Handling Complex Types, we need to use a Custom Type Mapper (CTM) to process the format of AdoDB.Recordset. Let's talk about the steps you need to do.

1. Generate a custom type conversion class to process adoDb.reoCrdset type

2. Modify the WSDL file generated by the WSDL Generator.

3. Set IIS, configure the WebService of Authors

4. Generate client testing this WebService

First Generate the CTM of AdoDb.Recordset, mainly to implement the MSSoAplib.isoaptypemapper interface in the SOAP Toolkit library, I think it is a major increase in MS SOAP Toolkit 2.0, which is more components and easy to use compared to the last SOAP Toolkit version. Now you can complete this CTM now, create a VB ActiveX DLL project, copy below the code, (I generated the component called adotypemapper.adorsttypemapper) If another installed MS SOAP Toolkit 2.0 seems to have a such adoDB .Recorset example.

Option expedition

Implements mssoaplib.isoaptypemapper

Private function isoaptypemapper_read (_ _

Byval pnode as msxml2.ixmldomnode, _

Byval bstrencoding as string, _

Byval encodingmode as mssoaplib.nencodingstyle, _

BYVAL LFLAGS As Long) As Variant

Dim Recordset As New Adodb.Recordset

DIM DOMDOC AS MSXML2.DOMDOCUMENT

Set Domdoc = CreateObject ("msxml2.domdocument")

Domdoc.LoadXml (pnode.xml)

Recordset.open Domdoc

Set isoaptypemapper_read = recordset

SET DOMDOC = Nothing

END FUNCTION

Private function isoaptypemapper_vartype () as long

IsoapTyPemApper_vartype = vbobject

END FUNCTION

Private sub is isoaptypemapper_write (_

Byval psoapserializer as mssoaplib.isoapserializer, _

Byval bstrencoding as string, _

Byval encodingmode as mssoaplib.nencodingstyle, _

Byval lflags as long, _

Pvar as variant

Dim xdom as new msxml2.domdocument

Dim Recordset as adodb.recordset

Set recordset = pvar

RecordSet.save xdom, AdpersistXML

PSoapSerializer.writeXML (xDom.xml)

End Sub

You need to reference Microsoft Soap Type Library (SOAP Toolkit Installation Directory / Binaries/msoap1.dll) and a reference to Microsoft XML V3.0, then compile into a DLL (such as AdorSttypeMapper.dll).

Then start configuring the WebService of the Server.

1. Register this DLL. Regsvr32 AdorSttypeMapper.dll

2. Get this component's Progid and CLSID, you can use the OLE / COM OBJECT Viewer Tool

PROGID: adotypemapper.adorsttypemapper

CLSID: {0C839C51-81E1-4DBC-AC69-3794E337B5F3}

3. At the C: / INETPUB / WWWROOT / Authors directory (the directory in the previous article) COPY is generated by the WSDL and WSML files generated by WSDL Generator to this directory.

4. Modify Authros.WSDL and Authors.wsml content.

Premier Authros.wsml:

10/12/01

By Microsoft SOAP Toolkit WSDL File Generator, Version 1.02.813.0 ->

Cachable = '0'

ID = 'adorstmap' />

Targetnamespace = 'http://tempuri.org/type'

Uses = 'adorstmap'

IID = '{0C839C51-81E1-4DBC-AC69-3794E337B5F3}' />

Blue font is you have to add. ADoSoAPMap will be in the authors.wsdl below.

Authors.wsdl needs to modify and add:

XMLns = 'http://www.w3.org/2001/xmlschema'

XMLns: soap-enc = 'http://schemas.xmlsoap.org/soap/encoding/'

XMLns: wsdl = 'http: //schemas.xmlsoap.org/wsdl/'

ElementFormDefault = 'Qualified'>

The original:

Modify it below:

Pay attention to the red font part, I wrote Type = 'XSD: adoSoapmap', which takes a lot of time when testing. Then test http://localhost/authors/authors.wsdl in IE is normal, if the display is correct, then we started the following test. There are two on the client's test, one I tested in this machine with VB EXE, and another machine uses a DOTNET's Winform test.

At present, our system structure has not changed, and the only change is the HenrySVR machine installed IIS and MS SOAP Toolkit 2.0 and the CTM components we have just generated. This component is not installed in the COM environment. It can be used in simple registration. In fact, in practical applications, more machines can be set to IIS and WebService, and the proxy package and CTM components prepared in front of this machine are installed. This is the original application App Server or App Server. The new machine only places IIS and CTM to handle the part of the WebService. The advantage of two IIS is that the original system doesn't have to do any changes, and for another IIS, because it is based on the SOAP protocol, that is, the communication with it can penetrate the firewall. For me, there is no machine that can be used again. The specific structural map may be like this.

The CLIENT's code seems to have a lot, I will write one.

Special: The above text and pictures involve other people's privacy and personal rights, such as non-authorized or agree, please do not publish, reprint, adapted, repost, or other forms of communication, or other forms, such as non-authorized or agreed by me. All of the above texts and images are only used for internal communication, and do not make any news publishers and commercial purposes.

转载请注明原文地址:https://www.9cbs.com/read-31027.html

New Post(0)