关于gsoap返回大字符串问题

kissspring126 2016-11-30 09:32:32
最近项目用到gsoap调用webservice服务,其中一个接口返回很大字符串信息,约200M左右,每次调用该接口都会准时在5分钟后断开连接,错误信息是“Error -1 fault in message exchange [no subcode]
"Connection reset by peer"
Detail: [no detail] ” 所使用的gsoap版本为 2.8.39最新版本,
类定义为:
class _WS1__query_USCOREproductAttribute
{ public:
/// A handle to the soap struct context that manages this instance when instantiated by a context or NULL otherwise (automatically set).
struct soap *soap ;
};

class _WS1__query_USCOREproductAttributeResponse
{ public:
/// Element "out" of XSD type xs:string.
std::string* out nullptr 1; ///< Required nillable (xsi:nil when NULL) element.
/// A handle to the soap struct context that manages this instance when instantiated by a context or NULL otherwise (automatically set).
struct soap *soap ;
};


调用方法如下
_WS1__query_USCOREproductAttribute query_USCOREproductAttribute;

_WS1__query_USCOREproductAttributeResponse query_USCOREproductAttributeResponse;

t_iResult = soap_call___WS1__query_USCOREproductAttribute(&gv_ClientSOAP,t_chServiceURL,NULL,&query_USCOREproductAttribute,query_USCOREproductAttributeResponse);

每次调用都是过5分钟整出现如上错误,哪位大侠遇到过如此问题的啊,有需要加什么编译选项么,还是对soap对象进行什么设置啊?跪求!


谢谢
...全文
473 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Tw!light 2017-11-29
  • 打赏
  • 举报
回复
怎么解决的啊,主楼?
qq_19922483 2017-03-29
  • 打赏
  • 举报
回复
还是没懂怎么解决问题。。。,求帮助
kissspring126 2016-12-02
  • 打赏
  • 举报
回复
问题已经找到,webservice未提供该服务,导致5分钟后防火墙关闭连接,结贴
C++实现56dxw短信验证码WebService接口。 编译工具gsoap-2.8.zip 因为长名字关系,请到根目录解压后再拷贝进来,直接解压可能会解压报错。 用VS.NET2003 开发游戏程序的时候,有一个登录功能模块,需要短信验证码。 56短信网有两种接口,一是HTTP,二是 Web Service。 短信验证码,采用HTTP接口,在客户端发送是不实际的,因为一是受制于客户端网络稳定性,二是容易被客户端拦截URL, 三是被拦截后,容易泄漏56短信网的帐号密码,导致被盗用,产生不安全因素。 服务端采用HTTP接口,也不是很好,服务端连接众多客户端,压力很大,如何有效执行URL和如何得到返回值都是问题。 服务端毕竟不是网站,需要及时有效响应。 因此,采用 服务端 + Web Service 方案很有必要。 其实,Web Service是什么,之前我也不懂,翻阅了大量百度后,知道SOAP这个东西来实现。 非常感谢这篇文章 http://hi.baidu.com/winnyang/blog/item/1138fad9bfac1be338012fdf.html 现在把我C++写的例子实现简单介绍下,与大家共享: 1、下载工具gsoap-2.8。gsoap是个好工具,包装了SOAP到C++的实现,不需要我们再辛苦。(例子中附带这个工具) gsoap-2.8.zip 因为长名字关系,请到根目录解压后再拷贝进来,直接解压可能会解压报错。 2、我例子目录下面有个文件夹gsoap,里面 soapcpp2.exe、wsdl2h.exe 、wsmap.dat、gsoap.bat、stdsoap2.h、stdsoap2.cpp 这几个文件不要删除。 其它文件可以删除,通过执行gsoap.bat重新生成。 3、执行gsoap.bat生成文件。 gsoap.bat内容: wsdl2h.exe -o 56dxw_webservice.h -t wsmap.dat -e http://jiekou.56dxw.com/WebServiceInterface.asmx?wsdl soapcpp2 -i -C -x 56dxw_webservice.h -I ..\gsoap-2.8\gsoap\import del /s /f /q WebServiceInterfaceSoap.nsmap.cpp rename WebServiceInterfaceSoap.nsmap WebServiceInterfaceSoap.nsmap.cpp 各参数意义稍微解释(网上复制): -t 定义std:string到C++中的字符串转化规则, 当前例子采用UNIOCDE编码编译,请在wsmap.dat 中加上 xsd__string = | std::wstring | std::wstring* 这句话 -o 文件名,指定输出头文件 -n 名空间前缀 代替默认的ns -c 产生纯C代码,否则是C++代码 -s 不要使用STL代码 -t 文件名,指定type map文件,默认为typemap.dat -e 禁止为enum成员加上名空间前缀 -C 仅生成客户端代码 -S 仅生成服务器端代码 -L 不要产生soapClientLib.c和soapServerLib.c文件 -c 产生纯C代码,否则是C++代码(与头文件有关) -I 指定import路径(见上文) -x 不要产生XML示例文件 -i 生成C++包装,客户端为xxxxProxy.h(.cpp),服务器端为xxxxService.h(.cpp)。 4、创建VS.NET2003对话框例子 (1)设置项目属性 设置 不使用预编译头 和 使用 Unicode 字符集(是否使用UNICODE根据项目实际情况,只要注意字符串转换) (2)项目中添加以下文件:注意,这些文件都是通过gsoap自动生成,无须修改。 stdsoap2.cpp stdsoap2.h soapC.cpp soapH.h WebServiceInterfaceSoap.nsmap.cpp soapWebServiceInterfaceSoapProxy.cpp soapWebServiceInterfaceSoapProxy.h (3)在对话框.h文件中 添加 #include "gsoap/soapWebServiceInterfaceSoapProxy.h" using namespace std; (4)在对话框.cpp文件中 添加 void Ctest2Dlg::OnBnClickedButton1() { #ifdef _UNICODE #define tstring wstring #else #define tstring string #endif WebServiceInterfaceSoapProxy gs; _ns1__SendNote SendSms; _ns1__SendNoteResponse Resp; CString str; GetDlgItemText(IDC_EDIT3,str); tstring handtels(str); tstring content(TEXT("验证码内容")); GetDlgItemText(IDC_EDIT1,str); tstring userName(str); //请测试人员此处直接输入用户名和密码 GetDlgItemText(IDC_EDIT2,str); tstring password(str); tstring cid(TEXT("713")); tstring sendtime(TEXT("")); tstring smsnumber(TEXT("1061")); SendSms.handtels = &handtels; SendSms._USCOREcontent = &content; SendSms.userName = &userName; SendSms.password = &password; SendSms.cid = &cid; SendSms._USCOREsendtime = &sendtime; SendSms._USCOREsmsnumber = &smsnumber; if(gs.SendNote(&SendSms;, &Resp;) == SOAP_OK) { int nReturn = Resp.SendNoteResult; switch( nReturn ) { case 1:str.Format(TEXT("发送成功"));break; case -1:str.Format(TEXT("用户名密码不正确"));break; case -2:str.Format(TEXT("内容不能大于70个字"));break; case -3:str.Format(TEXT("验证此平台是否存在"));break; case -4:str.Format(TEXT("提交号码不能为空或客户余额为0"));break; case -5:str.Format(TEXT("客户剩余条数不够要发送的短信数量"));break; case -6:str.Format(TEXT("非法短信内容"));break; case -7:str.Format(TEXT("返回系统故障"));break; case -8:str.Format(TEXT("网络性错误,请稍后再试"));break; default:str.Format(TEXT("未知错误"));break; } AfxMessageBox(str); } }

18,773

社区成员

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

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