axis2c_helloworld

java的版本请看我的http://haoningabc.iteye.com/blog/975976

参考http://axis.apache.org/axis2/c/core/docs/axis2c_manual.html#quick_start

1.下载axis2c-src-1.6.0.tar.gz

2.添加.bashrc
mkdir /root/Desktop/axis

export AXIS2C_HOME=/root/Desktop/axis
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${AXIS2C_HOME}/lib/


3.编译
$tar zxvf axis2c-src-1.6.0.tar.gz
$cd axis2c-src-1.6.0
$./configure --enable-auththila=yes --enable-libxml2=yes --prefix=${AXIS2C_HOME}
$make
$make install

在$AXIS2C_HOME下生成 axis2c一堆东西

4.To build the samples:
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${AXIS2C_HOME}/lib/ 
$ cd samples
$ ./configure --prefix=${AXIS2C_HOME} --with-axis2=${AXIS2C_HOME}/include/axis2-1.6.0
$ make
$ make install

在$AXIS2C_HOME下生成sample目录

5.测试例子:
启动服务:$AXIS2C_HOME/bin/axis2_http_server
客户端测试:$AXIS2C_HOME/samples/bin/echo
root@test-linux:~/Desktop/axis/samples/bin# ./echo
Using endpoint : http://localhost:9090/axis2/services/echo

Sending OM : <ns1:echoString xmlns:ns1="http://ws.apache.org/axis2/services/echo"><text>Hello World!</text></ns1:echoString>

Received OM : <ns1:echoString xmlns:ns1="http://ws.apache.org/axis2/c/samples"><text>Hello World!</text></ns1:echoString>

echo client invoke SUCCESSFUL!

Sending OM : <ns1:echoString xmlns:ns1="http://ws.apache.org/axis2/services/echo"><text>Hello World!</text></ns1:echoString>

Received OM : <ns1:echoString xmlns:ns1="http://ws.apache.org/axis2/c/samples"><text>Hello World!</text></ns1:echoString>

echo client invoke SUCCESSFUL!
root@test-linux:~/Desktop/axis/samples/bin#


6.做个官方的例子:
服务端:hello_svc.c:
#include <axis2_svc_skeleton.h>
#include <axutil_log_default.h>
#include <axutil_error_default.h>
#include <axutil_array_list.h>
#include <axiom_text.h>
#include <axiom_node.h>
#include <axiom_element.h>
#include <stdio.h>
axiom_node_t *axis2_hello_greet(const axutil_env_t *env,axiom_node_t *node);
int AXIS2_CALL hello_free(axis2_svc_skeleton_t *svc_skeleton,const axutil_env_t *env);
axiom_node_t* AXIS2_CALL hello_invoke(axis2_svc_skeleton_t *svc_skeleton,const axutil_env_t *env,axiom_node_t *node,axis2_msg_ctx_t *msg_ctx);

int AXIS2_CALL hello_init(axis2_svc_skeleton_t *svc_skeleton,const axutil_env_t *env);
axiom_node_t* AXIS2_CALL hello_on_fault(axis2_svc_skeleton_t *svc_skeli,const axutil_env_t *env, axiom_node_t *node);

axiom_node_t *build_greeting_response(const axutil_env_t *env,axis2_char_t *greeting);
axiom_node_t *axis2_hello_greet(const axutil_env_t *env, axiom_node_t *node){
axiom_node_t *client_greeting_node = NULL;
axiom_node_t *return_node = NULL;
AXIS2_ENV_CHECK(env, NULL);
if (node){
client_greeting_node = axiom_node_get_first_child(node, env);
if (client_greeting_node &&axiom_node_get_node_type(client_greeting_node, env) == AXIOM_TEXT){
axiom_text_t *greeting = (axiom_text_t *)axiom_node_get_data_element(client_greeting_node, env);
if (greeting && axiom_text_get_value(greeting , env)){
const axis2_char_t *greeting_str = axiom_text_get_value(greeting, env);
printf("Client greeted saying \"%s\" \n", greeting_str);
return_node = build_greeting_response(env, "Hello Client!");
}
}
}
else{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, AXIS2_FAILURE);
printf("ERROR: invalid XML in request\n");
return_node = build_greeting_response(env, "Client! Who are you?");
}
return return_node;
}
axiom_node_t *build_greeting_response(const axutil_env_t *env, axis2_char_t *greeting){
axiom_node_t* greeting_om_node = NULL;
axiom_element_t * greeting_om_ele = NULL;
greeting_om_ele = axiom_element_create(env, NULL, "greetResponse", NULL, &greeting_om_node);
axiom_element_set_text(greeting_om_ele, env, greeting, greeting_om_node);
return greeting_om_node;
}
static const axis2_svc_skeleton_ops_t hello_svc_skeleton_ops_var = {
hello_init,
hello_invoke,
hello_on_fault,
hello_free
};
axis2_svc_skeleton_t *axis2_hello_create(const axutil_env_t *env){
axis2_svc_skeleton_t *svc_skeleton = NULL;
svc_skeleton = AXIS2_MALLOC(env->allocator,sizeof(axis2_svc_skeleton_t));
svc_skeleton->ops = &hello_svc_skeleton_ops_var;
svc_skeleton->func_array = NULL;
return svc_skeleton;
}
int AXIS2_CALL hello_init(axis2_svc_skeleton_t *svc_skeleton,const axutil_env_t *env){
svc_skeleton->func_array = axutil_array_list_create(env, 0);
axutil_array_list_add(svc_skeleton->func_array, env, "helloString");
return AXIS2_SUCCESS;
}
axiom_node_t* AXIS2_CALL hello_invoke(axis2_svc_skeleton_t *svc_skeleton,const axutil_env_t *env,axiom_node_t *node,axis2_msg_ctx_t *msg_ctx){
return axis2_hello_greet(env, node);
}
axiom_node_t* AXIS2_CALL hello_on_fault(axis2_svc_skeleton_t *svc_skeli,const axutil_env_t *env, axiom_node_t *node){
axiom_node_t *error_node = NULL;
axiom_node_t* text_node = NULL;
axiom_element_t *error_ele = NULL;
error_ele = axiom_element_create(env, node, "EchoServiceError", NULL,&error_node);
axiom_element_set_text(error_ele, env, "Echo service failed ",text_node);
return error_node;
}
int AXIS2_CALL hello_free(axis2_svc_skeleton_t *svc_skeleton,const axutil_env_t *env){
if (svc_skeleton->func_array){
axutil_array_list_free(svc_skeleton->func_array, env);
svc_skeleton->func_array = NULL;
}
if (svc_skeleton){
AXIS2_FREE(env->allocator, svc_skeleton);
svc_skeleton = NULL;
}
return AXIS2_SUCCESS;
}

AXIS2_EXPORT intaxis2_get_instance(axis2_svc_skeleton_t **inst,const axutil_env_t *env){
*inst = axis2_hello_create(env);
if (!(*inst)){
return AXIS2_FAILURE;
}
return AXIS2_SUCCESS;
}
AXIS2_EXPORT intaxis2_remove_instance(axis2_svc_skeleton_t *inst,const axutil_env_t *env){
axis2_status_t status = AXIS2_FAILURE;
if (inst){
status = AXIS2_SVC_SKELETON_FREE(inst, env);
}
return status;
}

用这个编译成so
gcc -shared -olibhello.so -I$AXIS2C_HOME/include/axis2-1.6.0/ -L$AXIS2C_HOME/lib -laxutil -laxis2_axiom -laxis2_parser -laxis2_engine -lpthread -laxis2_http_sender -laxis2_http_receiver hello_svc.c

wsdl----services.xml:
<service name="hello">
<parameter name="ServiceClass" locked="xsd:false">hello</parameter>
<description>
Quick start guide hello service sample.
</description>
<operation name="greet"/>
</service>

把service.xml和hello_svc.c生成的libhello.so放到$AXIS2_HOME/service/hello/
启动axis2_http_server
使用http://192.168.1.118:9090/axis2/services查看webservice
具体wsdl用http://192.168.1.118:9090/axis2/services/echo?wsdl等

