PDA

View Full Version : QtSoap and .NET urgently need help



noo
29th October 2009, 06:33
Hi All,
Please help or suggest on this issue.

I convert QDomDocument to QString with following code.

QString xmlRequest = doc.toString();

The got the result as

<TT>100</TT>
<TR>001</TR>
<TE>ACK</TE>

Once convert from QString to QSaopMessage with following code

QtSoapMessage request;
request.setMethod("Post", "http://SomeURL.com/SUB/SUB1");
request.addMethodArgument("SUB_Request", "", xmlRequest);

The result will be like this

<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;TT>100&lt;/TT> // <- need "<" instead of "&lt;"
&lt;TR>001&lt;/TR>
&lt;TE>RECEIPT&lt;/TE>
</Post>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

How can I get "<" instead of "&lt;" in body message.
Please help.

wysota
29th October 2009, 09:32
You have to add the items to the soap structure one by one. Otherwise soap library doesn't know it should preserve the tags and encodes them to xml entities.

noo
29th October 2009, 12:08
Thanks a lot for your advises.

As your reply that means my code as below
not be able to use for soap message.
Is correct ?. Then I have to use soap structure
instead QDomDocument. Please advises.

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);

QString xmlRequest = doc.toString(); //

The got the result as

<TT>100</TT>
<TR>001</TR>
<TE>ACK</TE>

wysota
29th October 2009, 15:09
You can use QDomDocument as long as you convert its contents to QtSoapStruct (or whatever that class was called).

noo
30th October 2009, 02:52
Thanks for your advise.

I have tried to see Qt Document for converting QDomDocument to QtSoapStruct
but unfortunately not found on related issue. Can you give me some sample or
any suggestion on convert QDomDocument to QtSoapStruct.

Thanks in advances for your help.

wysota
30th October 2009, 03:37
Where have you been looking for it? I can clearly see a method for parsing a dom document into QtSoapStruct in the docs...

noo
30th October 2009, 04:28
As my code below, I already have QDomDocument then How can I convert to QtSoapStruct. Other one that I tried to create QtSoapStruct as sample in qtsoap document. When I display the value I did not see any value as insertion on each item.
Please see below "Start QtSoapStruct"

------ Start QDomDocument and How to convert to QtSoapStruct--------

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);

QString xmlRequest = doc.toString();

----------End QDomDocument----------


------------Start QtSoapStruct. Did not display and value from insertion-----------

QDomDocument Noo;
QtSoapStruct myStruct(QtSoapQName("xxx"));
myStruct.insert(new QtSoapSimpleType(QtSoapQName("item1"), 5));
myStruct.toDomElement(Noo);
myStruct.insert(new QtSoapSimpleType(QtSoapQName("item2"), "hello"));
myStruct.toDomElement(Noo);
myStruct.insert(new QtSoapSimpleType(QtSoapQName("item3"), true));
myStruct.toDomElement(Noo);

QString xml = Noo.toString();

qDebug() << xml;
--------------End QtSoapStruct----------------

wysota
30th October 2009, 09:36
Hmm... Haven't you noticed QtSoapStruct::parse()?

noo
2nd November 2009, 15:54
Thanks for your suggestion but nothing help.

wysota
2nd November 2009, 17:04
Care to explain?