PDA

View Full Version : SOAP API on Qt 5.3 - POST Request Wrong



kartikeya
10th June 2014, 11:58
I am using SOAP API (http://doc.qt.digia.com/solutions/4/qtsoap/) of Qt.
They have qtsoap.h & qtsoap.cpp files which I just simply included into my project.
I know this was originally was written for Qt4. And it works great with Qt 4.7.4 & Qt 4.8
Now, I wanted to port the same to Qt 5.3

The SOAP Message forms correctly by the API but the header is incorrect.

Header generated on Qt 4.7.3:
POST /service1.asmx HTTP/1.1
Content-Type: text/xml;charset=utf-8
SOAPAction: http://ireo.org/getBBProp
Content-Length: 457
Connection: Keep-Alive
Accept-Encoding: gzip
Accept-Language: en-US,*
User-Agent: Mozilla/5.0
Host: 10.1.0.66:80

Header generated on Qt 5.3 (which is wrong, service1.asmx is missing):
POST HTTP/1.1
Content-Type: text/xml;charset=utf-8
SOAPAction: http://ireo.org/getBBProp
Content-Length: 457
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
Accept-Language: en-US,*
User-Agent: Mozilla/5.0
Host: 10.1.0.66:80

SOAP Message generated on both Qt 4.7.4 & Qt 5.3 (is correct for both complilers):
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<getBBProp xmlns="http://ireo.org/">
<deviceid xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">user1</deviceid>
</getBBProp>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Now you can see, the issue is in the header generated. The difference in 5.3 is that the url which I set is missing which is in our case is service1.asmx
And header is not generated by the SOAP API but by the QNetworkAccessManager


Here's the code I am using for generating SOAP message and sending, which was working fine in Qt 4.7.4:

QtSoapHttpTransport m_soapHttpTransport;
m_soapHttpTransport.setAction("http://ireo.org/getBBProp");
m_soapHttpTransport.setHost("10.1.0.66",80);

QtSoapMessage request;
request.setMethod(QtSoapQName("getBBProp", "http://ireo.org/"));
request.addMethodArgument("deviceid", "", userid); //userid = "user1"
qDebug()<<request.toXmlString();

m_soapHttpTransport.submitRequest(request, "service1.asmx");


Now, when the SOAP message is formed which I have printed as request.toXmlString() which is correct is passed to the submitRequest.



Here's the code in the SOAP API for the submitRequest, in qtsoap.h:

/*!
Submits the SOAP message \a request to the path \a path on the
HTTP server set using setHost().
*/
void QtSoapHttpTransport::submitRequest(QtSoapMessage &request, const QString &path)
{
QNetworkRequest networkReq;
networkReq.setHeader(QNetworkRequest::ContentTypeH eader, QLatin1String("text/xml;charset=utf-8"));
networkReq.setRawHeader("SOAPAction", soapAction.toLatin1());
url.setPath(path);
networkReq.setUrl(url);

soapResponse.clear();
networkRep = networkMgr.post(networkReq, request.toXmlString().toUtf8().constData());
}

the soap message is passed to the networkMgr and uses the .post method and then when I check the header is missing.

Is it a bug in QNetworkAccessManager of Qt 5.3 or in SOAP API (http://doc.qt.digia.com/solutions/4/qtsoap/) or error on my part. I don't seem to know.

If anything doesn't work out, then I am thinking of writing the SOAP header myself and then generating the SOAP message from the SOAP API & sending over TCPSocket.

kartikeya
11th June 2014, 11:05
It's URGENT guys. My project's work is completely blocked. Any help would be great.

anda_skoa
11th June 2014, 11:37
Can you check the value of "url"? Does it contain the path?
Have you tried "/service1.asmx"?

Btw, if you want a more comfortable way of working with SOAP in Qt, check out https://github.com/KDAB/KDSoap
It has a code generator that can make Qt classes for interfaces specified in WSDL files.

Cheers,
_

kartikeya
13th June 2014, 05:46
Thanks anda_skoa for the reply.

Ya, I did check in the debugger both in the url (which is a object of QUrl) & networkMgr ( object of QNetworkAccessManager) both have url set.

Ya, I even tried changing to /service1.asmx but to no avail. In the header, where the URL should be, remains blank. I thinking of it as a bug on the Qt side.

And I did check KDSOAP, I downloaded the code in ZIP from their site. But, the project doesn't compile in 4.7.4.
It's giving me error like this:
WARNING: d:\Projects\KDSoap-master\KDSoap-master\kdsoap.pro:43: Unescaped backslashes are deprecated.
Project MESSAGE: No install prefix given, using default of C:\KDAB\KDSoap- (use configure -prefix DIR to specify)
Project MESSAGE: Install prefix is C:\KDAB\KDSoap-
Project MESSAGE: This is KD Soap version
The process "c:\qtsdk\desktop\qt\4.7.3\mingw\bin\qmake.exe" exited with code 3.
Error while building project kdsoap (target: Desktop)
When executing build step 'qmake'

I think there is error in .pro file. But, the pro file seems too complex for me to understand.

And, I have a situation here, I need to compile SOAP in Qt 5.3 Android Platform and it not even running for 4.7.4.

anda_skoa
13th June 2014, 09:37
According to INSTALL.txt it should be buildable with Qt5

Since that is your target anyway, why try with Qt4?

Cheers,
_

kartikeya
13th June 2014, 10:23
Project MESSAGE: No install prefix given, using default of C:\KDAB\KDSoap- (use configure -prefix DIR to specify)
Project MESSAGE: Install prefix is C:\KDAB\KDSoap-
Project MESSAGE: This is KD Soap version
Cannot read D:/Projects/KDSoap-master/KDSoap-master/include: No such file or directory
MAKEFILE_GENERATOR variable not set as a result of parsing : include. Possibly qmake was not able to find files included using "include(..)" - enable qmake debugging to investigate more.
Reading D:/Projects/KDSoap-master/KDSoap-master/examples/holidays_wsdl/holidays_wsdl.pro [D:/Projects/KDSoap-master/build-kdsoap-Desktop_Qt_5_3_0_MinGW_32bit-Debug/examples/holidays_wsdl]
14:47:56: The process "D:\Qt_5_3\5.3\mingw482_32\bin\qmake.exe" exited with code 3.
Error while building/deploying project kdsoap (kit: Desktop Qt 5.3.0 MinGW 32bit)
When executing step 'qmake'


getting same kind of message in qt 5.3 as well

anda_skoa
13th June 2014, 12:07
Strange.

You could file a report in their issue tracker.

Cheers,
_

ckvsoft
19th January 2017, 19:07
run ./autogen.py and than make (not qmake)