客户端:
hello.c:
#include <stdio.h>
#include <axiom.h>
#include <axis2_util.h>
#include <axiom_soap.h>
#include <axis2_client.h>
axiom_node_t *
build_om_request(const axutil_env_t *env);
const axis2_char_t *
process_om_response(const axutil_env_t *env,
axiom_node_t *node);
int main(int argc, char** argv)
{
const axutil_env_t *env = NULL;
const axis2_char_t *address = NULL;
axis2_endpoint_ref_t* endpoint_ref = NULL;
axis2_options_t *options = NULL;
const axis2_char_t *client_home = NULL;
axis2_svc_client_t* svc_client = NULL;
axiom_node_t *payload = NULL;
axiom_node_t *ret_node = NULL;
env = axutil_env_create_all("hello_client.log", AXIS2_LOG_LEVEL_TRACE);
options = axis2_options_create(env);
address = "http://localhost:9090/axis2/services/hello";
if (argc > 1)
address = argv[1];
if (axutil_strcmp(address, "-h") == 0)
{
printf("Usage : %s [endpoint_url]\n", argv[0]);
printf("use -h for help\n");
return 0;
}
printf("Using endpoint : %s\n", address);
endpoint_ref = axis2_endpoint_ref_create(env, address);
axis2_options_set_to(options, env, endpoint_ref);
client_home = AXIS2_GETENV("AXIS2C_HOME");
if (!client_home && !strcmp(client_home, ""))
client_home = "../..";
svc_client = axis2_svc_client_create(env, client_home);
if (!svc_client)
{
printf("Error creating service client\n");
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Stub invoke FAILED: Error code:"
" %d :: %s", env->error->error_number,
AXIS2_ERROR_GET_MESSAGE(env->error));
return -1;
}
axis2_svc_client_set_options(svc_client, env, options);
payload = build_om_request(env);
ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
if (ret_node)
{
const axis2_char_t *greeting = process_om_response(env, ret_node);
if (greeting)
printf("\nReceived greeting: \"%s\" from service\n", greeting);
axiom_node_free_tree(ret_node, env);
ret_node = NULL;
}
else
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Stub invoke FAILED: Error code:"
" %d :: %s", env->error->error_number,
AXIS2_ERROR_GET_MESSAGE(env->error));
printf("hello client invoke FAILED!\n");
}
if (svc_client)
{
axis2_svc_client_free(svc_client, env);
svc_client = NULL;
}
if (env)
{
axutil_env_free((axutil_env_t *) env);
env = NULL;
}
return 0;
}
axiom_node_t *
build_om_request(const axutil_env_t *env)
{
axiom_node_t* greet_om_node = NULL;
axiom_element_t * greet_om_ele = NULL;
greet_om_ele = axiom_element_create(env, NULL, "greet", NULL, &greet_om_node);
axiom_element_set_text(greet_om_ele, env, "Hello Server!", greet_om_node);
return greet_om_node;
}
const axis2_char_t *
process_om_response(const axutil_env_t *env,
axiom_node_t *node)
{
axiom_node_t *service_greeting_node = NULL;
axiom_node_t *return_node = NULL;
if (node)
{
service_greeting_node = axiom_node_get_first_child(node, env);
if (service_greeting_node &&
axiom_node_get_node_type(service_greeting_node, env) == AXIOM_TEXT)
{
axiom_text_t *greeting = (axiom_text_t *)axiom_node_get_data_element(service_greeting_node, env);
if (greeting && axiom_text_get_value(greeting , env))
{
return axiom_text_get_value(greeting, env);
}
}
}
return NULL;
}

用这个编译
gcc -o hello -I$AXIS2C_HOME/include/axis2-1.6.0/ -L$AXIS2C_HOME/lib -laxutil -laxis2_axiom -laxis2_parser -laxis2_engine -lpthread -laxis2_http_sender -laxis2_http_receiver hello.c -ldl -Wl,--rpath -Wl,$AXIS2C_HOME/lib

执行.hello
root@test-linux:~/Desktop/axis2c/mytest# ./hello 
Using endpoint : http://localhost:9090/axis2/services/hello

