Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Example with KDSoap

Example with KDSoap

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 4 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nitoman
    wrote on last edited by
    #1

    Hi.

    I´m trying to make an example to learn to use KDSoap.

    I´m using the http://www.dneonline.com/calculator.asmx to make test but i don´t know how to send the parameters.

    It´s my code:

            const QString endPoint = QLatin1String("http://dneonline.com/calculator.asmx");
            const QString messageNamespace = QLatin1String("http://tempuri.org/");
            KDSoapClientInterface client(endPoint, messageNamespace);
            KDSoapMessage message;            
            message.addArgument(QLatin1String("intA"), 10);
            message.addArgument(QLatin1String("intB"), 5);
    
            KDSoapMessage response = client.call(QLatin1String("Add"), message);
    

    But i dont receive the SUM 15, i always receive AddResult 0. I receive this xml:

    respuesta : "<?xml version="1.0" encoding="UTF-8"?><n1:AddResponse xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:n1="http://tempuri.org/">n1:AddResult 0</n1:AddResult></n1:AddResponse>\n"

    i know i´m not sending the parameters in the right way, how can i do it?

    Thanks in advance.

    Regards.

    JonBJ 1 Reply Last reply
    0
    • N nitoman

      Hi.

      I´m trying to make an example to learn to use KDSoap.

      I´m using the http://www.dneonline.com/calculator.asmx to make test but i don´t know how to send the parameters.

      It´s my code:

              const QString endPoint = QLatin1String("http://dneonline.com/calculator.asmx");
              const QString messageNamespace = QLatin1String("http://tempuri.org/");
              KDSoapClientInterface client(endPoint, messageNamespace);
              KDSoapMessage message;            
              message.addArgument(QLatin1String("intA"), 10);
              message.addArgument(QLatin1String("intB"), 5);
      
              KDSoapMessage response = client.call(QLatin1String("Add"), message);
      

      But i dont receive the SUM 15, i always receive AddResult 0. I receive this xml:

      respuesta : "<?xml version="1.0" encoding="UTF-8"?><n1:AddResponse xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:n1="http://tempuri.org/">n1:AddResult 0</n1:AddResult></n1:AddResponse>\n"

      i know i´m not sending the parameters in the right way, how can i do it?

      Thanks in advance.

      Regards.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @nitoman
      I'm afraid I don't know KDSoap. But look at http://www.dneonline.com/calculator.asmx?op=Add, where you can see what POST content that method expects:

      <?xml version="1.0" encoding="utf-8"?>
      <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
        <soap12:Body>
          <Add xmlns="http://tempuri.org/">
            <intA>int</intA>
            <intB>int</intB>
          </Add>
        </soap12:Body>
      </soap12:Envelope>
      

      That's telling you that to call the method you need to produce <Add ..> </Add>, inside which your parameters should be nested. I think your parameter passing code is probably correct, you are missing whatever from KDSoap to create an Add node at the top-level, and then make parameters children of that.

      EDIT Whoops, no, I see, client.call(QLatin1String("Add"), message); passes the Add. And the response shows are getting an AddResult back. Sorry! I'm having a rethink... :)

      KDSoap, https://docs.kdab.com/kdsoap/1.0.0/class_k_d_soap_message.html#a465ae2c13f2c3c26e19aeb01d10b89d8:

      
      void KDSoapMessage::addArgument	(	const QString & 	argumentName,
      const QVariant & 	argumentValue,
      const QString & 	typeNameSpace = QString(),
      const QString & 	typeName = QString()	 
      )	
      

      I'm not a C++-er, but that expects a const QVariant & argumentValue. You pass a plain integer. Does that get correctly coerced from your literal integer constant? Are you supposed to create a QVariant variable holding an int for this to work, like

      auto intA = QVariant::QVariant(10);
      message.addArgument(QLatin1String("intA"), intA);
      

      ?

      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @JonB said in Example with KDSoap:

        const QVariant &

        Hi
        I think it will construct a variant from the int parameter.
        like QVariant var(44) just indirectly.
        But a valid Question.

        1 Reply Last reply
        0
        • N Offline
          N Offline
          nitoman
          wrote on last edited by
          #4

          Thanks a lot for the replies but they don´t work

          i have tested:

          auto intA= QVariant(10);
          auto intB= QVariant(20);

          message.addArgument(QLatin1String("intA"), intA);
          message.addArgument(QLatin1String("intN"), intB);

          but the reply is the same. The result is always 0 :(

          JonBJ 1 Reply Last reply
          0
          • N nitoman

            Thanks a lot for the replies but they don´t work

            i have tested:

            auto intA= QVariant(10);
            auto intB= QVariant(20);

            message.addArgument(QLatin1String("intA"), intA);
            message.addArgument(QLatin1String("intN"), intB);

            but the reply is the same. The result is always 0 :(

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @nitoman , @mrjj
            Then this might sound odd, but I'm not sure there is anything wrong with what you are writing! If the parameters were bad we'd expect an error at the server. So, how do you know the code of that webservice is actually correct and is adding the numbers? The webservice looks pretty "incomplete" (no comments against the other methods supplied), maybe it just does not give the correct answer?! I would try to find some other public webservice somewhere and test passing parameters to that before I assumed anything was wrong in your client code?

            1 Reply Last reply
            0
            • N Offline
              N Offline
              nitoman
              wrote on last edited by
              #6

              Hi jonB.

              Thanks a lot for your support.

              i know the webservice is ok because if i test it with a Soap cliente like SopaUI i get a good answer for all operations.

              I show an example:

              I send this one:

              <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
              soapenv:Header/
              soapenv:Body
              tem:Add
              tem:intA10</tem:intA>
              tem:intB10</tem:intB>
              </tem:Add>
              </soapenv:Body>
              </soapenv:Envelope>

              and i receive:

              <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
              soap:Body
              <AddResponse xmlns="http://tempuri.org/">
              <AddResult>20</AddResult>
              </AddResponse>
              </soap:Body>
              </soap:Envelope>

              1 Reply Last reply
              0
              • N Offline
                N Offline
                nitoman
                wrote on last edited by
                #7

                the message lose some characters but i think you can see it more or less

                1 Reply Last reply
                0
                • N Offline
                  N Offline
                  nitoman
                  wrote on last edited by
                  #8

                  Ok, I have solved the problem creating the library with tool "kdwsdl2cpp". Now i have available methods to use the library.

                  Thanks!

                  Pablo J. RoginaP 1 Reply Last reply
                  1
                  • N nitoman

                    Ok, I have solved the problem creating the library with tool "kdwsdl2cpp". Now i have available methods to use the library.

                    Thanks!

                    Pablo J. RoginaP Offline
                    Pablo J. RoginaP Offline
                    Pablo J. Rogina
                    wrote on last edited by
                    #9

                    @nitoman said in Example with KDSoap:

                    I have solved the problem

                    great! please mark your post as solved. Thanks.

                    Upvote the answer(s) that helped you solve the issue
                    Use "Topic Tools" button to mark your post as Solved
                    Add screenshots via postimage.org
                    Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved