webservice 的参考例子 sample

一 、参考

https://blog.csdn.net/Ikaros_521/article/details/103232677

二、hello.h

h__hello(char*&);

三、

//helloclient.cpp

#include "soapH.h"
#include "h.nsmap"
int main() 
{
     char *s;
     struct soap *soap = soap_new(); 
     soap_call_h__hello(soap, "http://localhost:8080", "", s); 
     printf("%s\n", s); 
     soap_destroy(soap); 
     soap_end(soap); 
     soap_free(soap); 
     return 0;
     }

 四

//helloserver.cpp

#include "soapH.h"
#include "h.nsmap"
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 h__hello(struct soap *soap, char* &s)
{
 printf("soap start\n");    
  s = soap_strdup(soap, "Hello World!");
  return SOAP_OK;
}

c++ -o helloserver helloserver.cpp soapC.cpp soapserver.cpp stdsoap2.cpp -lws2_32

c++ -o helloclient helloclient.cpp soapC.cpp soapclient.cpp stdsoap2.cpp -lws2_32

 

posted @ 2024-08-01 17:27  atom_lxh  阅读(1)  评论(0编辑  收藏  举报