Results 1 to 14 of 14

Thread: soap and web services

  1. #1
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question soap and web services

    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:
    Qt Code:
    1. String request = " here should be the xml request";
    2. String url = " here is the we service provider url";
    3. Service service = new Service();
    4. Call call = (Call)service.createCall();
    5. call.setTargetEndPointAddress(new URL(url));
    6. call.setOperationName(new QName("Anagrafica", "execute")
    7. String response = (String)call.invoke(new Object[] {request});
    To copy to clipboard, switch view to plain text mode 

    "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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: soap and web services

    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.

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: soap and web services

    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: soap and web services

    Could you simplify the alternative suggested with a brief example?

    Thx

  5. #5
    Join Date
    Jul 2007
    Posts
    121
    Thanks
    38
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: soap and web services

    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...

  6. The following user says thank you to QPlace for this useful post:

    rmagro (18th November 2008)

  7. #6
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: soap and web services

    Someone knows how to translate the following code usign QSoap??


    Qt Code:
    1. String request = " here should be the xml request";
    2. String url = " here is the we service provider url";
    3. Service service = new Service();
    4. Call call = (Call)service.createCall();
    5. call.setTargetEndPointAddress(new URL(url));
    6. call.setOperationName(new QName("Anagrafica", "execute")
    7. String response = (String)call.invoke(new Object[] {request});
    To copy to clipboard, switch view to plain text mode 
    "Anagrafica" is the service and "execute" is the method to be invoked..

    Thanka a lot for your time,

    Roby

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: soap and web services

    With QtSoap it would be something like:
    Qt Code:
    1. QtSoapHttpTransport transport;
    2. transport.setHost(url.host(), url.port());
    3. connect(&transport, SIGNAL(reponseReady()), this, SLOT(...)));
    4. QtSoapMessage msg;
    5. msg.setMethod("Anagrafica:execute");
    6. transport.submitRequest(msg, url.path());
    To copy to clipboard, switch view to plain text mode 

  9. #8
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: soap and web services

    many thanks for your suggestion..

    I will try and let you know about my progress

    THX

    Roby

  10. #9
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: soap and web services

    Quote Originally Posted by wysota View Post
    With QtSoap it would be something like:
    Qt Code:
    1. QtSoapHttpTransport transport;
    2. transport.setHost(url.host(), url.port());
    3. connect(&transport, SIGNAL(reponseReady()), this, SLOT(...)));
    4. QtSoapMessage msg;
    5. msg.setMethod("Anagrafica:execute");
    6. transport.submitRequest(msg, url.path());
    To copy to clipboard, switch view to plain text mode 
    where should I put my xml request in this case?

  11. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: soap and web services

    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.

  12. #11
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: soap and web services

    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


    Quote Originally Posted by wysota View Post
    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.

  13. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: soap and web services

    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.

  14. #13
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: soap and web services

    Ok.. and can you suggest how to do something like that..
    Thx
    Roby


    Quote Originally Posted by wysota View Post
    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.

  15. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: soap and web services

    Oh come on! Please read the docs and see the examples. I already told you everything you need to know.

  16. The following user says thank you to wysota for this useful post:

    rmagro (24th November 2008)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.