Instance Learning MS SOAP Toolkit 3.0 with Web Service

xiaoxiao2021-03-06  39

Instance Learning MS SOAP Toolkit 3.0 with Web Service

HerosWord original

I. MS SOAP TOOLKIT 3.0 Download and Install

You can download it on Microsoft's website. Installation Select the default installation.

II. Set the IIS virtual directory

In MS SOAP Toolkit 3.0, the ISAPI handler is a SOAPIS30.DLL file.

After installing the SOAP Toolkit 3.0, there is a file soapvdir.cmd to help us set up a virtual directory.

And SOAPIS30.DLL is associated with the request of the .wsdl file in this directory, or manually sets the IIS directory, configures the directory properties, join the SOAPIS30.DLL to process the handler for the .wsdl request.

Use the SOAPVDIR.CMD script tool:

Command format:

SOAPVDIR [Command vDirName [Directory Path]] [-s: server] [-w: root]

The specific command can be viewed with soapvdir.cmd help.

Hand-building. WSDL and SOAPIS30.DLL mapping

Open IIS, select a site or virtual directory, right click to select Properties: Select the application settings in the primary or virtual directory, as shown in the figure:

Click Add to add an application mapping for the WSDL file.

Input box input:

C: /Progra ~ 1/common ~ 1/mssoap/binaries/soapis30.dll

Enter: .wsdl in the extension input box: .wsdl

Select: get, post, head

(As shown)

Click to confirm: (as shown)

The above steps are actually configured with an ISAPI Listener for Server, and you can also configure a Listener, ASP Listener.

three. Develop and deploy a Web Service

First create an ATL project to implement a Simple Object interface

After the compilation is successful, use the WSDL Generator tool for SOAPToolkit 3.0 to generate WebService WSDL and WSML, and the generated file saves to the virtual directory of the IIS just set.

3. Develop SOAP client programs with SOAPCLIENT 30 Object

SOAPCLIENT OBJECT is implemented in MSSOAP30.DLL, we need to introduce mssoap30.dll type libraries

#import "c: /winnt/system32/msxml4.dll"

USING NAMESPACE MSXML2;

#import "C: / Program files / compon files / mssoap / binaries / mssoap30.dll" /

Exclude ("iStream", "IrrorInfo", "ISEQUENTIALSTREAM", "_large_integer", / /

"_Ularge_integer", "tagstatstg", "_filetime")

Using Namespace MSSOAPLIB30;

// TestClient.cpp: Defines the entry point for the console application.

//

#include "stdafx.h"

Void Add ()

{

Isoapserializerptr serializer;

IsoapReaderptr Reader;

IsoapConnectorptr Connector;

// Connect to the service.

Connector.createInstance (__ uuidof (httpconnector30)); connection -> proty ["endpointURL"] = "http://172.16.245.62:8090/myws/mytestservice.wsdl";

CONNECTOR-> Connect ();

// begin the message.

// Connector-> Property ["soapaction"] = "URI: AddNumBers";

Connector-> Property ["soapaction"] = "http://org.kylin.test/mytestservice/Adition/math.add";

CONNECTOR-> BeginMessage ();

// Create The Soapserializer Object.

Serializer.createInstance (__ uuidof (soapserializer30);

// Connect The Serializer Object To The Input Stream of The Connector Object.

Serializer-> Init (_variant_t ((iunknown *) connector-> inputstream);

// build the soap message.

Serializer-> Startenvelope (",", "" ");

Serializer-> StartBody ("");

Serializer-> StartElement ("add", "http: //org.kylin.test/mytestService/message/", "," ");

Serializer-> StartElement ("LOP1", ",", "");

Serializer-> WriteString ("2");

Serializer-> endelement ();

Serializer-> StartElement ("LOP2", ",", "");

Serializer-> WriteString ("13");

Serializer-> endelement ();

Serializer-> endelement ();

Serializer-> endbody ();

Serializer-> EndENVelope ();

// dend the message to the xml web service.

CONNECTOR-> endMessage ();

// read the response.

Reader.createInstance (__ uuidof (SoapReader30));

// Connect The Reader to The Output Stream of The Connector Object.

Reader-> Load (_VARIANT_T ((iunknown *) connector-> outputstream), "" "

// Display the result.

Printf ("ANSWER:% S / N", (const char *) reader-> rpcResult-> text);

}

INT Main (int Argc, char * argv []) {

Coinitialize (NULL);

Add ();

Couninitialize ();

Return 0;

}

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

New Post(0)