设为首页 加入收藏

TOP

Axis2/C基础入门(二)
2014-11-23 22:25:21 来源: 作者: 【 】 浏览:5
Tags:Axis2/C 基础 入门
n = NULL;
68 svc_skeleton = (axis2_svc_skeleton_t *) AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t));
69 svc_skeleton->ops = &hello_svc_skeleton_ops_var;
70 svc_skeleton->func_array = NULL;
71 return svc_skeleton;
72 }
73
74 int AXIS2_CALL hello_init(axis2_svc_skeleton_t *svc_skeleton, const axutil_env_t *env)
75 {
76 svc_skeleton->func_array = axutil_array_list_create(env, 0);
77 axutil_array_list_add(svc_skeleton->func_array, env, "helloString");
78 return AXIS2_SUCCESS;
79 }
80
81
82
83 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)
84 {
85 return axis2_hello_greet(env, node);
86 }
87
88 axiom_node_t* AXIS2_CALL hello_on_fault(axis2_svc_skeleton_t *svc_skeli, const axutil_env_t *env, axiom_node_t *node)
89 {
90 axiom_node_t *error_node = NULL;
91 axiom_node_t* text_node = NULL;
92 axiom_element_t *error_ele = NULL;
93 error_ele = axiom_element_create(env, node, "EchoServiceError", NULL,
94 &error_node);
95 axiom_element_set_text(error_ele, env, "Echo service failed ",
96 text_node);
97 return error_node;
98 }
99
100
101
102 int AXIS2_CALL hello_free(axis2_svc_skeleton_t *svc_skeleton,
103 const axutil_env_t *env)
104 {
105 if (svc_skeleton->func_array)
106 {
107 axutil_array_list_free(svc_skeleton->func_array, env);
108 svc_skeleton->func_array = NULL;
109 }
110
111 if (svc_skeleton)
112 {
113 AXIS2_FREE(env->allocator, svc_skeleton);
114 svc_skeleton = NULL;
115 }
116 return AXIS2_SUCCESS;
117 }
118
119 AXIS2_EXPORT int axis2_get_instance(axis2_svc_skeleton_t **inst, const axutil_env_t *env)
120 {
121 *inst = axis2_hello_create(env);
122 if (!(*inst))
123 {
124 return AXIS2_FAILURE;
125 }
126 return AXIS2_SUCCESS;
127 }
128
129
130
131 AXIS2_EXPORT int axis2_remove_instance(axis2_svc_skeleton_t *inst, const axutil_env_t *env)
132 {
133 axis2_status_t status = AXIS2_FAILURE;
134 if (inst)
135 {
136 status = AXIS2_SVC_SKELETON_FREE(inst, env);
137 }
138 return status;
139 }
140
6、编译上述代码,在命令行运行如下编译命令:
$ C:VS8VCincl.exe /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "AXIS2_DECLARE_EXPORT" /D "AXIS2_SVR_MULTI_THREADED" /w /nologo /I %AXIS2_HOME%include /I C:\VS8\VC\include /c hello_svc.c
7、链接生成的中间对象,并产生DLL,运行命令如下:
$ C:VS8VCinlink.exe /nologo /LIBPATH: %AXIS2_HOME%lib /LIBPATH:C:\VS8\VC\lib axutil.lib axiom.lib axis2_parser.lib axis2_engine.lib /DLL /OUT:hello.dll *.obj
8、在 %AXIS2_HOME%services下创建目录hello,将步骤7产生的hello.dll拷贝到其中,并创建服务描述文件services.xml,并插入如下内容:
1 < xml version="1.0" encoding="utf-8" >
2
3 hello
4
5 Quick start guide hello service sample.
6

7
8 http://ws.apache.org/axis2/c/samples/hello
9

10

9、启动Axis2服务器,执行如下命令:
$ axis2_http_server
三、访问服务
10、在VS中创建项目Axis2Test,并在 Axis2Test.cpp中插入这些代码:
1 #include "stdafx.h"
2
3 #include
4 #include
5 #include
6 #include
7 #include
8
9 axiom_node_t *build_om_request(const axutil_env_t *env);
10 const axis2_char_t *process_om_response(const axutil_env_t *env, axiom_node_t *node);
11
12 int _tmain(int argc, char** argv)
13 {
14 const axutil_env_t *env = NULL;
15 const axis2_char_t *address = NULL;
16 axis2
首页 上一页 1 2 3 4 下一页 尾页 2/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇均值不等式的简单探究 下一篇查找序列中的最大数和最小数

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: