首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用WSO2 (Axis2c)执行简单SOAP操作

无法使用WSO2 (Axis2c)执行简单SOAP操作
EN

Stack Overflow用户
提问于 2012-07-18 03:31:30
回答 1查看 379关注 0票数 0

我已经用scratchbox为ARM (诺基亚N9)交叉编译了WSO2,这很容易,甚至我都能做到。现在我有了需要部署到我的设备上的库。

然后,我已经使用ebay CPP生成了C++数据绑定,并将它们添加为源文件(仅供参考,我在这里使用了来自WSO2的FindingService.wsdl:http://developer.ebay.com/webservices/finding/latest/FindingService.wsdl)

我试图执行最简单的操作,基本上就是getVersion,但它不起作用,不知何故没有正确地序列化对象,我不确定为什么。

下面是我的main.cpp代码:

代码语言:javascript
复制
int mainGetVersionUsingWSOFCPP() {
Environment::initialize("wsof.log", AXIS2_LOG_LEVEL_DEBUG);
std::string client_home = "/opt/meebay/res/axis2c/axis2.xml";

//ServiceClient sc("http://svcs.ebay.com/services/search/FindingService/v1");

FindingServiceStub *stub = new FindingServiceStub(client_home);
Options * op = stub->getOptions();
op->setSoapVersion(AXIOM_SOAP12);

GetVersionRequest *req = new GetVersionRequest();
GetVersionRequestE8 *reqE8 = new GetVersionRequestE8(req);

GetVersionResponse *res = NULL;
GetVersionResponseE3 *resE3 = NULL;

ServiceClient *sc = stub->getServiceClient();

resE3 =  stub->getVersion(reqE8);


res = resE3->getGetVersionResponse();

}

下面是axis2c WSDL2CPP为这个特定的getVersion请求生成的代码:

代码语言:javascript
复制
com_ebay_www_marketplace_search_v1_services::GetVersionResponseE3* WSF_CALL FindingServiceStub::getVersion(com_ebay_www_marketplace_search_v1_services::GetVersionRequestE8*  _getVersionRequest)
     {
        axis2_svc_client_t *svc_client = NULL;
        axis2_options_t *options = NULL;
        axiom_node_t *ret_node = NULL;

        const axis2_char_t *soap_action = NULL;
        axutil_qname_t *op_qname =  NULL;
        axiom_node_t *payload = NULL;
        axis2_bool_t is_soap_act_set = AXIS2_TRUE;
        axutil_string_t *soap_act = NULL;

        com_ebay_www_marketplace_search_v1_services::GetVersionResponseE3* ret_val;

                            payload = _getVersionRequest->serialize(NULL, NULL, AXIS2_TRUE, NULL, NULL);

    svc_client = serviceClient->getAxis2SvcClient();





    options = clientOptions->getAxis2Options();
        if (NULL == options)
        {
            AXIS2_ERROR_SET(Environment::getEnv()->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
            AXIS2_LOG_ERROR(Environment::getEnv()->log, AXIS2_LOG_SI, "options is null in stub");
            return (com_ebay_www_marketplace_search_v1_services::GetVersionResponseE3*)NULL;
        }
        soap_act = axis2_options_get_soap_action( options, Environment::getEnv() );
        if (NULL == soap_act)
        {
          is_soap_act_set = AXIS2_FALSE;
          soap_action = "http://www.ebay.com/marketplace/search/v1/services/getVersion";
          soap_act = axutil_string_create(Environment::getEnv(), "http://www.ebay.com/marketplace/search/v1/services/getVersion");
          axis2_options_set_soap_action(options, Environment::getEnv(), soap_act);    
        }


        axis2_options_set_soap_version(options, Environment::getEnv(), AXIOM_SOAP11);

        ret_node =  axis2_svc_client_send_receive_with_op_qname( svc_client, Environment::getEnv(), op_qname, payload);

        if (!is_soap_act_set)
        {

          axis2_options_set_soap_action(options, Environment::getEnv(), NULL);    

          axis2_options_set_action( options, Environment::getEnv(), NULL);
        }
        if(soap_act)
        {
          axutil_string_free(soap_act, Environment::getEnv());
        }


                if ( NULL == ret_node )
                {
                    return (com_ebay_www_marketplace_search_v1_services::GetVersionResponseE3*)NULL;
                }
                ret_val = new com_ebay_www_marketplace_search_v1_services::GetVersionResponseE3();

                if(ret_val->deserialize(&ret_node, NULL, AXIS2_FALSE ) == AXIS2_FAILURE)
                {
                    if(ret_val != NULL)
                    {
                       delete ret_val;
                    }

                    AXIS2_LOG_ERROR( Environment::getEnv()->log, AXIS2_LOG_SI, "NULL returned from the _deserialize: "
                                                            "This should be due to an invalid XML");
                    return (com_ebay_www_marketplace_search_v1_services::GetVersionResponseE3*)NULL;
                }


                        return ret_val;

    }

你能提供的任何帮助都将是最受欢迎的,我已经为这个问题努力了一段时间了。

我只是尝试生成XSD数据绑定对象,这样就不必手动处理每个请求。

EN

回答 1

Stack Overflow用户

发布于 2012-07-18 06:01:45

对于其他坚持这一点的人来说--问题是我需要使用--enable-ssl支持来编译wsof/axis2c。

然后按照这里的说明抓取易趣.crt文件(它被保存为.pem,但这是脚本的错误,一个.pem文件包含.crt和.key文件,但这只包含.crt文件):

http://axis.apache.org/axis2/c/core/docs/axis2c_manual.html#ssl_client

我只需要设置SERVER_CERT参数。

原因是URI集是https (不要将名称空间与http混淆-它与端点不同,不要上当受骗。)

请对此持保留态度,因为我几分钟前才明白。我从ebay收到了一条SOAP错误消息--但我只需要根据文档设置HTTP头,就完成了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11529551

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档