C++和C# WebService相互调用
2015-03-23 20:24
330 查看
C#调用C++ gSOAP:
调用http://blog.csdn.net/ggz631047367/article/details/44567411的服务http://127.0.0.1:8089/
1.右键添加web服务引用,输入http://127.0.0.1:8089/
2.调用:
ServiceReference1.calcPortTypeClient service = new ServiceReference1.calcPortTypeClient();
label1.Text = service.add(1, 2).ToString();
C++ gSOAP调用C# WebService:
1.生成头文件:wsdl2h.exe -s -t typemap.dat -o hello.h http://127.0.0.1:8083/WebService1.asmx?wsdl
使用定义模板typemap.dat,typemap.dat是GSOAP自带的复制过来增加了以下内容xsd__string = | wchar_t*
因为默认GSOAP生成的C++代码都是ANSI的,而C#默认是用UTF的,所以最好转换成wchar_t这样兼容性好些,避免中文乱码。
2.生成其他文件:soapcpp2.exe -i -I C:\Users\Hunter\Downloads\gsoap_2.8.21\gsoap-2.8\gsoap\import hello.h
3.将文件引用到项目:
4.test.cpp代码:
调用http://blog.csdn.net/ggz631047367/article/details/44567411的服务http://127.0.0.1:8089/
1.右键添加web服务引用,输入http://127.0.0.1:8089/
2.调用:
ServiceReference1.calcPortTypeClient service = new ServiceReference1.calcPortTypeClient();
label1.Text = service.add(1, 2).ToString();
C++ gSOAP调用C# WebService:
1.生成头文件:wsdl2h.exe -s -t typemap.dat -o hello.h http://127.0.0.1:8083/WebService1.asmx?wsdl
使用定义模板typemap.dat,typemap.dat是GSOAP自带的复制过来增加了以下内容xsd__string = | wchar_t*
因为默认GSOAP生成的C++代码都是ANSI的,而C#默认是用UTF的,所以最好转换成wchar_t这样兼容性好些,避免中文乱码。
2.生成其他文件:soapcpp2.exe -i -I C:\Users\Hunter\Downloads\gsoap_2.8.21\gsoap-2.8\gsoap\import hello.h
3.将文件引用到项目:
4.test.cpp代码:
#include"soapWebService1SoapProxy.h" #include"WebService1Soap.nsmap" #include<iostream> using namespace std; int main() { WebService1SoapProxy p; _ns1__HelloWorld nsh; _ns1__HelloWorldResponse nsr; p.HelloWorld(&nsh, nsr); cout << nsr.HelloWorldResult << endl; _ns1__add nsa ; _ns1__addResponse nar; nsa.a = 1; //设置形参 nsa.b = 10; p.add(&nsa, nar); cout << nar.addResult << endl; system("pause"); return 0; }
相关文章推荐
- C++、C#写的WebService相互调用
- C++、C#写的WebService相互调用
- [转载]C++、C#写的WebService相互调用
- C++、C#写的WebService相互调用
- C++、C#写的WebService相互调用
- C++和C# WebService相互调用
- [转贴]C++、C#写的WebService相互调用
- [转载]C++、C#写的WebService相互调用
- C++、C#写的WebService相互调用
- C# 与C/C++相互调用
- 关于WinRT中c++和c#相互调用的问题
- C++调用C#WebService
- C++和C#编写并且相互调用COM组件
- C# C++ dll的相互调用
- 关于WinRT中c++和c#相互调用的问题
- 关于WinRT中c++和c#相互调用的问题
- C#开发WEBService服务 C++开发客户端调用WEBService服务
- C++和C#编写的COM组件与DLL库相互调用
- (摘)C++和C#相互调用COM组件的方法简介
- C# C++ dll的相互调用