首页 > 其他分享 >webservice hello

webservice hello

时间:2024-08-01 17:18:59浏览次数:7  
标签:std webservice int hello cpp include soap

一、

// hello.h
int ns__hello(std::string name, std::string& greeting);

二、

//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 

 

标签:std,webservice,int,hello,cpp,include,soap
From: https://www.cnblogs.com/luoxh-whn/p/18337055

相关文章

  • 信步漫谈之Android——HelloWorld
    目录目标1资源2第一个HelloWorld程序3项目结构说明3.1目录结构3.2结构说明4在App中添加日志后续补充参考资料目标学习搭建Android的开发环境sayhelloworld1资源官网教程:https://developer.android.com/courses开发工具AndroidStudio下载路径:https://d......
  • 信步漫谈之微信小程序——HelloWorld
    目录目标1资源2程序目录说明3第一个HelloWorld程序4真机调试参考资料(感谢)目标微信小程序开发环境sayhelloworld1资源微信官方文档:https://developers.weixin.qq.com/doc/微信开发者工具下载:https://developers.weixin.qq.com/miniprogram/dev/devtools/downloa......
  • Electron学习笔记(二)Hello World
    目录前言运行主进程创建界面使用窗口打开界面管理窗口的生命周期关闭所有窗口时退出应用(Windows&Linux)​如果没有窗口打开则打开一个窗口(macOS)使用预加载脚本访问渲染器的Node.js添加你自己的功能完整代码展示效果展示前言接上一篇文章Electron学习笔......
  • QOJ7899 Say Hello to the Future
    考虑先求出原序列的方案数设\(f_i\)表示\(1\simi\)被划分为若干区间的方案数,若一段区间合法当且仅当\(r-l+1\ge\max\{a_{l\simr}\}\),可以发现数据结构难以维护且由于不是最优性问题,考虑\(\texttt{cdq}\)分治优化对于每个分治中心\(m\),令\(mxL_i=\max\{a_{i\si......
  • 【Blog1】PyCharm写hello world
    创建项目选择项目类型和项目目录设置python编译器选择编译器新建Python文件编写代码并运行运行运行结果......
  • 最长的Hello, World!(C++)
    最长的Hello,World!(C++)#include<iostream>#include<string>#include<vector>#include<memory>#include<random>_<typenameT>classNode{public:Tdata;std::shared_ptr<Node<T>>next;Node(......
  • 最长的Hello, World!(Python)
    最长的Hello,World!(Python)(lambda_,__,___,____,_____,______,_______,________:getattr(__import__(True.__class__.__name__[_]+[].__class__.__name__[__]),().__class__.__eq__.__class__.__name__[:__]+().__iter__().__cla......
  • Hello World
    1.第一个代码helloworld1.随便建立一个文件夹,用来存放代码2.新建一个Java文件。文件后缀名是.java例如Hello.Java注意如果修改不起点击文件上方的查看,把文件扩展名勾选上。3.编写代码publicclassHello{ publicstaticvoidmain(String[]args){ System.out.print("......
  • oracle EF core hello world
    在oracle数据库里建一个表CREATETABLEstudent(numintnotnull,namevarchar2(200)notnull,PRIMARYKEY(num));通过vsstudio2022建一个"控制台应用"类型的项目.通过vsstudio上的nuget下载Oracle.EntityFrameworkCore,Microsoft.EntityFrameworkCore......
  • 虚拟机编译安装 dpdk--运行helloworld
    DPDK技术介绍一,版本信息DPDK版本:dpdk-22.07操作系统:Ubuntu22.04.1LTS二、虚拟机ubuntu添加网卡1.2.显卡由enssx改为ethxsudonano/etc/default/grub找到GRUB_CMDLINE_LINUX=""改为GRUB_CMDLINE_LINUX="net.ifnames=0biosdevname=0"然后执行如下指令sudogr......