PDA

View Full Version : qtsoap



anoop
12th February 2007, 14:37
qtsoap for sending image data can any body help?????

wysota
12th February 2007, 21:59
Could you elaborate? There is a soap client available as part of Qt Solutions for commercial use.

stevey
13th February 2007, 04:18
Hi,

It would help if you could let use know in detail what you're trying to do / thinking so we can best answer your questions.

Here's my take on soap style communcation in Qt:
I did a job recently where I wrote an image uploader for a document imaging backend.
The developer of the backend developed his own Java web service transport format which was very similar to SOAP in concept (Why he never used in the first place is beyond me...sheesh).
To send the images I'd request that a 'Batch' be created, then the server returned a receipt which was an xml document (Batch Receipt), then I'd upload the images to his server with a standard QHttp request and I'd receive back an Image Receipt xml document which would state the name assigned to the file by the server. So I'd end up with a list of uploaded filenames.
Then I'd add these names as elements to the first Batch Receipt xml document I received then send that back to the server in 'Commit' mode.

I can't say what was going on in the server because I didn't write it.
But you could use this sort of technique or even Base 64 encode the image files into the xml document and send it all as one request. It really depends on your situation.
I haven't used the QtSoap library so I can't comment on how to use it.

Just remember that the SOAP stuff is just a way of getting the data across and you can do it in one step or many. The reason we uploaded images one at a time was due to the image quality. We were scanning up to A0 maps at 400 - 600 dpi so the files were massive. Also, an single batch could have hundreds of images. Sending any more than one at a time wasn't feasible, but in your case it might be okay to base 64 encode your images straight into an element in the xml document.

If you need to actually use SOAP (which is probably the best way to go) then you'll need QtSoap if you have a commercial licence to Qt, or you could have a look into how http://qsoapman.sourceforge.net/ works.


I hope this helps,

Steve York

anoop
13th February 2007, 13:17
hai

thanks for responding so fast, well i did go through the qt soap, the problem i am facing is

how to send base64binary , int, float type values the QtSoapMessage class has an

addMethodArgument function which i take is what is used to send arguments to the function

with the execption of one all takes string type values. while the other one takes a QtSoapType * . The QTSoapType class does not provide any way to pass value of the variable or he variable name . The webservice i plan to use have methods that take int, float

as well as base64 encoded image. can you please tell me how to use

addMethodArgument function or something else that can be used to pass base64 encoded
binary jpeg as well as other datatypes. my main concern is how to send the value .


for eg i have a function that takes a string , base64binary encoded jpeg image and double

how should i populate the QSoapMessage object with values i mean which all functions

can be used.

thanks in advance

wysota
13th February 2007, 13:53
how to send base64binary , int, float type values the QtSoapMessage class has an

addMethodArgument function which i take is what is used to send arguments to the function

with the execption of one all takes string type values. while the other one takes a QtSoapType * . The QTSoapType class does not provide any way to pass value of the variable or he variable name .

You have to construct it using QtSoapSimpleType and its parse() method from an xml node.

As for integers, you can use addMethodArgument directly, there are overloads provided for bool and int types.

MaxProgrammer
13th February 2007, 13:55
Hello all Fellow QT programmers

Can any one tell me in the Scenario where i am supposed to send an image file encoded to Base64 and send as Binary data to SOAP web service using QT SOAP Libraries

How will I send Binary data in an Array and get the Response from the Web Service VIA QT

The Web service Where the QT SOAP has to send the image is located here

http://xrl.us/urur

Please do tell me how will i pass the Binary Data here in this Case the image to the Web Service Via QT SOAP Libraries

Thanks in Advance

Yours Friendly QT programmer

Roger

anoop
14th February 2007, 11:23
How to addmethodargument function to pass base64 binary encoded JPG Image to a Webservice using SOAP ?

addmethodargument function allows to pass primitive methods like Int Bool and String how ever it allows only QtSoapType for passing other types QtSoapType class or its derivatives QtSoapType symbol type does not provide any method to pass value alothough it allows to set the type like Base64 Binary

Pls tell me how will i actually pass value to this particular class when the type is Base64 Binary

Thanks in Advance

anoop
14th February 2007, 11:33
where to give the Value of the Array ie the Encoded Base64 binary JPG image to the the Web Service Via SOAP

QtSoapArray ( const QtSoapQName & name, QtSoapType::Type type = Other, int size0 = -1, int size1 = -1, int size2 = -1, int size3 = -1, int size4 = -1 )

wysota
14th February 2007, 11:42
This is a quote from:
http://doc.trolltech.com/solutions/4/qtsoap/qtsoaptype.html


SOAP supports the types described in XML Schema Part 2: Datatypes listed at http://www.w3.org/TR/xmlschema-2/. The following values are represented using QtSoapSimpleType, except where noted.

QtSoapType::Base64Binary is among them.

And you can construct it through:


bool QtSoapSimpleType::parse ( QDomNode node ) [virtual]

Inspects node and constructs the QtSoapSimpleType content if node qualifies as a SOAP simple type. Returns true if it does; otherwise returns false.

Reimplemented from QtSoapType.

Just look at the xml schema from the url in the docs to see how should a particular type be created.

anoop
14th February 2007, 12:20
hai

can you give me a code snippet or else tell me how to proceed, i mean how to use the parse function to get the base64encoded passed as an argument to the webservice
method

thanks in addvance

wysota
14th February 2007, 12:36
No, I can't give you a code snippet as I don't have access to QtSoap, so I won't be able to test it.
Just construct a QDomElement with data formatted as the xml document says (http://www.w3.org/TR/xmlschema-2/#base64Binary) and pass it to QSoapSimpleType::parse(). Remember that first you have to encode the data with base64 (if you don't know what that is, ask Google (http://www.google.com/search?q=base64)).

Edit:
Most probably it'll just be <base64Binary>base64 encoded data goes here</base64Binary>

anoop
14th February 2007, 12:45
How Will i add
Base64Binary ::= ((B64S B64S B64S B64S)*
((B64S B64S B64S B64) |
(B64S B64S B16S '=') |
(B64S B04S '=' #x20? '=')))?

add Base64 encoded image into a QDomNode element

wysota
14th February 2007, 13:44
How Will i add
Base64Binary ::= ((B64S B64S B64S B64S)*
((B64S B64S B64S B64) |
(B64S B64S B16S '=') |
(B64S B04S '=' #x20? '=')))?
This is just a grammar, you don't need it, just get a base64 encoder or write one yourself, it's trivial.


add Base64 encoded image into a QDomNode element


QBuffer buf;
QImage img; // contains your image
img.save(&buffer, "JPEG");
QString encodedstring = base64(buffer.data().constData());
QDomDocument doc;
QDomElement elem = doc.createElement("base64Binary");
elem.setAttribute("name", "somename");
elem.appendChild(doc.createTextNode(encodedstring) );
QSoapSimpleType arg;
arg.parse(elem); // this should get you a valid QSoapSimpleType object

anoop
14th February 2007, 14:30
How Will i add Base64 encoded image into a QDomNode element

wysota
14th February 2007, 19:25
Look at the previous post. There is a code snippet there that may work.

stevey
14th February 2007, 22:44
Once you have your base64 feed it into:
QDomText QDomDocument::createTextNode ( const QString & value )
You'll get back a QDomText object which you can pass into .appendChild(...)

So using the this technique, if you have a string like 'dl;kgjsdflkghlfjkghlkjf' and you call:


QDomText base64Text = doc.createTextNode("dl;kgjsdflkghlfjkghlkjf");
base64Elem.appendChild(base64Text );

You should end up with:


<base64Binary>dl;kgjsdflkghlfjkghlkjf</base64Binary>


Wysota already showed this in his last example.
Hopefully this will highlight the section of his example that actually sticks the base 64 string in the element.

anoop
14th February 2007, 23:25
This is just a grammar, you don't need it, just get a base64 encoder or write one yourself, it's trivial.




QBuffer buf;
QImage img; // contains your image
img.save(&buffer, "JPEG");
QString encodedstring = base64(buffer.data().constData());
QDomDocument doc;
QDomElement elem = doc.createElement("base64Binary");
elem.setAttribute("name", "somename");
elem.appendChild(doc.createTextNode(encodedstring) );
QSoapSimpleType arg;
arg.parse(elem); // this should get you a valid QSoapSimpleType object


What are the


elem.setAttribute("name", "somename");

What Will i have to pass here on "name", "somename" in case of this Webservice

http://xrl.us/urur

Thanks in Advance

wysota
15th February 2007, 00:41
What are the


elem.setAttribute("name", "somename");
Do you have any knowledge about XML or webservices?


What Will i have to pass here on "name", "somename" in case of this Webservice

http://xrl.us/urur


You can either ignore it or set the argument name there (like srcImage or whatever is needed)...