代码如下;
#include <stdio.h>
#include <iostream.h>#import "msxml4.dll"
using namespace MSXML2;
#import "C:\Program Files\Common Files\MSSoap\Binaries\MSSOAP30.dll" \
exclude("IStream", "IErrorInfo", "ISequentialStream", "_LARGE_INTEGER", \
"_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
using namespace MSSOAPLib30;void Add()
{
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
// Connect to the service.
Connector.CreateInstance(__uuidof(HttpConnector30));
Connector->Property["EndPointURL"] = "http://www.wopos.com/webservice/weather.asmx";
Connector->Connect(); // Begin the message.
//Connector->Property["SoapAction"] = "uri:AddNumbers";
Connector->Property["SoapAction"] = "http://tempuri.org/getWeather";
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("getWeather","http://tempuri.org/getWeather","","");
Serializer->StartElement("mCity","","","");
Serializer->WriteString("济南");
Serializer->EndElement();
//Serializer->StartElement("NumberTwo","","","");
//Serializer->WriteString("10");
//Serializer->EndElement();
Serializer->EndElement();
Serializer->EndBody();
Serializer->EndEnvelope();
// Send 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->xml);
}int main()
{
::CoInitialize(NULL);
Add();
CoUninitialize();
return 0;
}
#include <stdio.h>
#include <iostream.h>#import "msxml4.dll"
using namespace MSXML2;
#import "C:\Program Files\Common Files\MSSoap\Binaries\MSSOAP30.dll" \
exclude("IStream", "IErrorInfo", "ISequentialStream", "_LARGE_INTEGER", \
"_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
using namespace MSSOAPLib30;void Add()
{
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
// Connect to the service.
Connector.CreateInstance(__uuidof(HttpConnector30));
Connector->Property["EndPointURL"] = "http://www.wopos.com/webservice/weather.asmx";
Connector->Connect(); // Begin the message.
//Connector->Property["SoapAction"] = "uri:AddNumbers";
Connector->Property["SoapAction"] = "http://tempuri.org/getWeather";
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("getWeather","http://tempuri.org/getWeather","","");
Serializer->StartElement("mCity","","","");
Serializer->WriteString("济南");
Serializer->EndElement();
//Serializer->StartElement("NumberTwo","","","");
//Serializer->WriteString("10");
//Serializer->EndElement();
Serializer->EndElement();
Serializer->EndBody();
Serializer->EndEnvelope();
// Send 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->xml);
}int main()
{
::CoInitialize(NULL);
Add();
CoUninitialize();
return 0;
}
解决方案 »
- CreateWindow()只能在WM_CREATE消息处理内实现吗?
- 请问哪有installshield下载
- 想问一下 福州富士通通信软件公司的软件工程师待遇
- 不同打印机高度与宽度问题??高手能解决么?
- 多个 COM进程外服务器 ??
- 如何报考微软证书???
- 以前看到过一个自称是字符串高手...........
- 打包cab文件法时,inf文件如何编写?
- 关于vc7.0 beta的一个问题
- 如何踏出第一步?
- 关于CBitMap的问题
- 急问:0X80040154 = CoCreateInstance(__uuidof(DOMDocument40), NULL, CLSCTX_ALL, __uuidof(IXMLDOMDocument),(void)**pp);
http://www.cnblogs.com/babyblue/archive/2005/05/16/156160.html
ISoapClient *m_pSoapClient = NULL;//create soapclient object
hr = ::CoCreateInstance(__uuidof(SoapClient30), NULL, CLSCTX_INPROC_SERVER, __uuidof(ISoapClient), (LPVOID *)&m_pSoapClient);
if (m_pSoapClient == NULL)
{
IssueError(_T("Create soap client object fail"));
return hr;
}//init soap client
try
{
_variant_t varWSDL = szWSDLFile;
_variant_t varWSML = _T("");
_bstr_t bstrService = szService;
_bstr_t bstrPort = szPort;
_bstr_t bstrNS = _T(""); hr = m_pSoapClient->MSSoapInit2(varWSDL, varWSML, bstrService, bstrPort, bstrNS);
if (FAILED(hr))
{
IssueError(_T("Error calling MSSoapInit2"));
}
}
catch (...)
{
IssueError(_T("Initialize web service failed."));
hr = S_FALSE;
}