vc中如何调用webservice? VC/MFC / 进程/线程/DLL
来源:百度文库 编辑:神马文学网 时间:2024/05/13 06:28:32
用msxml+soap
#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;
string GetCompanyNameFromWeb(void)
{
try
{
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
// Connect to the service.
Connector.CreateInstance(__uuidof(HttpConnector30));
//Connector->Property["EndPointURL"] = "http://www.mainone.com/UpLoadImage.asmx";
Connector->Property["EndPointURL"] = "http://localhost/WebOfficeValidateService/Validate.asmx";
Connector->Connect();
// Begin the message.
Connector->Property["SoapAction"] = "http://tempuri.org/GetCompanyName";
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("GetCompanyName","http://tempuri.org/","","");
Serializer->StartElement("SerialNum","http://tempuri.org/","","");
Serializer->WriteString(m_strSerial.c_str());
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.
VARIANT_BOOL bl = Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), "");
// Display the result.
_bstr_t bstrResult = Reader->RpcResult->text;
return (char*)bstrResult;
}
catch(_com_error &e)
{
return NULL;
}
}
#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;
string GetCompanyNameFromWeb(void)
{
try
{
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
// Connect to the service.
Connector.CreateInstance(__uuidof(HttpConnector30));
//Connector->Property["EndPointURL"] = "http://www.mainone.com/UpLoadImage.asmx";
Connector->Property["EndPointURL"] = "http://localhost/WebOfficeValidateService/Validate.asmx";
Connector->Connect();
// Begin the message.
Connector->Property["SoapAction"] = "http://tempuri.org/GetCompanyName";
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("GetCompanyName","http://tempuri.org/","","");
Serializer->StartElement("SerialNum","http://tempuri.org/","","");
Serializer->WriteString(m_strSerial.c_str());
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.
VARIANT_BOOL bl = Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), "");
// Display the result.
_bstr_t bstrResult = Reader->RpcResult->text;
return (char*)bstrResult;
}
catch(_com_error &e)
{
return NULL;
}
}
vc中如何调用webservice? VC/MFC / 进程/线程/DLL
vc中如何调用webservice? VC/MFC / 进程/线程/DLL - CSDN社...
在VC中调用 WebService
在VC中调用 WebService
在VC中调用 WebService网易学院教程
dll中如何得到一个对话框的句柄 - VC/MFC / 基础类
VC中MFC工程为什么会自动调用AppModul.cpp
在VB应用程序中调用VC环境下开发的DLL
IT 技术联盟--VC++ MFC线程处理概述
IT 技术联盟--VC++ MFC线程处理概述
用BCB写软件的界面,调用VC的dll
用BCB写软件的界面,调用VC的dll
VC++中MFC窗口对象的清除
VC /MFC 源码下载
VC 线程同步
VC DLL导出类
如何在Java中调用dll
VC中利用多线程技术实现线程之间的通信
VC中利用多线程技术实现线程之间的通信
如何将CString转换为char[] VC/MFC / 基础类
在ADO中如何获得一个表中记录的总数? VC/MFC / 数据库 - CSDN社区 com...
在VC++中创建DLL文件并加载
在VC++中创建DLL文件并加载
VC中, 为何每次都要重新编译? VC/MFC / 基础类 - CSDN社区 commu...