Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Communicating with gSoap - QNetworkReply::NetworkError(ContentNotFoundError)



  • The application on the other side uses gSoap for providing SOAP . I have the request samples from gSOAP to build the respective request XML in Qt. I have included one small sample below.

    I have been trying to get the request successfully built and sent from Qt but somehow it is not working.

    Thankful for any pointers/inputs to resolve this.

    Development Environment
    Linux Debian
    Qt 5.9.2
    SSL - 1.0.2 supported and available

    Error
    Network error: QNetworkReply::NetworkError(ContentNotFoundError)

    gSOAP request sample

    POST / HTTP/1.1
    Host: IP_Address:8000
    User-Agent: gSOAP/2.8
    Content-Type: text/xml; charset=utf-8
    Content-Length: 476
    Connection: close
    
    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope
        xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:ns2="http://tempuri.org/ns2.xsd"
        xmlns:ns1="http://tempuri.org/ns1.xsd">
     <SOAP-ENV:Body>
      <ns1:getAPTListByICAO>
       <icaoPart>YSSY</icaoPart>
      </ns1:getAPTListByICAO>
     </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

    This is what I have in Qt
    (it looks a bit messy though)

        QNetworkAccessManager manager;
        QNetworkRequest request;
        request.setRawHeader("Content-Type", "text/xml;charset=UTF-8");
        request.setRawHeader("Content-Length", "1024");
        request.setRawHeader("SOAPAction", "getAPTListByICAO");
        request.setUrl(QUrl("http://tempuri.org/ns1.xsd"));
        request.setRawHeader("User-Agent","gSOAP/2.8");
        request.setRawHeader("Host","ip.ip.ip.ip:8000");
        request.setRawHeader("Connection","Close");
    
        QString query =
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                "<SOAP-ENV:Envelope"
                    "xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\""
                    "xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\""
                    "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
                    "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\""
                    "xmlns:ns2=\"http://tempuri.org/ns2.xsd\""
                    "xmlns:ns1=\"http://tempuri.org/ns1.xsd\">"
                 "<SOAP-ENV:Body>"
                  "<ns1:getAPTListByICAO>"
                   "<icaoPart>YSSY</icaoPart>"
                  "</ns1:getAPTListByICAO>"
                 "</SOAP-ENV:Body>"
                "</SOAP-ENV:Envelope>";
    
        QNetworkReply* reply = manager.post(request, query.toUtf8());
    
        QEventLoop eventLoop;
    
        QObject::connect(reply, SIGNAL(finished()), &eventLoop, SLOT(quit()));
        eventLoop.exec();
    
        if (reply->error() != QNetworkReply::NoError)
        {
            qDebug() << "Network error: " << reply->error();
        }
        else
        {
            qDebug() << reply->readAll();
        }
    
    

  • Lifetime Qt Champion

    Hi,

    Not a direct answer but since you are doing SOAP, you might want to consider using the KDSoap.


Log in to reply