Received greeting: "Hello Client!" from service
root@test-linux:~/Desktop/axis2c/mytest#
axis2c-bin-1.6.0 axis2c-src-1.6.0 axis2c-bin-1.6.0-linux.tar.gz axis2c-bin-1.6.0-win32.zip axis2c-src-1.6.0.tar.gz axis2c-src-1.6.0.zip 加md5 立即下载

相关推荐

axis2c linux下c客户端编程详解

此文档详细描述了,如何安装axis2c引擎,如何根据wsdl生成客户端,以及客户端的应用开发,并有详细客户端实例。

Axis2/C 基础入门

Axis2/C是一个用C语言实现的Web Service引擎。 Axis2/C基于Axis2架构 ,支持SOAP1.1 和SOAP1.2 协议,并且支持RESTful 风格的Web Service。基于Axis2/C的Web Service可以同时暴露为SOAP和RESTful风格的服务。 最近研究了一下Axis2/C,这篇文章详述了如何利用Axis2/C发布一个Web Ser...

yesjavame 774

axis2/c linux 安装步骤

axis2/c linux 安装步骤

Axis2/C入门教程之一(环境部署与服务端搭建)

Apache Axis2 / C是以C编程语言实现的Web服务引擎。 它基于可扩展和灵活的Axis2架构。 Apache Axis2 / C可用于提供和使用Web服务。 它的实现具有可移植性和嵌入能力,因此可以在其他软件中用作Web服务启用器。Apache Axis2 / C支持SOAP 1.1和SOAP 1.2以及REST风格的WebService。 单个服务可以同时作为SOAP风格和REST风...

1807垃圾信息处理中心 1452

Trae AI开发工具:大前端环境配置与避坑指南

大前端开发的第一步往往不是选框架,而是搭建一套可靠的工具链。IDE作为编码、调试与AI能力协同的载体,直接决定后续开发的顺畅度。传统编辑器需要手动拼装插件生态,而新一代AI开发工具将对话、代码生成与项目脚手架能力内置到编辑器底层,降低了环境准备的门槛。Trae基于VS Code内核,兼容其插件体系,同时提供Chat、Builder、内联对话三种AI交互模式,适合从VS Code迁移的开发者,也适合大前端新人快速上手。安装时需认准官方渠道,注意Node.js、Git版本联动,配置自动格式化与手动更新策略,并结

weixin_26833139的博客 281

ANSYS Twin Builder实战:5步搞定数字孪生模型部署(附ROM配置技巧)

本文详细解析了ANSYS Twin Builder在数字孪生模型部署中的实战应用,重点介绍了ROM(降阶模型)配置技巧。通过5个关键步骤,从环境搭建到工业部署,帮助工程师高效实现高精度三维仿真到轻量化数字孪生的转化,提升预测性维护和系统仿真效率。

weixin_27330481的博客 659

axis2 默认端口_基于 AXIS2/C 的 C 语言库实现对提供 REST API 的系统进行数据访问...

基于 AXIS2/C 的 C 语言库实现对提供 REST API 的系统进行数据访问宋 东平 和 赵 健2013 年 3 月 07 日发布AXIS2/C 简介和 REST 及 REST API 相关内容的简介AXIS2/C 简介Axis2/c 是基于 C 语言实现的 Web Service 引擎,基于 Axis2 架构,用于提供 Web 服务,并具有良好的可移植性,可以作为其他软件的一部分提供 W...

weixin_42299396的博客 402

eNSP-Pro配置又丢了?手把手教你用导出功能防患于未然

本文详细介绍了eNSP-Pro配置防丢失的全套方案,包括运行时内存、虚拟存储设备和宿主机文件系统的配置存储机制,以及多维度备份策略和特殊场景下的恢复技巧。通过优化保存流程、自动化定时导出和版本化管理,帮助网络工程师有效防止配置丢失,提升工作效率。

weixin_42665725的博客 241

Axis2 Web Service(一)

一、Axis2简介 1.1 介绍Axis2 Axis框架来自 Apache 开放源代码组织,它是基于Java语言的最新的 SOAP 规范(SOAP 1.2)和 SOAP withAttachments 规范(来自 Apache Group )的开放源代码实现。有很多流行的开发工具都使用AXIS作为其实现支持Web服务的功能,例如JBuilder以及著名的Eclipse J2EE插件Lom

