简体   繁体   English

编写简单的WSO2 / C ++ Web服务客户端时崩溃

[英]Crash writing simple WSO2/C++ web service client

Has any been able to successfully run with a client using the WSO2/C++ web services package? 使用WSO2 / C ++ Web服务程序包是否能够成功与客户端一起运行? I've tried just about everything I can think of yet every time I try to run a very simple client I get a crash. 我已经尝试了几乎所有我能想到的一切,但是每次尝试运行一个非常简单的客户端时,我都会崩溃。 Here's some sample code from one of their example programs... 这是他们的示例程序之一的一些示例代码...

#include <stdio.h>
#include <WSRESTClient.h>
#include <OMElement.h>
#include <iostream>
#include <AxisFault.h>
using namespace std;
using namespace wso2wsf;

int _tmain(int argc, _TCHAR* argv[])
{
 WSRESTClient * sc = new WSRESTClient("http://localhost:9090/axis2/services/echo/echoString");
    try 
    {   
        sc->initializeClient("echo_rest.log", AXIS2_LOG_LEVEL_TRACE);
    }   
    catch (AxisFault & e)
    {   
        cout << endl << "Error: " << e << endl;
        return 0;
    }
    Options * op = sc->getOptions();
    op->setHTTPMethod(AXIS2_HTTP_GET);
    sc->setOptions(op);
    {
        OMNamespace * ns = new OMNamespace("http://ws.apache.org/axis2/services/echo", "ns1");
        OMElement * payload = new OMElement(NULL,"echoString", ns);
        OMElement * child = new OMElement(payload,"text", NULL);
        child->setText("Hello World!");
        cout << endl << "Request: " << payload << endl;
        OMElement * response;
        try
        {
            response = sc->request(payload, "http://ws.apache.org/axis2/c/samples/echo/soap_action");
            if (response)
            {
                cout << endl << "Response: " << response << endl;
            }
        }
        catch (AxisFault & e)
        {
            cout << endl << "Error: " << e << endl;
        }
        delete payload;
    }
    delete sc;

    return 0;
}

I get a crash every time at the point of the WRESTClient object construction. 每次在WRESTClient对象构造时都会崩溃。 It appears to be an issue somewhere in the WSO2 code but I don't get any error message indicating what the exact problem is. WSO2代码中的某个地方似乎是一个问题,但是我没有收到任何错误消息指出确切的问题是什么。 My next step will be to build against the source for WSO2 and step through the code which is crashing but I'm hoping someone has encountered this issue before and has some immediate feedback. 我的下一步将是针对WSO2的源代码构建并逐步执行崩溃的代码,但我希望有人之前遇到过此问题并立即得到反馈。

Have you considered putting a try/catch-all block around the WRESTClient object construction? 您是否考虑过围绕WRESTClient对象构造try / catch-all块? If you're core dumping on this line then the chances are that it's throwing an exception, and if you catch it then you might be able to get more useful error information out of that exception. 如果您在这行上进行核心转储,则很可能会引发异常,如果您捕获了异常,则可能可以从该异常中获取更多有用的错误信息。

Other than that, time to break out the debugger as you suggested. 除此之外,您还可以按照建议的时间调试一下调试器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM