linux gsoap服务端,gsoap linux下服务器端代码生成与测试

2023-11-14

二、解压压缩包。ios

三、进入cd gSoap/gsoap-2.8/gsoap/bin/linux386函数

四、建立一个头文件serverTest.h测试

//gsoap ns service name: calc

//gsoap ns service style: rpc

//gsoap ns service encoding: encoded

//gsoap ns service namespace: http://127.0.0.1:8089/calc.wsdl

//gsoap ns service location: http://127.0.0.1:8089/cal

//gsoap ns schema  namespace:    urn:calc

int ns__hello(char *p, char *result);

int ns__add(double a, double b, double *result);

int ns__sub(double a, double b, double *result);

int ns__mul(double a, double b, double *result);

int ns__div(double a, double b, double *result);

int ns__pow(double a, double b, double *result);spa

五、./soapcpp2 -i serverTest.h.net

生成须要的文件code

六、中calc.wsdl、soapC.cpp、soapStub.h、soapcalcService.h、stdsoap2.h、 calc.nsmap、serverTest.h、soapH.h  、  soapcalcService.cpp、 stdsoap2.cpp 是须要的文件。server

七、建立main.cpp文件xml

#include "iostream"

#include "soapcalcService.h"

#include "stdafx.h"

#include "calc.nsmap"blog

#include

using namespace std;

//º??ª

int  http_get(struct   soap   *soap)

{

FILE*fd = NULL;

fd = fopen("./calc.wsdl", "rb"); //open WSDL file to copy

if (!fd)

{

return 404; //return HTTP not found error

}

soap->http_content = "text/xml";  //HTTP header with text /xml content

soap_response(soap, SOAP_FILE);

for (;;)

{

size_t r = fread(soap->tmpbuf, 1, sizeof(soap->tmpbuf), fd);

if (!r)

{

break;

}

if (soap_send_raw(soap, soap->tmpbuf, r))

{

break; //cannot send, but little we can do about that

}

}

fclose(fd);

soap_end_send(soap);

return SOAP_OK;

}

int main(int argc, char *argv[])

{

calcService cal;

cal.fget = http_get;

while (1)

{

if (cal.run(8089))

{

cal.soap_stream_fault(std::cerr);

}

}

return 0;

}

八、编写makefile

OBJ_NS := calc

GSOAP_ROOT := /home/likaiqiang/test/gSoap/gsoap-2.8/gsoap/bin/linux386/server/testCore

INCLUDE := -I$(GSOAP_ROOT)

#GCC := g++

CXX := arm-linux-gnueabihf-g++

CFLAGS += -w

CXXFLAGS += -w

OBJ_SERVER := stdafx.o soapC.o stdsoap2.o soap$(OBJ_NS)Service.o

server: $(OBJ_SERVER)

$(CXX) $(CXXFLAGS) $(INCLUDE) $^ -o $@

clean:

rm -f server client *.o

九、编译运行,出错提示没有实现头文件里面的五个函数的实现

soapcalcService.o:(.rodata._ZTV11calcService[_ZTV11calcService]+0xc0): undefined reference to `calcService::hello(char*, char*)'

soapcalcService.o:(.rodata._ZTV11calcService[_ZTV11calcService]+0xc8): undefined reference to `calcService::add(double, double, double*)'

soapcalcService.o:(.rodata._ZTV11calcService[_ZTV11calcService]+0xd0): undefined reference to `calcService::sub(double, double, double*)'

soapcalcService.o:(.rodata._ZTV11calcService[_ZTV11calcService]+0xd8): undefined reference to `calcService::mul(double, double, double*)'

soapcalcService.o:(.rodata._ZTV11calcService[_ZTV11calcService]+0xe0): undefined reference to `calcService::div(double, double, double*)'

soapcalcService.o:(.rodata._ZTV11calcService[_ZTV11calcService]+0xe8): undefined reference to `calcService::pow(double, double, double*)'

