使用WSO2/C++ Web服务包的客户端是否能够成功运行?我已经尝试了几乎所有我能想到的东西,但每次我尝试运行一个非常简单的客户端时,我都会崩溃。这是他们的示例程序之一的一些示例代码...
#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;
}
每次在 WRESTClient 对象构造时都会崩溃。这似乎是 WSO2 代码中某处的问题,但我没有收到任何错误消息表明确切的问题是什么。我的下一步将是针对 WSO2 的源代码进行构建,并逐步执行崩溃的代码,但我希望有人之前遇到过这个问题并有一些即时反馈。