Axis2C非正式与Axis2C员工 [英] Axis2C unofficial vs. Axis2C Staff

查看:156
本文介绍了Axis2C非正式与Axis2C员工的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将开发一个应用程序,将使用一些框架为基于SOAP的Web服务。我做了一些研究,我喜欢Axis2C框架,但在这里在一些主题我发现,原来的Axis2C实现遭受内存泄漏,它的官方发展已经被扼杀。



幸运的是,存在Axis2C非官方分支和基于Axis2C的Staff框架。现在,问题是,这个Axis2C后代哪个更好或更容易使用?我知道,工作人员将Axis2C包装在C ++中,但我不介意纯C。工作人员还修复内存泄漏吗?



感谢任何建议。 p>

解决方案

我不能告诉你在Axis2 / C上的工作已经停止,它继续但非常缓慢。如果您查看中继库repo ,您只能看到5在今年提交... Trunk版本1.7.0(未发布)有许多变化和新功能,但发布日期仍然不知道。



原始Axis2 / C -1.6.0真的有内存泄漏和已知问题,它不适合生产。 Axis2 / C-unofficial是基于原始的Axis2 / C-1.6.0,并修复最关键的问题,并提供其他有用的功能。
但是非官方的分支,当然,有与原来相同的API,你将采取相同的时间来开发服务或客户端。



如果我们谈论WSF Staff,它打算用于快速开发WEB服务和客户端。与Axis2 / C相反,您只需写入几行代码即可启动服务或客户端工作。你不需要知道内部消息结构:你只使用简单(bool,int,字符串等)或复杂(struct,typedef,std containers ...)类型(当然,级别访问消息)。 Axis2 / C具有类似的名为ADB(Axis数据绑定)的功能,但它是由C-way完成的,您需要编写额外的代码行以获取请求和结果。


请注意,ADB(和生成的服务)有内存泄漏,它不是在非官方分支中修复。


要比较更容易使用的方式 - ADB或员工我想给这个例子:


注意:你需要写手动<$ p $ c> {和}之间的代码。


Axis2 / C实现Calculator服务的添加操作的方式WITHOUT来自Axis2 / C示例的ADB(传统)

  axiom_node_t * 
axis2_calc_add(
const axutil_env_t * env,
axiom_node_t * node)
{
axiom_node_t * param1_node = NULL ;
axiom_node_t * param1_text_node = NULL;
axis2_char_t * param1_str = NULL;
long int param1 = 0;
axiom_node_t * param2_node = NULL;
axiom_node_t * param2_text_node = NULL;
axis2_char_t * param2_str = NULL;
long int param2 = 0;

if(!node)
{
AXIS2_ERROR_SET(env->错误,AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL,
AXIS2_FAILURE);
printf(Calculator client request request ERROR:input parameter NULL\);
return NULL;
}

/ *迭代到第一个子元素跳过(空)文本元素* /
for(param1_node = axiom_node_get_first_child(node,env);
param1_node& ;& axiom_node_get_node_type(param1_node,env)!= AXIOM_ELEMENT;
param1_node = axiom_node_get_next_sibling(param1_node,env)

if(!param1_node)
{
AXIS2_ERROR_SET(env->错误,
AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
printf(Calculator service ERROR:invalid XML in request\\\
);
return NULL;
}
param1_text_node = axiom_node_get_first_child(param1_node,env);
if(!param1_text_node)
{
AXIS2_ERROR_SET(env->错误,
AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
printf(Calculator service ERROR:invalid XML in request\\\
);
return NULL;
}
if(axiom_node_get_node_type(param1_text_node,env)== AXIOM_TEXT)
{
axiom_text_t * text =
(axiom_text_t *)axiom_node_get_data_element(param1_text_node,env);
if(text& axiom_text_get_value(text,env))
{
param1_str =(axis2_char_t *)axiom_text_get_value
}
}
else
{
AXIS2_ERROR_SET(env->错误,
AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
printf(Calculator service ERROR:invalid XML in request\\\
);
return NULL;
}

/ *迭代到第二个子元素跳过(空)文本元素* /
for(param2_node = axiom_node_get_next_sibling(param1_node,env);
param2_node& ;& axiom_node_get_node_type(param2_node,env)!= AXIOM_ELEMENT;
param2_node = axiom_node_get_next_sibling(param2_node,env)
if(!param2_node)
{
AXIS2_ERROR_SET(env->错误,
AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
printf(Calculator service ERROR:invalid XML in request\\\
);
return NULL;
}
param2_text_node = axiom_node_get_first_child(param2_node,env);
if(!param2_text_node)
{
AXIS2_ERROR_SET(env->错误,
AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
printf(Calculator service ERROR:invalid XML in request\\\
);
return NULL;
}
if(axiom_node_get_node_type(param2_text_node,env)== AXIOM_TEXT)
{
axiom_text_t * text =
(axiom_text_t *)axiom_node_get_data_element(param2_text_node,env);
if(text& axiom_text_get_value(text,env))
{
param2_str =(axis2_char_t *)axiom_text_get_value
}
}
else
{
AXIS2_ERROR_SET(env->错误,
AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
printf(Calculator service ERROR:invalid XML in request\\\
);
return NULL;
}

if(param1_str& param2_str)
{
long int result = 0;
axis2_char_t result_str [255];

axiom_element_t * ele1 = NULL;
axiom_node_t * node1 = NULL,
* node2 = NULL;
axiom_namespace_t * ns1 = NULL;
axiom_text_t * text1 = NULL;

param1 = strtol(param1_str,NULL,10);
param2 = strtol(param2_str,NULL,10);
result = param1 + param2;
sprintf(result_str,%ld,result);

ns1 = axiom_namespace_create(env,
http:// axis2 / test / namespace1,ns1);
ele1 = axiom_element_create(env,NULL,result,ns1,& node1);
text1 = axiom_text_create(env,node1,result_str,& node2);

return node1;
}

AXIS2_ERROR_SET(env->错误,
AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST,
AXIS2_FAILURE);
printf(Calculator service ERROR:invalid parameters\\\
);
return NULL;
}

Axis2 / C实现Calculator服务的添加操作方式WITH来自Axis2 / C codegen的ADB示例:

  adb_addResponse_t * axis2_skel_Calculator_add(const axutil_env_t * env,
adb_add_t * add)
{
adb_addResponse_t * add_res = NULL;
int ret_val = 0;
int val1 = 0;
int val2 = 0;
val1 = adb_add_get_arg_0_0(add,env);
val2 = adb_add_get_arg_1_0(add,env);
ret_val = val1 + val2;
add_res = adb_addResponse_create(env);
adb_addResponse_set_addReturn(add_res,env,ret_val);
return add_res;
}

员工实施Calculator服务的添加操作的方式: strong>

  int CalculatorImpl :: add(int param_1,int param_2)
{
return param_1 + param_2;
}

关于代码生成和编译过程,



对于Axis2 / C:

 #从WSDL生成服务
WSDL2C.sh -uri Calculator.wsdl -u -ss -sd
#implement src / axis2_skel_Calculator.c
#编译和安装
cd src
#build
sh build.sh
#install
sudo mkdir $ AXIS2C_HOME / services / calculator
sudo cp lib * .so ../resources/*.xml $ AXIS2C_HOME / services / calculator

对于WSF工作人员:

 code>#从WSDL生成服务
staff_codegen -pwsdl -tcomponent_all Calculator.wsdl
#implement src / CalculatorImpl.cpp
#build and install
make&& sudo -E make install

当然,您可以使用Axis2 / C-unofficial上的WSF Staff从中获益。


I´m going to be developing an application that will be using some framework for SOAP based web services. I did some research and I kind of like Axis2C framework but here in some topics I found out that original Axis2C implementation suffered from memory leaks and that it´s official development has been stoped.

Luckily, there exists Axis2C unofficial branch and also Staff framework based on Axis2C. Now, the question is, which of this Axis2C descendants is better or easier to use? I know, that Staff wraps the Axis2C in C++, but I don´t mind plain C. Does Staff also fix the memory leaks?

Thanks for any advice.

解决方案

I can't tell you that work on Axis2/C has been stopped, it's keeping going but very-very slow. If you look into trunk repo, you can see only 5 commits in this year... Trunk version 1.7.0(unreleased) has many changes and new features, but release date is still not known.

Original Axis2/C-1.6.0 really have memory leaks and known issues, it's not suitable for production. Axis2/C-unofficial is based on original Axis2/C-1.6.0 and fixes most critical issues and gives other useful features. But unofficial branch, of course, has the same API as original, and you will take the same time to develop the service or client. It's not easier or harder in use.

If we talking about WSF Staff, it intended for fast developing of WEB services and clients. In contrast to Axis2/C you need to write only few lines of code to start your service or client working. You don't need to know about internal message structure: you working only with simple (bool, int, string, etc.) or complex (struct, typedef, std containers...) types (and of course you can have low-level access to message). Axis2/C has similar feature named ADB (Axis data binding) but it's done by C-way, and you need to write additional lines of code to get access to request and result.

Please note ADB (and generated services) has memory leaks, and it's not fixed in unofficial branch.

To compare what's easier in use - ADB or Staff I would like to give this example:

Note: you need to write the code between { and } by hand.

Axis2/C way of implementing the add operation of Calculator service WITHOUT ADB (traditional) from Axis2/C samples:

axiom_node_t *
axis2_calc_add(
    const axutil_env_t * env,
    axiom_node_t * node)
{
    axiom_node_t *param1_node = NULL;
    axiom_node_t *param1_text_node = NULL;
    axis2_char_t *param1_str = NULL;
    long int param1 = 0;
    axiom_node_t *param2_node = NULL;
    axiom_node_t *param2_text_node = NULL;
    axis2_char_t *param2_str = NULL;
    long int param2 = 0;

    if (!node)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL,
                        AXIS2_FAILURE);
        printf("Calculator client request ERROR: input parameter NULL\n");
        return NULL;
    }

    /* iterating to the first child element skipping (empty) text elements */
    for (param1_node = axiom_node_get_first_child(node, env);
         param1_node && axiom_node_get_node_type(param1_node, env) != AXIOM_ELEMENT;
         param1_node = axiom_node_get_next_sibling(param1_node, env));

    if (!param1_node)
    {
        AXIS2_ERROR_SET(env->error,
                        AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
                        AXIS2_FAILURE);
        printf("Calculator service  ERROR: invalid XML in request\n");
        return NULL;
    }
    param1_text_node = axiom_node_get_first_child(param1_node, env);
    if (!param1_text_node)
    {
        AXIS2_ERROR_SET(env->error,
                        AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
                        AXIS2_FAILURE);
        printf("Calculator service  ERROR: invalid XML in request\n");
        return NULL;
    }
    if (axiom_node_get_node_type(param1_text_node, env) == AXIOM_TEXT)
    {
        axiom_text_t *text =
            (axiom_text_t *) axiom_node_get_data_element(param1_text_node, env);
        if (text && axiom_text_get_value(text, env))
        {
            param1_str = (axis2_char_t *) axiom_text_get_value(text, env);
        }
    }
    else
    {
        AXIS2_ERROR_SET(env->error,
                        AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
                        AXIS2_FAILURE);
        printf("Calculator service ERROR: invalid XML in request\n");
        return NULL;
    }

    /* iterating to the second child element skipping (empty) text elements */
    for (param2_node = axiom_node_get_next_sibling(param1_node, env);
         param2_node && axiom_node_get_node_type(param2_node, env) != AXIOM_ELEMENT;
         param2_node = axiom_node_get_next_sibling(param2_node, env));
    if (!param2_node)
    {
        AXIS2_ERROR_SET(env->error,
                        AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
                        AXIS2_FAILURE);
        printf("Calculator service  ERROR: invalid XML in request\n");
        return NULL;
    }
    param2_text_node = axiom_node_get_first_child(param2_node, env);
    if (!param2_text_node)
    {
        AXIS2_ERROR_SET(env->error,
                        AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
                        AXIS2_FAILURE);
        printf("Calculator service  ERROR: invalid XML in request\n");
        return NULL;
    }
    if (axiom_node_get_node_type(param2_text_node, env) == AXIOM_TEXT)
    {
        axiom_text_t *text =
            (axiom_text_t *) axiom_node_get_data_element(param2_text_node, env);
        if (text && axiom_text_get_value(text, env))
        {
            param2_str = (axis2_char_t *) axiom_text_get_value(text, env);
        }
    }
    else
    {
        AXIS2_ERROR_SET(env->error,
                        AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
                        AXIS2_FAILURE);
        printf("Calculator service ERROR: invalid XML in request\n");
        return NULL;
    }

    if (param1_str && param2_str)
    {
        long int result = 0;
        axis2_char_t result_str[255];

        axiom_element_t *ele1 = NULL;
        axiom_node_t *node1 = NULL,
            *node2 = NULL;
        axiom_namespace_t *ns1 = NULL;
        axiom_text_t *text1 = NULL;

        param1 = strtol(param1_str, NULL, 10);
        param2 = strtol(param2_str, NULL, 10);
        result = param1 + param2;
        sprintf(result_str, "%ld", result);

        ns1 = axiom_namespace_create(env,
                                     "http://axis2/test/namespace1", "ns1");
        ele1 = axiom_element_create(env, NULL, "result", ns1, &node1);
        text1 = axiom_text_create(env, node1, result_str, &node2);

        return node1;
    }

    AXIS2_ERROR_SET(env->error,
                    AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST,
                    AXIS2_FAILURE);
    printf("Calculator service ERROR: invalid parameters\n");
    return NULL;
}

Axis2/C way of implementing the add operation of Calculator service WITH ADB from Axis2/C codegen samples:

    adb_addResponse_t * axis2_skel_Calculator_add(const axutil_env_t * env,
                                                    adb_add_t * add) 
{
    adb_addResponse_t * add_res = NULL;
    int ret_val = 0;
    int val1 = 0;
    int val2 = 0;
    val1 = adb_add_get_arg_0_0(add, env);
    val2 = adb_add_get_arg_1_0(add, env);
    ret_val = val1 + val2;
    add_res = adb_addResponse_create(env);
    adb_addResponse_set_addReturn(add_res, env, ret_val);
    return add_res;
}

Staff's way of implementing the add operation of Calculator service:

int CalculatorImpl::add(int param_1, int param_2)
{
  return param_1 + param_2;
}

Regarding codegenerating and compilation process it will be:

For Axis2/C:

# generate service from WSDL
WSDL2C.sh -uri Calculator.wsdl -u -ss -sd
# implement src/axis2_skel_Calculator.c
# compile and install
cd src
# build
sh build.sh
# install
sudo mkdir $AXIS2C_HOME/services/calculator
sudo cp lib*.so ../resources/*.xml $AXIS2C_HOME/services/calculator

For WSF Staff:

# generate service from WSDL
staff_codegen -pwsdl -tcomponent_all Calculator.wsdl
# implement src/CalculatorImpl.cpp
# build and install
make && sudo -E make install

Of course you can use WSF Staff on Axis2/C-unofficial to get all benefits from both.

这篇关于Axis2C非正式与Axis2C员工的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