⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 soapclient.cpp

📁 vc6.0作为开发工具
💻 CPP
字号:
#include <stdio.h>

#import "msxml3.dll" 
using namespace MSXML2;

#import "C:\Program Files\Common Files\MSSoap\Binaries\MSSOAP1.dll" \
         exclude("IStream", "ISequentialStream", "_LARGE_INTEGER", \
               "_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
using namespace MSSOAPLib;

void CallService()
{

	
   
   ISoapSerializerPtr Serializer;
   ISoapReaderPtr Reader;
   ISoapConnectorPtr Connector;

   // Connect to the service
   Connector.CreateInstance(__uuidof(HttpConnector));
   Connector->Property["EndPointURL"] = "http://www.allesta.net:51110/webservices/soapx4/isuseronline.php";
   Connector->Connect();

   // Begin message
   Connector->Property["SoapAction"] = "uri:allesta-YahooUserPing";
   Connector->BeginMessage();

   // Create the SoapSerializer
   Serializer.CreateInstance(__uuidof(SoapSerializer));

   // Connect the serializer to the input stream of the connector
   Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));

   // Build the SOAP Message
   Serializer->startEnvelope("","","");
   Serializer->startBody("");
   Serializer->startElement("isuseronline","uri:allesta-YahooUserPing","","m");
   Serializer->startElement("username","","","");
   Serializer->writeString("laghari78");
   Serializer->endElement();
   Serializer->endElement();
   Serializer->endBody();
   Serializer->endEnvelope();
   
   // Send the message to the web service
   Connector->EndMessage();      

   // Let us read the response
   Reader.CreateInstance(__uuidof(SoapReader));

   // Connect the reader to the output stream of the connector
   Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), "");

   // Display the result
   printf("Answer: %s\n", (const char *)Reader->RPCResult->text);

}

void main()
{
   CoInitialize(NULL);
   CallService();
   CoUninitialize();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -