原文地址::https://www.cnblogs.com/joeblackzqq/p/1961818.html
相关文章
1、使用Visual C++开发SOAP客户端应用----https://www.cnblogs.com/dengpeng1004/p/3502440.html
2、VC++使用Soap ToolKit3.0调用WebService接口----https://blog.csdn.net/shixin_0125/article/details/42493535?locationNum=13&fps=1
3、VC++6.0访问webservice----https://blog.csdn.net/aasmfox/article/details/51939256
4、使用C++开发webservice客户端(上)----https://blog.csdn.net/iteye_5681/article/details/81795416
5、使用C++开发webservice客户端(下)----https://blog.csdn.net/iteye_5681/article/details/81795418
vc6控制台程序利用SoapToolkit3.0调用WebService
1. 首先要安装SoapToolkit3.0安装包并安装(我的安装目录为:D:\Program Files\MSSOAP\)
2. 新建vc控制台程序(空项目),项目名称:WinConsole6InvokeWebService,添加一个c++源文件(main.cpp),将SOAP安装目录下的lib文件D:\Program Files\MSSOAP\Lib\mssoap30.lib复制到项目文件夹下。
3。添加源代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
这样,程序就完成了,运行起来就可以得到WebService的服务了。
其中的WebService服务是用ASP.NET2005(C#)开发的,源码如下:
|
调用的Hello方法,其调用方式如下:
SOAP 1.1
以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。
POST /WebService1/Service.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/Hello"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Hello xmlns="http://tempuri.org/">
<username>string</username>
</Hello>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HelloResponse xmlns="http://tempuri.org/">
<HelloResult>string</HelloResult>
</HelloResponse>
</soap:Body>
</soap:Envelope>
SOAP 1.2
以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。
POST /WebService1/Service.asmx HTTP/1.1
Host: localhost
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<Hello xmlns="http://tempuri.org/">
<username>string</username>
</Hello>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<HelloResponse xmlns="http://tempuri.org/">
<HelloResult>string</HelloResult>
</HelloResponse>
</soap12:Body>
</soap12:Envelope>
HTTP POST
以下是 HTTP POST 请求和响应示例。所显示的占位符需替换为实际值。
POST /WebService1/Service.asmx/Hello HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: length
username=string
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">string</string>