Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Page:  1  2  next
Avatar
Esofter #1
Member since Oct 2009 · 20 posts
Group memberships: Members
Show profile · Link to this post
Subject: Send query.
Hello everyone.
How I can send query width this xml for example:

<iq type='get'>
 <query xmlns='...'>
   <methodCall>
     <methodName>getStopName</methodName>
     <params>
       <param><value><string>somestring</string></value></param>
       <param><value><i4>3</i4></value></param>
     </params>
   </methodCall>
  </query>
</iq>

I use the agsXMPP.protocol.client.IQ class:

IQ myIq=new IQ(IqType.get);
myIq.Query.SetTag("MethodCall");
//send this query
con.Send(myIq);

How paste other elements in <methodCall> element, such as <methodName>,<params>...?
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I think what you are looking for is XEP-0009 Jabber-RPC. This is already included with agsXMPP.

Alex
Avatar
Esofter #3
Member since Oct 2009 · 20 posts
Group memberships: Members
Show profile · Link to this post
Alex, please help me build a typical request with agsxmpp:

<iq type='set'
    from='requester@company-b.com/jrpc-client'
    to='responder@company-a.com/jrpc-server'
    id='rpc1'>
  <query xmlns='jabber:iq:rpc'>
    <methodCall>
      <methodName>examples.getStateName</methodName>
      <params>
        <param>
          <value><i4>6</i4></value>
        </param>
      </params>
    </methodCall>
  </query>
</iq>

What class of agsXMPP sdk include a typical request?
This post was edited on 2009-10-29, 14:37 by Esofter.
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by Esofter:
What class of agsXMPP sdk include a typical request?

look in agsXMPP.protocol.iq.rpc

Alex
Avatar
Esofter #5
Member since Oct 2009 · 20 posts
Group memberships: Members
Show profile · Link to this post
Thank you.
I send correct query now. But response incoming with error:

<error xmlns="jabber:client" code="501" type="cancel"><feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error>

What means this error?
Avatar
Alex #6
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
please post the complete request including the complete response.
feature-not-implemented means that the receiver of this IQ does not support this protocol or namespace.

Alex
Avatar
Esofter #7
Member since Oct 2009 · 20 posts
Group memberships: Members
Show profile · Link to this post
Thank you.
If I get response like:

...
<methodResponse>
 <params>
   <param>
     <value><i4>5</i4></value>
   </param>
   <param>
     <value><string>string_1</string></value>
     <value><string>string_2</string></value>
     <value><string>string_3</string></value>
   </param>
 </params>
</methodResponse>
...

How I may to read this values from query? What methods iq class I must use?
Avatar
Esofter #8
Member since Oct 2009 · 20 posts
Group memberships: Members
Show profile · Link to this post
I write this code for get all values:

                    Rpc rpc = new Rpc();
                    rpc = (Rpc)iq.Query;
                    MethodResponse resp = new MethodResponse();
                    resp = rpc.MethodResponse;
                    ArrayList arr = resp.GetResponse();
Response:

<methodResponse>
 <params>
   <param>
     <value><i4>5</i4></value>
   </param>
   <param>
     <value><string>string_1</string></value>
     <value><string>string_2</string></value>
     <value><string>string_3</string></value>
   </param>
 </params>
</methodResponse>

In array list writed <5> and <string_1>.
 What I do not correctly?
Avatar
Esofter #9
Member since Oct 2009 · 20 posts
Group memberships: Members
Show profile · Link to this post
I find bug in your library. It was in MethodResponse.ParseResponse.
Look at part code where bug:

        private ArrayList ParseResponse()
        {
           ...
                //incorrect code I place in comment
                foreach (Element p in nl)
                {
                    //Element value = p.SelectSingleElement("value");
                    //if (value != null)
                    //    al.Add(ParseValue(value));

                    //correct
                    ElementList list = p.SelectElements("value");
                    for (int i = 0; i < list.Count; i++)
                    {
                        al.Add(ParseValue(list.Item(i)));
                    }
                }
            }
            return al;
        }

Good luck.
Avatar
Alex #10
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
no, IMHO your response is wrong according to the XML-RPC specs. If you want to return a string array you have to embed it in a data element.
See: http://www.xmlrpc.com

