PDA

View Full Version : soap and web services



rmagro
17th November 2008, 12:22
Hi All,

I'm gonna try to explain you what I should make..

The web service provider, showed me an example about how to invoke its web service. The problem for me is that he's using Java and the Apache Axis libraries..

Here's the example provided:


String request = " here should be the xml request";
String url = " here is the we service provider url";
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndPointAddress(new URL(url));
call.setOperationName(new QName("Anagrafica", "execute")
String response = (String)call.invoke(new Object[] {request});


"Anagrafica" is the service and "execute" is the method to be invoked..

how can I get the same result using Qt's way??

Thank you in advance,

Roby

wysota
17th November 2008, 13:04
If you are a commercial user, you can use the QtSoap solution (unfortunately you have to pay for it). Otherwise you have to create appropriate xml wrapping for the method yourself based on an example query and then send it over network with proper headers to the webservice server.

high_flyer
17th November 2008, 13:06
You can also use Qt-Java development:
Windows:
http://trolltech.com/downloads/opensource/appdev/windows-java
Linux:
http://trolltech.com/downloads/opensource/appdev/linux-x11-java

rmagro
17th November 2008, 13:18
Could you simplify the alternative suggested with a brief example?

Thx

QPlace
17th November 2008, 23:44
I was fighting with web-services recently and ended (since I am not yet a commercial user and don't have access to qtsoap) just duplicating "post" method with QNetworkManager. I spent quite some time trying, until I installed http sniffer and it showed me exactly where I was wrong. After the sniffer pointed to the difference between request made from the browser and from my Qt code the rest was trivial.

In short, I suggest you to do the same. Install the sniffer, catch the request to the web-service made from the browser and then use QNetworkManager to construct "post" request...

rmagro
19th November 2008, 21:54
Someone knows how to translate the following code usign QSoap??



String request = " here should be the xml request";
String url = " here is the we service provider url";
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndPointAddress(new URL(url));
call.setOperationName(new QName("Anagrafica", "execute")
String response = (String)call.invoke(new Object[] {request});
"Anagrafica" is the service and "execute" is the method to be invoked..

Thanka a lot for your time,

Roby

wysota
19th November 2008, 22:02
With QtSoap it would be something like:

QtSoapHttpTransport transport;
transport.setHost(url.host(), url.port());
connect(&transport, SIGNAL(reponseReady()), this, SLOT(...)));
QtSoapMessage msg;
msg.setMethod("Anagrafica:execute");
transport.submitRequest(msg, url.path());

rmagro
20th November 2008, 10:58
many thanks for your suggestion..

I will try and let you know about my progress

THX

Roby

rmagro
20th November 2008, 14:47
With QtSoap it would be something like:

QtSoapHttpTransport transport;
transport.setHost(url.host(), url.port());
connect(&transport, SIGNAL(reponseReady()), this, SLOT(...)));
QtSoapMessage msg;
msg.setMethod("Anagrafica:execute");
transport.submitRequest(msg, url.path());

where should I put my xml request in this case?

wysota
20th November 2008, 16:33
I'm not sure I understand :) QtSoapMessage is a request. If you mean the actual data to send then you have to form a proper structure using QtSoapStruct or similar.

rmagro
21st November 2008, 12:12
What I meant is that in the axix example I provided there was an XML request that represented the actual data to send..
Using QtSoap where Should I put my xml request (yeah, the actual data to send or "payload" if you prefer).

Should I use something like QtSoapMessage::setContent or something else?

THX



I'm not sure I understand :) QtSoapMessage is a request. If you mean the actual data to send then you have to form a proper structure using QtSoapStruct or similar.

wysota
21st November 2008, 16:29
You have to construct the xml structure using QtSoap, not using external xml mechanisms. You fill objects which are then transformed into a properly formed xml based soap request.

rmagro
24th November 2008, 10:08
Ok.. and can you suggest how to do something like that..
Thx
Roby



You have to construct the xml structure using QtSoap, not using external xml mechanisms. You fill objects which are then transformed into a properly formed xml based soap request.

wysota
24th November 2008, 11:34
Oh come on! Please read the docs and see the examples. I already told you everything you need to know.