2009-01-13 80 views
2

是否能夠使用WSO2/C++ web服務包成功運行客戶端?我嘗試過所有我能想到的事情,但每次嘗試運行一個非常簡單的客戶端時,我都會遇到崩潰。下面是他們的榜樣方案之一了一些示例代碼...崩潰編寫簡單的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的源代碼進行構建,並逐步瀏覽崩潰的代碼,但我希望以前有人遇到過這個問題,並有一些即時反饋。

回答

1

您是否考慮過在WRESTClient對象構造中放置try/catch-all塊?如果你是在這條線上進行核心轉儲,那麼它有可能拋出一個異常,並且如果你捕獲了異常,那麼你可能會從這個異常中獲得更多有用的錯誤信息。

除此之外,按照您的建議打破調試器的時間。