无法与Poco发送肥皂请求

时间:2019-06-18 09:29:39

标签: c++ soap poco

我在Poco上遇到问题,我正在尝试发送一个请求以测试soap websevice, 当我遵循此tutorial时,我在WSAP中使用了WS,但是当我尝试在代码中执行相同操作时,出现了此错误

  

{000000} 2019-06-18 10:56:21.726.259 Poco:错误超时

这是我在SoapUI中所做的: enter image description here 如您所见,我得到了答复(在一秒钟之内),但Poco无法做到这一点

    string paramUri("http://www.dataaccess.com:80/webservicesserver/numberconversion.wso");
    URI uri(paramUri);
    m_rwPathLogin = uri.getPathAndQuery();      
    HTTPClientSession session(uri.getHost(), uri.getPort());
    HTTPRequest request(HTTPRequest::HTTP_POST, m_rwPathLogin, HTTPMessage::HTTP_1_1);

    HTTPResponse response;
    std::cout << response.getStatus() << " " << response.getReason() <<std::endl;
    std::ostringstream stream;
    std::string str;
    std::ifstream fichier(fileTemps);
    while (std::getline(fichier, str))
    {
        stream << str << "\n";
        cout << str; //works
    }

    std::string doc = stream.str();

    request.setKeepAlive(true);

    request.setContentLength(doc.size());
    cout << "used req uri " << request.getURI() << endl; //works
    request.setContentType("text/xml");
    response.setContentType("text/xml");
    cout << "used port " << session.getPort() << endl;//works
    cout << "used host " << session.getHost() << endl;//works

    request.write(std::cout);
    std::ostream& requestStream = session.sendRequest(request);
    requestStream << doc;
    cout << "ok" << endl; //not working (ERROR Timeout)
    request.write(std::cout);

    std::istream& rs = session.receiveResponse(response);
    std::cout << response.getStatus() << " " << response.getReason() << std::endl; //not working

我什至尝试通过session.setTimeout(Poco::Timespan(20, 0));增加超时时间,但仍然没有希望。

这是fileTemps

上的内容
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.dataaccess.com/webservicesserver/" xmlns:sch="http://www.dataaccess.com/webservicesserver/schema">
   <soapenv:Header/>
   <soapenv:Body>
      <web:NumberToDollars>
         <web:dNum>123</web:dNum>
      </web:NumberToDollars>
   </soapenv:Body>
</soapenv:Envelope>

0 个答案:

没有答案