Perspective and Adjust your business and business system (III: SOAP, Webservice, Client)

zhaozj2021-02-17  74

Perspective and Adjust your business and business system (III: SOAP, Webservice, Client)

Small gas god 2001-10-13

The client's test is mainly used to test the two VB programs. It can be in a variety of forms of VC, ASP or Script, etc. in the actual application, as long as the COM interface can be, but truly issues your client. You need to attach the MS SOAP Toolkit distribution library and CTM components. Perhaps it is this reason. After finishing this test, I think about the use of ASP.NET's WebService, so that the client can be more light.

If you are familiar with VB and COM, the test of VB is very simple. The trouble is the configuration of IIS, as well as whether WSDL and WSML are correct, often this is the most time. It is recommended that you produce a few times of WSDL and WSML files. From the simplest start, don't debug AdoDB.Recordset, wait for basic and simple debugging, then debug the adoDb.recordset type. One of the benefits of WebService is more secure than before.

First VB version, and test in this unit:

Private subducersion_click ()

DIM RETSTR AS STRING

Dim SoapClient as mssoaplib.soapclient

SET SOAPCLIENT = New MSSOAPLIB.SOAPClient

Call SoapClient.msoapinit (strwsdlurl, "," ", strwsmlurl)

Retstr = soapclient.version ()

MSGBOX RETSTR

Set soapclient = Nothing

End Sub

Private subcmdsoap_click ()

ON Error Goto Errhandle

Dim Result As Adodb.Recordset

Dim strheaders as string

Dim SoapClient as mssoaplib.soapclient

SET SOAPCLIENT = New MSSOAPLIB.SOAPClient

Strheaders = "au_id / name / name / phone / address / city / state / zip / contract"

Call SoapClient.msoapinit (WSDLURL, "," ", WSMLURL)

SET RESULT = soapclient.getauthors ()

Lvwheadname Lstauthors, Strheaders

AdOfilllvw Result, Lstauthors

Msgbox "A total of" & Result.Recordcount & "record"

Errexit:

Set soapclient = Nothing

EXIT SUB

Errhandle:

Msgbox SOAPCLIENT.DETAIL

Resume errexit

End Sub

The results are shown below:

Then start to another machine Dereksvr to generate a DOTNET's winform to test it. The principle is consistent, and the DOTNET mode seems to be more troublesome (Haha), but the interoperability of the entire DOTNET can be said to be first-class, the only thing is worried about the performance issues of the program execution. First there are some work to do:

1. Install the distribution library for Microsoft SOAP Toolkit 2.0 SP on Dereksvr (because MSSOAPLIB libraries to apply) 2. Install and register CTM, Regsvr32 AdorSttypeMapper.dll

3. Check the last sentence of the WSDL file If it is localhost, change it into your machine name or IP.

If it is:

changed to:

This is mainly if other machines call this WebService, then set to localhost's locations locally on the call machine, then it will be wrong.

Create a WinForm's Project in VS.NET, then select so that vs.net automatically generates a packaged proxy class, and Version can be called below:

Using system.reflection;

Private void btnversion_click (Object Sender, System.Eventargs E)

{

// String RetStr;

String strwsdlurl;

String strwsmlurl;

MSsoaplib.soapClient SOAPCLIENT;

SOAPCLIENT = New MSSOAPLIB.SOAPCLIENT ();

Strwsdlurl = WSDLURL;

Strwsmlurl = WSMLURL;

IF (txtwsdl.text! = "" && txtwsml.text! = "")

{

Strwsdlurl = txtwsdl.text;

Strwsmlurl = txtwsml.text;

}

SOAPCLIENT.MSSOAPINIT (STRWSDLURL, "," "", strwsmlurl;

TYPE TYPE = soapclient.gettype ();

Object retobject = type.invokemember ("Version", BindingFlags.InvokeMethod, Null, SOAPCLIENT, NULL)

Messagebox.show (RetObject.toString ());

}

Previous needs to add USING SYSTEM.REFLECTION;

For GetAuthors a little troubles, because the acquired adodb.recordset needs to be converted, I will display it again in a Grid control. The specific code is as follows: private void btngetauthors_click (Object Sender, System.EventArgs E)

{

// GetAuthors

String strwsdlurl;

String strwsmlurl;

MSsoaplib.soapClient SOAPCLIENT;

SOAPCLIENT = New MSSOAPLIB.SOAPCLIENT ();

Strwsdlurl = WSDLURL;

Strwsmlurl = WSMLURL;

IF (txtwsdl.text! = "" && txtwsml.text! = "")

{

Strwsdlurl = txtwsdl.text;

Strwsmlurl = txtwsml.text;

}

AdoDb.recordset RST = new adodb.recordset ();

SOAPCLIENT.MSSOAPINIT (STRWSDLURL, "," "", strwsmlurl;

TYPE TYPE = soapclient.gettype ();

Object retobject = type.invokemember ("getauthors", bindingflags.invokeMethod, Null, SOAPCLIENT, NULL);

OLEDBDataAdapter myadapter;

Myadapter = new oledbdataadapter ();

DataSet TmpDataSet = new dataset ();

Myadapter.fill (TmpDataSet, RetObject, "Authors");

DataGrd1.datasource = TmpDataSet;

}

This needs to be added to the reference library of AdoDB 2.7 and the following statement:

Using system.data.oledb;

If you are multiple parameters, you can use this way

Object [] PARS = New Object [2];

PARS [0] = 3;

PARS [1] = "mypars";

Object ret = type.invokemember ("OtherMethod",

BindingFlags.InvokeMethod,

NULL,

SOAPCLIENT,

PARS);

The final result is as follows:

The process of the entire DOTNET, almost the same, although the results are out, I am still very unsatisfactory, because all the ways to reference the SOAP library reference can only show that the interoperability of DOTNET is better, the client Still very heavy. Unable to imagine such DOTNET client programs to get real applications, installation, and performance are still unknown. However, it is certain that the DOTNET is very interoperability. From the technology and kernel, DOTNET and the previous MS product and technology can be said to be a new road. Many design is Ning wasting and the previous maintenance Compatible, but it is actually enhanced on the position of component services. Some people say that there is DOTNET, COM is dead. I think that DOTNET will use another eye and another way to see the previous com.dotnet. "I like COM very much, but I am different from COM."

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

New Post(0)