PDA

View Full Version : Error on QtSoapMessage::toXmlString



noo
27th October 2009, 09:51
I have create qtsoap message and got error once submit to
dotnet. Then I have verified to see all message and found
problem at 2 points.

1. Once create QdomDocument and convert to string at line
doc.toString(). I got correct of xml syntax as :-

Correct Syntax: <tag> xx </tag>
Please see Result of xmlRequest Message section below.

But got incorrect syntax after convert to qtsoapmessage as:-

Incorrect Syntax: &lt;tag> xx &lt;/tag>
Please see Result of requestMessage section below.

2. At "Control xmlns=''", I need to get xmlns='' at starting
tag but need to eliminate xmlns='' from ending tag.

Correct Syntax: <Control xmlns=''>
<tag> xx </tag>
<Control>

Please see Result of requestMessage section below.

If I did not eliminate xmlns='' at ending tag. I will got an
error once submit to dotnet.

Please help and thanks in advance.


//Some part of program...!

QDomDocument doc("");

QDomElement sub01 = doc.createElement("Control xmlns=''");
doc.appendChild(sub01);

// TransactionType
QDomElement tag01 = doc.createElement("TT");
sub01.appendChild(tag01);
QDomText _tag01 = doc.createTextNode("100");
tag01.appendChild(_tag01);

// TransactionReverse
QDomElement tag02 = doc.createElement("TR");
sub01.appendChild(tag02);
QDomText _tag02 = doc.createTextNode("O01");
tag02.appendChild(_tag02);

// TransactionEvent
QDomElement tag03 = doc.createElement("TE");
sub01.appendChild(tag03);
QDomText _tag03 = doc.createTextNode("ACK");
tag03.appendChild(_tag03);

// I then get the QString...
QString xmlRequest = doc.toString(); //
qDebug() << xmlRequest; // Please see Result of xmlRequest


// Then build the soap message as follows:
QtSoapMessage request;
request.setMethod("Post", "http://SomeURL.com/SUB/SUB1");
request.addMethodArgument("SUB_Request", "", xmlRequest);

QString requestMessage = request.toXmlString(); // Line 2
qDebug() << requestMessage; // Please see Result of requestMessage

//and so on posting this to the web service URL..

http.setHost("SomeURL.com", 443);
http.setAction("https://SomeURL.com/sub_url/req.asmx?wsdl");
http.submitRequest(request, "/sub_url/req.asmx?wsdl");



Result of xmlRequest Message......!

<Control xmlns=''>
<TT>100</TT>
<TR>001</TR>
<TE>ACK</TE>
</Control xmlns=''> // need to eliminate xmlns='' out from this tag

End of xmlRequest Message........!



Result of requestMessage .....!

NEED TO GET CORRECT SYNTAX from &lt;tag>xx&lt;/tag> => <tag> xx </tag>

<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/2001/XMLSchema" >
<SOAP-ENV:Body xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<Post xmlns="http://SomeURL.com/SUB/SUB1">
<SUB_Request>
&lt;Control xmlns=''>
&lt;TT>100&lt;/TT>
&lt;TR>001&lt;/TR>
&lt;TE>RECEIPT&lt;/TE>
&lt;/Control xmlns=''>
</SUB_Request>
</Post>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

End of requestMessage ......!:confused: