vc2010 +gSOAP

sunmoonfly 2010-08-30 09:58:47
在vc2010中通过gSOAP访问.net 的webserivce,编译时报错,主要是soapC.obj报错
网上查看的写开发gSoap的帖子都是用vc6.0编译的,难道gSOAP不支持高版本吗
...全文
371 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunmoonfly 2010-09-01
  • 打赏
  • 举报
回复
楼上的这个我会
yui 2010-09-01
  • 打赏
  • 举报
回复
我只在UNIX/LINUX下用过gSOAP,不过,按照gSOAP的README,它至少是支持Visual Studio 2005的,但需要bison和flex,你可以试下

Visual Studio 2005 Solution files for soapcpp2 and wsdl2h.

If not already installed, install the Platform SDK (R2) for winsock.h

To build soapcpp2, first install Bison and Flex (in the default dirs):
http://gnuwin32.sourceforge.net/packages/bison.htm
http://gnuwin32.sourceforge.net/packages/flex.htm
then add the FlexBison.rules:
http://msdn2.microsoft.com/en-us/library/aa730877(VS.80).aspx
These custom-build rules are used to build the scanner and parser for soapcpp2.

To build wsdl2h, you first need to build soapcpp2.exe and install it in
Program Files or copy it to the wsdl2h source file directory. This is needed to
execute the custom-build step on wsdl.h to generate wsdlStub.h, wsdlH.h, and
wsdlC.cpp.
chenjiawei007 2010-09-01
  • 打赏
  • 举报
回复
我用 VS2008 SOAP访问 webservice
VC编码

//这是需要导入的库 ,记得第一次编译会报错,第二次编译就OK了。这是为何尚不知道,估计依赖一些编译后的库。

#import "msxml3.dll"
using namespace MSXML2;
#import "C:\Program Files\Common Files\MSSoap\Binaries\MSSOAP1.dll"
using namespace MSSOAPLib;
using namespace std;


//用户登录
std::string _cdecl LoginUsers(std::string &_strName ,std::string &_strPwd)
{
//初始化
CoInitialize(NULL);
std::string strUrl = "http://"+P_strSvrIp+"/VODWebService/Service.asmx";
//将string类型转换为_bstr_t类型
_bstr_t _user(_strName.c_str());
_bstr_t _password(_strPwd.c_str());

ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;

//创建连接实例
Connector.CreateInstance(__uuidof(HttpConnector));

//连接WebService服务
Connector->Property["EndPointURL"]= strUrl.c_str();
Connector->Connect();

//连接WebService中接口
Connector->Property["SoapAction"] = "VODWebService/LoginUsers";
Connector->BeginMessage();

// 创建SoapSerializer对象
Serializer.CreateInstance(__uuidof(SoapSerializer));

// 与输入流连接
Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));

// 制作SOAP信息
Serializer->startEnvelope("","","utf-16");//美版的中文字库
Serializer->startBody("");
//VODWebService是webservice的命名空间
Serializer->startElement("LoginUsers","VODWebService","","");
Serializer->startElement("_strName","VODWebService","","");
Serializer->writeString(_user);
Serializer->endElement();
Serializer->startElement("_strPwd","VODWebService","","");
Serializer->writeString(_password);
Serializer->endElement();
Serializer->endElement();
Serializer->endBody();
Serializer->endEnvelope();



// 向服务器发送信息
Connector->EndMessage();

// 读取回应
Reader.CreateInstance(__uuidof(SoapReader));

// 连接输出流
Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), "");

//取出结果

return (char*)Reader->RPCResult->text;

}

这是我写的一个简单的用户登录的函数,去访问webservice中的LoginUsers()接口,
配合一些网上的资料应该很好理解。


VS2010应该和2008差不多,开头的库需要编译2编,第一遍编译时会报58个错,再编译次就OK
sunmoonfly 2010-09-01
  • 打赏
  • 举报
回复
微软的这个玩意就是部署麻烦了点需要额外的装东西
sunmoonfly 2010-09-01
  • 打赏
  • 举报
回复
试了一天没搞好,用微软的soaptoolkit做好了

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