- 浏览: 35786 次
- 性别:
- 来自: 杭州
文章分类
最新评论
1 http://gsoap2.sourceforge.net/ 下载gsoap_2.7.15.tar.gz
2 tar -zxvf gsoap_2.7.15.tar.gz
3 ./configure(默认安装在/usr/local/share/gsoap目录下,也可以使用 ./configure –-prefix=/usr/local/gsoap指定安装路径)
4 make
5 su输入密码转到root用户
6 make install
7 创建工程目录,mkdir calculator
8 进入工程目录cd calculator
9 cp /home/jimmy/development/webservice/gsoap-2.7/gsoap/stdsoap2.c .
cp /home/jimmy/development/webservice/gsoap-2.7/gsoap/stdsoap2.h .
10 mkdir include
11 cp /home/jimmy/development/webservice/gsoap-2.7/gsoap/libgsoap.a ./include
12 /usr/local/bin/wsdl2h -c -o calculator.h http://192.168.0.125:8888/IntelligenceAppliance/CalculatorPort?wsdl
** The gSOAP WSDL/Schema processor for C and C++, wsdl2h release 1.2.15
** Copyright (C) 2000-2009 Robert van Engelen, Genivia Inc.
** All Rights Reserved. This product is provided "as is", without any warranty.
** The wsdl2h tool is released under one of the following two licenses:
** GPL or the commercial license by Genivia Inc. Use option -l for more info.
Saving calculator.h
Cannot open file 'typemap.dat'
Problem reading type map file 'typemap.dat'.
Using internal type definitions for C instead.
Connecting to 'http://192.168.0.125:8888/IntelligenceAppliance/CalculatorPort?wsdl' to retrieve WSDL/XSD... connected, receiving...
Connecting to 'http://192.168.0.125:8888/IntelligenceAppliance/CalculatorPort?xsd=1' to retrieve schema... connected, receiving... done reading 'http://192.168.0.125:8888/IntelligenceAppliance/CalculatorPort?xsd=1'
done reading 'http://192.168.0.125:8888/IntelligenceAppliance/CalculatorPort?wsdl'
To complete the process, compile with:
soapcpp2 calculator.h
[jimmy@srp calculator]$
13 /usr/local/bin/soapcpp2 -c -C calculator.h
** The gSOAP code generator for C and C++, soapcpp2 release 2.7.15
** Copyright (C) 2000-2009, Robert van Engelen, Genivia Inc.
** All Rights Reserved. This product is provided "as is", without any warranty.
** The soapcpp2 tool is released under one of the following three licenses:
** GPL, the gSOAP public license, or the commercial license by Genivia Inc.
Saving soapStub.h annotated copy of the input definitions
Saving soapH.h serializers
Saving soapC.c serializers
Saving soapClient.c client calling stubs
Saving soapClientLib.c client stubs with static serializers for libs
Using ns1 service name: CalculatorPortBinding
Using ns1 service style: document
Using ns1 service encoding: literal
Using ns1 service location: http://192.168.0.125:8888/IntelligenceAppliance/CalculatorPort
Using ns1 schema namespace: http://webservice.nk.cn/
Saving CalculatorPortBinding.substract.req.xml sample SOAP/XML request
Saving CalculatorPortBinding.substract.res.xml sample SOAP/XML response
Saving CalculatorPortBinding.add.req.xml sample SOAP/XML request
Saving CalculatorPortBinding.add.res.xml sample SOAP/XML response
Saving CalculatorPortBinding.divide.req.xml sample SOAP/XML request
Saving CalculatorPortBinding.divide.res.xml sample SOAP/XML response
Saving CalculatorPortBinding.multiply.req.xml sample SOAP/XML request
Saving CalculatorPortBinding.multiply.res.xml sample SOAP/XML response
Saving CalculatorPortBinding.nsmap namespace mapping table
Compilation successful
[jimmy@srp calculator]$
14 创建calculator.c,内容如下:
1 #include <stdio.h>
2 #include "soapH.h"
3 #include "CalculatorPortBinding.nsmap"
4
5 int main(int argc, char *argv[])
6 {
7 struct soap *soap = soap_new();
8 struct ns1__add add;
9 struct ns1__substract sub;
10 struct ns1__multiply mul;
11 struct ns1__divide div;
12 struct ns1__addResponse add_ret;
13 struct ns1__substractResponse sub_ret;
14 struct ns1__multiplyResponse mul_ret;
15 struct ns1__divideResponse div_ret;
16
17 int result;
18
19 add.arg0 = 1;
20 add.arg1 = 2;
21
22 sub.arg0 = 1;
23 sub.arg1 = 2;
24
25 mul.arg0 = 1;
26 mul.arg1 = 2;
27
28 div.arg0 = 8;
29 div.arg1 = 2;
30
31
32 if(soap_call___ns1__add(soap, NULL, NULL, &add, &add_ret) == SOAP_OK)
33 printf("The sum of 1 and 2 is %d\n", add_ret.return_);
34 else
35 soap_print_fault(soap, stderr);
36
37 if(soap_call___ns1__substract(soap, NULL, NULL, &sub, &sub_ret) == SOAP_OK)
38 printf("The substract of 1 and 2 is %d\n", sub_ret.return_);
39 else
40 soap_print_fault(soap, stderr);
41
42 if(soap_call___ns1__multiply(soap, NULL, NULL, &mul, &mul_ret) == SOAP_OK)
43 printf("The multiply of 1 and 2 is %d\n", mul_ret.return_);
44 else
45 soap_print_fault(soap, stderr);
46
47 if(soap_call___ns1__divide(soap, NULL, NULL, &div, &div_ret) == SOAP_OK)
48 printf("The divide of 8 and 2 is %d\n", div_ret.return_);
49 else
50 soap_print_fault(soap, stderr);
51
52 soap_end(soap);
53 soap_free(soap);
54 }
15 创建Makefile
#INCLUDE=$(GSOAP_ROOT)
INCLUDE=./include
OBJS=soapC.o stdsoap2.o soapClient.o calculator.o
calculator: $(OBJS)
gcc -I $(INCLUDE) -o calculator $(OBJS)
.PHONY: clean
clean:
rm *.o calculator
16 make
cc -c -o soapC.o soapC.c
cc -c -o stdsoap2.o stdsoap2.c
cc -c -o soapClient.o soapClient.c
cc -c -o calculator.o calculator.c
gcc -I ./include -o calculator soapC.o stdsoap2.o soapClient.o calculator.o
17 ./calculator
The sum of 1 and 2 is 3
The substract of 1 and 2 is -1
The multiply of 1 and 2 is 2
The divide of 8 and 2 is 4
18 目录结构
calculator
calculator.c
calculator.h
CalculatorPortBinding.add.req.xml
CalculatorPortBinding.add.res.xml
CalculatorPortBinding.divide.req.xml
CalculatorPortBinding.divide.res.xml
CalculatorPortBinding.multiply.req.xml
CalculatorPortBinding.multiply.res.xml
CalculatorPortBinding.nsmap
CalculatorPortBinding.substract.req.xml
CalculatorPortBinding.substract.res.xml
include
libgsoap.a
Makefile
soapC.c
soapClient.c
soapClientLib.c
soapH.h
soapStub.h
stdsoap2.c
stdsoap2.h
19 总结
把所有的xml文件删除依然可以正确编译运行
soapStub.h中包含所有的在calculator.c中使用的结构体和函数声明
soapcpp2常用选项
* -C 仅生成客户端代码
* -S 仅生成服务器端代码
* -L 不要产生soapClientLib.c和soapServerLib.c文件
* -c 产生纯C代码,否则是C++代码(与头文件有关)
* -I 指定import路径(见上文)
* -x 不要产生XML示例文件
* -i 生成C++包装,客户端为xxxxProxy.h(.cpp),服务器端为xxxxService.h(.cpp)。
/usr/local/bin/soapcpp2 -c calculator.h则产生服务器端和客户端的代码
20、安装注意:
在README.txt文件中:
To build without OpenSSL support, use:
$ ./configure --disable-openssl
$ make
$ make install
我在ubuntu下安装采用此方法
发表评论
-
精简jre
2013-07-29 15:20 11120. 思路: 1)把自己的应用程序打包成可运行的 ... -
java map的重复键值的排序
2013-05-22 20:05 56361. 概述 在java map中,一般有重复的k ... -
3. Java基础和细节-继承
2013-04-16 17:35 01. 多态 可以引用多种实际类型的现象称为 ... -
2. Java基础和细节-对象与类
2013-04-16 10:28 7181. 类之间的关系 1)依赖(uses- ... -
1. Java基础和细节-Java的基本程序设计和结构
2013-04-15 16:17 12251. 注释 1)单 ... -
0. Java基础和细节-血和泪啊
2013-04-15 16:07 7072013.4.15通知晋升结果——晋升失败 ... -
servlet fileupload上传文件
2012-05-18 17:09 1966版权信息: 可以任意转载, 转载时请务必以超链接形式标明 ... -
Java中变化无常的常量
2011-08-19 16:39 979Java中变化无常的常量 ... -
LiveValidation验证
2011-08-17 20:36 8981、http://livevalidation.com/dow ... -
Java 命令行参数
2011-08-17 20:04 743public class CmdLineArgsTest { ...
相关推荐
代码在Linux5.6 64下编译通过,代码中调用http://www.cs.fsu.edu/~engelen/calc.wsdl提供的WebService接口。文件中相应的文件由gSOAP工具生成,详细操作说明请看我的博客。
Linux下用gSOAP开发Web Service服务端和客户端程序
在Linux 平台下 使用gsoap以 webservice 的方式实现通信, 此例为结构体实例,实现结构体的参数返回。
本文档主要介绍C++如何使用gSoap调用java的webservice接口. 是一篇自己工作中使用写下的使用说明。 非常详细步骤,带有简单示例的详细说明文档。
c++利用gsoap访问webservice,结合文章使用
Qt下gsoap访问webService方法程序。
用gsoap实现面向Java客户端的WebService.pdf
qt程序通过gsoap访问webservice示例程序代码!
C++做客户端,通过gSoap调用java发布的webservice,所调用的java方法返回的是自定义实体类,如果返回int,String等基本数据类型,这很容易实现;但这里函数返回的是List,Course,List甚至是Object,应该很有价值! ...
利用gsoap实现web service的服务端和客户端,参考网址:http://blog.csdn.net/JoeBlackzqq/article/details/7942066
linux下使用gsoap和mysql的api实现的webservice服务端,webservice访问mysql数据库的功能
windows下的gsoap生成c++代码的webservice客户端 linux下的gsoap生成c++代码的webservice客户端 基于多个服务端生成同一个c++客户端的方法
C++通过gSoap访问webService,vs2010的完整项目,打开运行查看效果,另外有一个说明的文档,发现csdn不能传多个文件,到我的下载列表里面找找吧。
1. 内附 CSharp webservice例子,及GSOAP client和server例子 2. 里面的例子. 注意根据自己情况修改批处理里面的wsdl地址. 3. 如果webservice是php的 请注意修改php版wsdl中类型为标准类型(默认好像php生成的wsdl文件...
在Linux下QT通过gSOAP调试天气预报的WebService接口的方法实例,
gsoap,a tool can use http to comnicate with webserver
gSOAP中文文档 gSOAP中文文档,WebService基于C++的应用开发。 gSOAP中文文档,WebService基于C++的应用开发。
对应前面发的C++ gsoap webserver的client端,windows系统环境下两台机器测试通过没有问题
一、用C#实现WebService是相当简单的事情,我们只要创建一个Web服务程序,在方法名上面加上[WebMethod],部署到IIS上,就能像访问Web站点一样访问WebService。 用C#编写客户端时,只需要将WebService添加到引用,就...