QtSoap generates wrong xml request



  • Hi,
    I have problem with QtSoap plugin that generates wrong xml request.
    Plugin from link: https://github.com/commontk/QtSOAP

    In response I always receive message that echo parameter is not given, so I wrote a simple soap client using PHP (response is correct).
    I'm sure the problem only affects xml request (not header), because I injected PHP xml request statically in QtSoap plugin (reponse was correct).

    PHP xml request:

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:StWebApi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
       <SOAP-ENV:Body>
          <ns1:test>
             <test xsi:type="ns1:test">
                <echo xsi:type="xsd:string">aaaaaaaaaaaaaaddd</echo>
             </test>
          </ns1:test>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

    C++ xml request:

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
       <SOAP-ENV:Body xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
          <test>
             <echo xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xsi:type="xsd:string">aaaaaaaaaaaaaaddd</echo>
          </test>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

    C++ code:

    Test::Test(QObject* parent) :
        QObject(parent)
    {
        connect(&http, SIGNAL(responseReady()), SLOT(getResponse()));
        http.setAction("urn:StWebApiSoapServer");
        http.setHost("mywebpage.com", true);
    }
    
    Test::~Test()
    {
    }
    
    void Test::sendRequest()
    {
        QtSoapMessage request;
        request.setMethod(QtSoapQName("test", ""));
        request.addMethodArgument("echo", "", "aaaaaaaaaaaaaaddd");
    
        // Submit the method request to the web service.
        http.submitRequest(request, "/backend.php/webapi/soap");
    }
    
    void Test::getResponse()
    {
        // Get the response, check for error.
        const QtSoapMessage &resp = http.getResponse();
        if (resp.isFault())
        {
            qDebug() << (tr("Query failed: ")
                        + resp.faultString().value().toString());
            return;
        }
    
        // Extract the return value from this method response, check for
        // errors.
        const QtSoapType &res = resp.returnValue();
        if (!res.isValid())
        {
            qDebug() << (tr("Invalid return value"));
            return;
        }
        qDebug() << "response: " << resp.toXmlString();
                return;
    }
    

    As You can see xml requests are a bit different.
    What's wrong with my code?


  • Lifetime Qt Champion

    Hi,

    That's likely something you should as the author of the fork since he's likely the most recent developer having touch that code.

    As an alternative you might want to check KDAB's KDSoap project which is actively maintained.



  • Yeah, but KDAB's KDSoap is paid.
    I just wrote my own class and it looks that everything works correctly.


  • Lifetime Qt Champion

    @Devoo said in QtSoap generates wrong xml request:

    Yeah, but KDAB's KDSoap is paid.

    That is not accurate:

    From the projects readme:

    License
    
    KD Soap is (C) 2010-2019, Klaralvdalens Datakonsult AB, and is available under the terms of:
    
    * the LGPL (see LICENSE.LGPL.txt for details) (except libkdsoap-server, see LICENSE.AGPL3-modified.txt)
    
    * the GPL (see LICENSE.GPL.txt for details) (except libkdsoap-server, see LICENSE.AGPL3-modified.txt)
    
    * the KDAB commercial license, provided that you buy a license. please contact sales@kdab.com if you are interested in buying commercial licenses.
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.