lc1010078424的博客 533

玩转Isaac Sim动态控制:从随机舞动到精准操控Franka的5种控制模式实测

本文深入实测了在NVIDIA Isaac Sim仿真平台中,利用Dynamic Control模块对Franka机械臂进行精准操控的五种核心模式:位置控制、单关节位置控制、速度控制、单关节速度控制和力矩控制。通过详细的代码示例和对比分析,阐述了每种模式的适用场景、参数调优技巧及从随机运动到闭环控制的实现路径,为机器人算法验证提供了实用指南。

night的博客 808

COMSOL实战:薄膜声学超材料模态分析全流程解析(含预应力设置技巧)

本文详细解析了使用COMSOL进行薄膜声学超材料模态分析的全流程,包括预应力设置技巧和共振频率优化方法。通过实际案例和参数设置指南,帮助工程师掌握从几何建模到结果解读的关键步骤,特别适合声学超材料和共振薄膜结构的设计与优化。

ujm5678901的博客 292

通向架构师的道路(第十天)之Axis2 Web Service(一)

通向架构师的道路(第十天)之Axis2 Web Service(一)

江南@风少的博客 381

三维重建(十三)——多视角重建

本文综述了多视角三维重建技术,涵盖静态和动态场景的重建方法。介绍了从图像获取到纹理映射的SFM流程,以及非刚性重建(NRSFM)的挑战和解决方案。重点探讨了基于可微渲染的重建方法,以及数据采集策略、相机标定和同步技术。文章还讨论了如何用单视角相机模拟多视角重建,总结了关键技术和未来研究方向。

河海大学研究生在读的学习笔记 1058

基于Tomcat5.0和Axis2开发Web Service应用实例

基于Tomcat5.0和Axis2开发Web Service应用实例 2007-04-13 21:59:03 标签:Tomcat web Service Axis2   [推送到博客圈] 版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否

xqf_1999的专栏 788

如何正确的计算两个角度的角度差?

这一步是必要的,因为它确保了无论a相对于b是在逆时针方向还是顺时针方向,d2总是正确地反映出绕圆相反方向的角度差。这样,当函数进行最后的比较时,它能够准确地比较两个方向的旋转路径并选择最短的一个。

小秋 AI SLAM 入门实战教程 4137

uni-app:实现APP设置手机闹钟+取消闹钟+响铃重复/文字等,帮用户设置好闹钟并备注文本,uni-app设置安卓系统闹钟和苹果ios系统闹钟(uniapp调用手机上的闹钟,详细示例代码demo)

uniapp设置安卓和iOS闹钟的插件,uni-app设置安卓系统闹钟,uniapp设置苹果ios系统闹钟,uniapp设置定时闹铃的完整解决方案,UniApp设置手机闹钟,uniApp如何设置手机闹铃,uniapp设置闹钟,设置闹钟提醒,uni-app设置安卓系统闹钟_通过uniapp设置原声闹钟,调用android系统闹钟,如何在App中启动系统闹钟,uniapp如何取消闹钟,通过调用ios的原生接口来设置手机闹钟,uni-app 调用手机闹钟功能,uniap调用ios系统闹钟,uniapp调用手机上的

✅ 精选推荐文章 4233

axis2开发并调用webservice

本文将介绍如何使用Tomcat5.0和Apache Axis2开发、部署及测试一个简单的Web Service应用。1.工作环境 Eclipse 3.1.2+Lomboz+jdk1.5+ apache-tomcat-5.0.18+AXIS2:1.0(war版本和bin版本) 在[url]http://ws.apache.org/axis2/download/1_0/downlo...

phantomes的专栏 189

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

jsdk1.5 + tomcat + eclipse java ee+ axis2 创建web Service 版 Hello world

首先需要下载相应的安装包。 jsdk1.5 :自己网上搜搜有的是。 tomcat:http://tomcat.apache.org/download-60.cgi 下载tomcat 6.0 zip文件。 eclipse :下载http://www.eclipse.org/d

zmywhhit的专栏 2411

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

上一篇: ubuntu备份笔记
下一篇: libvrit
linux内核控
博客等级 码龄19年 41粉丝 638原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值