collect2: error: ld returned 1 exit status

make: *** [server] Error 1

十、在soapcalcService.cpp文件中实现相关函数

int calcService::hello(char *p, char *result)

{

if (NULL == p || NULL == result)

{

printf("Error:The third argument should not be NULL!\n");

return SOAP_ERR;

}

else

{

printf("recv :%s\n",p);

memcpy(result,"hello world",16);

return SOAP_OK;

}

return SOAP_OK;

}

int calcService::add(double num1, double num2, double* result)

{

if (NULL == result)

{

printf("Error:The third argument should not be NULL!\n");

return SOAP_ERR;

}

else

{

(*result) = num1 + num2;

return SOAP_OK;

}

return SOAP_OK;

}

/*减法的具体实现*/

int calcService::sub(double num1, double num2, double* result)

{

if (NULL == result)

{

printf("Error:The third argument should not be NULL!\n");

return SOAP_ERR;

}

else

{

(*result) = num1 - num2;

return SOAP_OK;

}

return SOAP_OK;

}

/*乘法的具体实现*/

int calcService::mul(double num1, double num2, double* result)

{

if (NULL == result)

{

printf("Error:The third argument should not be NULL!\n");

return SOAP_ERR;

}

else

{

(*result) = num1 * num2;

return SOAP_OK;

}

return SOAP_OK;

}

/*除法的具体实现*/

int calcService::div(double num1, double num2, double* result)

{

if (NULL == result || 0 == num2)

{

return soap_senderfault("Square root of negative value", "I can only compute the square root of a non-negative value");

return SOAP_ERR;

}

else

{

(*result) = num1 / num2;

return SOAP_OK;

}

return SOAP_OK;

}

int calcService::pow(double num1, double num2, double* result)

{

if (NULL == result || 0 == num2)

{

printf("Error:The second argument is 0 or The third argument is NULL!\n");

return SOAP_ERR;

}

else

{

(*result) = num1 / num2;

return SOAP_OK;

}

return SOAP_OK;

}

十一、运行./server

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

