webservice hello
一、
// hello.h int ns__hello(std::string name, std::string& greeting);
二、
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | //helloclient.cpp #include "soapH.h" #include "ns.nsmap" #include <string> #include <iostream> using namespace std; int hello( struct soap *soap,std::string name,std::string& greeting) { int flag = -1; flag = soap_call_ns__hello(soap, "http://localhost:8080" , "" , name,greeting); return flag; } int main() { std::string name= "Luoxuehua" ; std::string greeting; struct soap *soap = soap_new(); int flag = -1; for ( int i = 0;i<50 ;i++) { std::string str = std::to_string(i*10); name.append(str.c_str()); flag = hello(soap,name,greeting); if (flag ==0) { printf ( "%s\n" , greeting.c_str()); std::cout << "result:" <<greeting <<std::endl; } } soap_destroy(soap); soap_end(soap); soap_free(soap); return 0; } |
三、
c++ -o helloclient helloclient.cpp soapC.cpp soapclient.cpp stdsoap2.cpp -lws2_32
四、
soapcpp2 -C hello.h soapcpp2 -S hello.h wsdl2h -o dd.h ns.wsdl
五
//helloserver.cpp #include "soapH.h" #include "ns.nsmap" #include <string> #include <iostream> int main() { struct soap *soap = soap_new(); SOAP_SOCKET m = soap_bind(soap, NULL, 8080, 1); if (soap_valid_socket(m)) { while (true) { SOAP_SOCKET s = soap_accept(soap); if (!soap_valid_socket(s)) break; soap_serve(soap); soap_destroy(soap); soap_end(soap); } } soap_print_fault(soap, stderr); soap_free(soap); } int ns__hello(struct soap *soap, std::string name, std::string& greeting) { printf("soap start name:%s\n",name.c_str()); greeting="Hello world:"; greeting.append(name.c_str()); return SOAP_OK; }
六
//编译 g++ -o helloserver helloserver.cpp soapC.cpp soapserver.cpp stdsoap2.cpp -lws2_32
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】