Alex
Avatar
Esofter #11
Member since Oct 2009 · 20 posts
Group memberships: Members
Show profile · Link to this post
Alex, I agree with you but I needed to make it just like that.
Now I have question again:
Application is receiving different types of responses which must have to processed differently.
How to know in what way I must process response?
I read your document "creating own packet types" but if I will use this method then I will need to refuse from xml rpc standard of packet.
What will way be better?
Avatar
Alex #12
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I would use jabber:iq:rpc only if you have to reuse or integrate with existing rpc code and services.
Avatar
Esofter #13
Member since Oct 2009 · 20 posts
Group memberships: Members
Show profile · Link to this post
Hi.
I read your document "creating own packet types" and want to write class for getting informations from iq like this:
  1. <iq type="result" id="111" to="some">
  2.    <query xmlns="someNamespace">
  3.       <methodResponse>
  4.          <params>
  5.            <param>
  6.              <value><i4>7</i4></value>
  7.           </param>
  8.          <param>
  9.          <value>
  10.              <array>
  11.                 <data>
  12.                   <value><i4>-1</i4></value>
  13.                    <value><i4>1</i4></value>
  14.                </data>
  15.             </array>
  16.         </value>
  17.        </param>
  18.        <param>
  19.         <value>
  20.          <array>
  21.           <data>
  22.             <value><string>one</string></value>
  23.             <value><string>two</string></value>
  24.           </data>
  25.         </array>
  26.       </value>
  27.    </param>
  28. </params>
  29. </methodResponse>
  30. </query>
  31. </iq>

In document "creating own packet types" you did it for this xml

  1. <message xmlns="jabber:client" to="romeo@montage.net">
  2.  <weather xmlns="agsoftware:weather">  
  3. <humidity>90</humidity>
  4.  <temperature>57</temperature>  
  5. </weather>
  6.  </message>
there is no elements with type of param, only name of param.
How do it without names, but with types?
Please, help me write this class.
Avatar
Alex #14
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
to me it looks like you want to add RPC. This is already in the SDK in the agsXMPP.protocol.iq.rpc namespace.

Alex
Avatar
Esofter #15
Member since Oct 2009 · 20 posts
Group memberships: Members
Show profile · Link to this post
Quote by Alex:
to me it looks like you want to add RPC. This is already in the SDK in the agsXMPP.protocol.iq.rpc namespace.

Alex

Yes, I successfully send any query using agsXMPP.protocol.iq.rpc.
 Now I take respose:

                                Rpc rpc = new Rpc();
                                rpc = (Rpc)iq.Query;
                                MethodResponse resp = new MethodResponse();
                                resp = rpc.MethodResponse;
                                ArrayList arr = resp.GetResponse();

But then I must correct processed arr. To do it I  must know what packed incoming.
And I know that it was like this

   1.
      <iq type="result" id="111" to="some">
   2.
         <query xmlns="someNamespace">
   3.
            <methodResponse>
   4.
               <params>
   5.
                 <param>
   6.
                   <value><i4>7</i4></value>
   7.
                </param>
   8.
               <param>
   9.
               <value>
  10.
                   <array>
  11.
                      <data>
  12.
                        <value><i4>-1</i4></value>
  13.
                         <value><i4>1</i4></value>
  14.
                     </data>
  15.
                  </array>
  16.
              </value>
  17.
             </param>
  18.
             <param>
  19.
              <value>
  20.
               <array>
  21.
                <data>
  22.
                  <value><string>one</string></value>
  23.
                  <value><string>two</string></value>
  24.
                </data>
  25.
              </array>
  26.
            </value>
  27.
         </param>
  28.
      </params>
  29.
      </methodResponse>
  30.
      </query>
  31.
      </iq>


or like this

<iq type="result" id="111" to="some">

<query xmlns="someNamespace">
<methodResponse>

<params><param>

<value><boolean>1</boolean></value>

</param></params>

</methodResponse></query></iq>

How I may to know what in query?

Thank you.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Page:  1  2  next
Forum: agsXMPP RSS