VC2010 调用 Webservice

开发环境:VC2010,gsoap_2.8.23


http://blog.csdn.net/zhaiwenjuan/article/details/6590941


使用soapcpp2的时候要加参数-i


3个文件去掉预编译头


在调用的地方包含这两个头文件:

#include "MobileServiceImplServiceSoapBinding.nsmap"

#include "soapMobileServiceImplServiceSoapBindingProxy.h"


8月28日在做登录模块,调用服务器webservice的时候汉字总是返回乱码,8月29日终于调好了。

在调用的构造函数中:

setlocale ( LC_ALL , "chs" );  //设置语言环境 包含

以及代理类增加了一个参数: SOAP_C_MBSTRING

代码如下:



                 CString formatStr ;

                 formatStr . Format ( _T ( "%s%s" ),

                                 this -> m_strUserName . Trim (), this -> m_strPassword . Trim ());

                 TRACE ( formatStr + _T ( "\r\n" ));

                 MobileServiceImplServiceSoapBindingProxy proxy ( SOAP_C_MBSTRING ); //SOAP_C_UTFSTRING、SOAP_C_MBSTRING

 

                 ns1__srvObjectOut srvObjectOut ;

                 srvObjectOut . ns1__queryXmlDoc = formatStr . GetBuffer ();

                 srvObjectOut . ns1__jkxlh = "01A6D48EA5316A3DB5B5BB9EE0D89590" ;

                 srvObjectOut . ns1__jkid = "AW001" ;

                 const char endpoint [] = "http://localhost:8080/VIMSystem/Services/MobileService" ;

 

                 ns1__srvObjectOutResponse srvObjectOutResponse ;

                 int rtn = proxy . srvObjectOut ( endpoint , NULL , & srvObjectOut , srvObjectOutResponse );

                 CString rtnStr ;

                 rtnStr . Format ( _T ( "返回值:%d\r\n返回内容:%s\r\n" ), rtn , srvObjectOutResponse . return_ );

                 TRACE ( rtnStr );


菊子曰 本文用 菊子曰发布

转载于:https://www.cnblogs.com/sdsunjing/p/vc2010-%e8%b0%83%e7%94%a8-webservice.html

你可能感兴趣的:(VC2010 调用 Webservice)