linux gsoap服务端,gsoap linux下服务器端代码生成与测试 的相关文章

  • 函数模板与普通函数的区别

    函数模板与普通函数的区别 1 普通函数调用时可以发生自动类型转换 隐式转换 2 函数模板调用时 如果利用自动类型推导 不会发生隐式类型转换 3 如果利用显示指定类型的方式 可以发生隐式类型转换 代码示例 include
  • Java物联网方向_物联网专业课程安排——未来主要方向之一

    课程1 物联网产业与技术导论 使用电子工业出版社 物联网 技术 应用 标准 安全与商业模式 等等教材 在学完高等数学 物理 化学 通信原理 数字电路 计算机原理 程序设计原理等课程后开设本课程 全面了解物联网之RFID M2M 传感网 两化
  • 关于加法溢出问题

    开个题目 关于加法溢出问题 以后想到什么情况就在这里更新吧 1 freeRTOS 的时钟节拍函数 要实现一个定时任务A 当前时钟节拍计数器xTickCount 需要延时的时钟节拍 delayTick 延时的时钟节拍时间点tickTime 由
  • 05智慧杆塔

    一张图读懂一个产业之智慧杆塔 智慧杆塔是综合承载多种设备和传感器并具备智慧能力的杆 塔等设施的总称 包括但不限于通信杆 塔 路灯杆和监控杆 智慧杆塔具备的功能由其挂载的设备和传感器决定 这些设备和传感器可通过各种通信技术接入网络和平台 并在
  • R语言实用教程薛毅清华出版社课后题答案

    有R语言实用教程薛毅课后题答案习题1 5 详情请到我的页面资源查看
  • NVMe Cli 使用教程 -- NVMe Read / Write 使用实践

    1 NVMe Write Write命令的官方说明 nvme write
  • C Primer Plus 第五章 编程练习

    第五章 编程练习 5 1 题 目 编写一个程序 把用分钟的时间转换用小时和分钟表示的时间 使用 define或者const创建一个表示60的符号常量或const变量 通过while循环让用户重复输入值 直到用户输入小于或者等于0 的值才停止
  • 网络安全工程师

    岗位职责 1 分析网络现状 对网络系统进行安全评估和安全加固 设计安全的网络解决方案 2 在出现网络攻击或安全事件时 提高服务 帮助用户恢复系统及调查取证 3 针对客户网络架构 建议合理 的网络安全解决方案 4 负责协调解决方案的客户化实施
  • CISSP-安全和风险管理

    俗话说什么是网络安全 那网络安全的基本原则有哪些呢 主要是有可用性 保密性 完整性 1 那什么是可用性 可用性的话 那就是在我们的数据和资源需要随时保持能够授权用户进行访问 用户想要访问想要用的时候 你就应该能用 而不是不能用 2 那什么是
  • Vijava 学习笔记之 DataStore(基础配置信息)

    vijava 代码 实体类 package com vmware pojo import java util ArrayList import java util Calendar 存储信息 author zhb public class
  • R语言实战笔记 基本统计分析-相关

    相关 相关系数可以用来描述定量变量之间的关系 将使用R基础安装中的state x77数据集 提供了美国50个州在1977年的人口 收入 文盲率 预期寿命 谋杀率和高中毕业率数据等 数据如下 相关的类型 Pearson Spearman和Ke
  • Markdown语法详解

    Markdown语法 标题 一级标题 一级标题 二级标题 二级标题 三级标题 三级标题 四级标题 四级标题 五级标题 五级标题 段落 前后空行超过一行 即为一个段落 标题 副标题 正文 表格 ID 用户名 昵称 1 root ROOT 2
  • Node 调试利器,前端、Node 开发必备 - VSCode JS Debug Terminal

    经常看到有同学抱怨 Node 调试麻烦或者是搞不清怎么调试各种脚本 Jest Webpack 等等 而偶尔看到的调试相关的文章又全都是在写 inspect launch json 这些方案 其实有一定学习成本 而其实在 VSCode 中早已
  • [OCCT] Open CASCADE Technology的编译(包含示例的编译)

    QQ交流群 604668232 OCCT知识库 yuque com softdev occt 持续更新 相关文档 官方文档 构建 调试和升级 官方文档 OCCT的构建 文章目录 源代码目录 编译源代码 方法一 使用官方提供的VS工程 方法二
  • 【AAAI-2019】论文整理(清单)

    AAAI 19 Accepted Papers Main Technical Track 整理自 AAAI官网 分类整理持续更新 详细文章可从arXiz org下载 CircConv A Structured Convolution wit
  • VSCode远程配置流程(详细图解)

    基本情况 基本需求 本地 Win10 系统下安装 VSCode 连接远程的服务器 Ubuntu 进行代码编写和调试 下载地址 vscode 图文安装流程 Remote SSH 远程插件 按照下图安装即可 安装完成后 弹出如下图中红色框内的控
  • VoTT使用教程

    VoTT是微软发布的用于图像目标检测的标注工具 它是基于javascript开发的 因此可以跨Windows Linux和Mac平台运行 并且支持从图片和视频读取标注 此外 其还提供了基于CNTK训练的faster rcnn模型进行自动标注
  • 如何查看本机 MySQL(DB)安装位置

    首先按住 win R 键 输入 services msc 找到正在运行的 MySQL 打开属性 之后就可以找到 文件路径了
  • 【八股】2023秋招八股复习笔记2(C++基础 & 操作系统)

    文章目录 1 内存深拷贝 代码 2 C 基础知识 虚函数了解吗 说一下static 关键字的作用 说一下C 和C 的区别 c 中四种强制 cast 转换 请说一下C C 中指针和引用的区别 请你说一下你理解的c 中的smart pointe

随机推荐