Answer the question
In order to leave comments, you need to log in
How to compose a SOAP message correctly? (C++ Qt)?
Good afternoon, help, please, dear Khabrovites!
I'm trying to understand SOAP.
You need to write a message according to the template.
I am using Qt Creator. Installed QtSoap. Test messages are compiled and sent, for example:
QtSoapMessage request;
request.setMethod("procedure", ""); // Вызываемая процедура
QtSoapArray * array = new QtSoapArray(QtSoapQName("arrayName"), QtSoapType::Array, 2);
QtSoapStruct * struct1 = new QtSoapStruct(QtSoapQName("testName"));
array->append(struct1);
QtSoapStruct * struct2 = new QtSoapStruct(QtSoapQName("testName"));
array->append(struct2);
request.addMethodArgument(array);
this->send(request); //отправляем, используя QtSoapHttpTransport
<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/">
<procedure>
<arrayName
SOAP-ENC:arrayType="xsd:struct[2]"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="xsd:Array"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
>
<item SOAP-ENV:position="[0]" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/>
<item SOAP-ENV:position="[1]" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/>
</arrayName>
</procedure>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
QtSoapMessage request;
QDomDocument document;
//составляем XML
request.setContent(document);//запихиваем в request
//отправляем
<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"/>
Answer the question
In order to leave comments, you need to log in
Try using the gSOAP Toolkit , maybe it will help you figure it out. Or Qt SOAP Manager .
Qt SOAP is not entirely native, it is included in Qt Solutions (it is not included in Qt, the situation with support is not entirely clear). In my experience, the degree of compatibility of various SOAP implementations is close to zero - that is, if you have a .NET service and a .NET client, then maybe everything will work as it should. Therefore, manually generating requests is the easiest and most reliable way. Parse, respectively, also manually, for example, using xpath.
This does not cause any particular problems, since the code for generating and parsing a message is quite abstract and is written once.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question