KDSoap
KDSoap copied to clipboard
Add the possibility to serialize as XML
There is no possibility (or at least not documented) to serialize the generated classes as XML before sending the actual payload.
HI Phieber,
Sorry for the late answer, do you mean doing something like : myGeneratedClass myClass; KDSoapValue myClassValue = myClass.serialize(QString("MyClass")); qDebug() << myClassValue.toXml();
This allows you to check what it will look like once it's serialized. Cheers
Hi Franck,
to be quite honest, I have no idea what was the issue anymore. However, I hope that someone else will benefit from your answer. Thanks
take care Patrick
Am 15. Januar 2016 11:55:29 MEZ, schrieb Franck Arrecot [email protected]:
HI Phieber,
Sorry for the late answer, do you mean doing something like : myGeneratedClass myClass; KDSoapValue myClassValue = myClass.serialize(QString("MyClass")); qDebug() << myClassValue.toXml();
This allows you to check what it will look like once it's serialized. Cheers
Reply to this email directly or view it on GitHub: https://github.com/KDAB/KDSoap/issues/17#issuecomment-171932729
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
As of today there are generic serialize() and deserialize() methods on every type. I did not find any note about that in https://docs.kdab.com/kdsoap/latest Are those methods used to create XML from objects and the other way round?
For instance, we need to send XML files to a SOAP server. The WSDL provides all the types of the XML. But we already have the XML serialized as a file. Is it possible to create a KDSOAP object from the XML without parsing all the XML manually?
serialize()/deserialize() aren't documented because their use is mostly internal.
But if you already have XML in a file and you want to send that as a SOAP request, you don't really need KDSoap, you can just use QNetworkRequest/QNetworkReply directly (with just a few calls to request.setHeader, which you can find in KDSoapClientInterfacePrivate::prepareRequest for inspiration).
I'm not 100% sure about adding API for this use case, I fear it might confuse people, since this isn't the intended way to use KDSoap?
We don't have the complete SOAP XML. The SOAP service provides
void asyncSendFile( const N1__DocumentType& document );
where we have the XML of that document. KDSOAP would be required to provide soap:Envelope and soap:Body.
For the design perspective we could have based our framework on that N1__DocumentType with all the structure from KDSoap. But we did not like to base all on KDSoap, also because KDSoap cannot create structs from XSD.
I routed the (KD-) soap client to netcat with some simple data:
POST / HTTP/1.1
...
Host: 127.0.0.1:8081
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:soap-enc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<n1:Document xmlns:n1="urn:fooglobal:foo:xsd:1" schemaVersion="0" creationDate="">
<n1:Body>
<FooName>ValueBar</FooName>
</n1:Body>
</n1:Document>
</soap:Body>
</soap:Envelope>
What we have as XML is the n1:Document part. So what I would expect, that any KDSOAP type can be filled with custom XML string and just send without validation. The more advanced step would be to validate that XML against the WSDL embedded schema and also initialize all the structure below from that XML string. This should be possible, because implementing the server-side by KDSOAP, there is also incoming XML initializing C++ structures. So from my understanding every KDSOAP type should have some serializeFromXml(const QString&) and QString deserializeToXml(). What do you think? I guess this is what the author of this ticket thought about in 2013.
OK. That would be acceptable API indeed. Feel free to work on a patch that implements that (and sorry for the delayed reply...)