Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
tambunanw #1
User title: Welly
Member since Jul 2011 · 57 posts · Location: Jakarta
Group memberships: Members, Premium
Show profile · Link to this post
Subject: Bad Request Response while using Custom Element
hai all,

i'm planning on buying Matrix component.

i want to create custom component. but i've got an error like this

<iq type="error" id="MX_1" from="madya@jakwt/MatriX" to="jakwt/8ede1f92" xmlns="jabber:client">
  <weather xmlns="petrolink:weather">
    <zip>74080</zip>
  </weather>
  <error code="400" type="modify">
    <bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
  </error>
</iq>

my code for component is...

// weather.cs

    public class Weather : XmppXElement
    {
        public const string NAMESPACE = "petrolink:weather";
        public const string TAG_NAME = "weather";

        public Weather()
            : base(NAMESPACE, TAG_NAME)
        {
        }

        public int Humidity
        {
            get { return GetTagInt("humidity"); }
            set { SetTag("humidity", value); }
        }

        public int Temperature
        {
            get { return GetTagInt("temperature"); }
            set { SetTag("temperature", value); }
        }

        public string Zip
        {
            get { return GetTag("zip"); }
            set { SetTag("zip", value); }
        }
    }

    public class WeatherIq : Iq
    {
        public WeatherIq()
        {
            GenerateId();
        }

        public Weather Weather
        {
            get { return Element<Weather>(); }
            set { Replace(value); }
        }
    }

and i've already register my custom element
        private void RegisterCustomElement()
        {
            Factory.RegisterElement<Weather>(Weather.NAMESPACE, Weather.TAG_NAME);
        }

could anyone explain the problem? in agsXmpp version my code with custom component is running well. 

Thanks before
This post was edited on 2011-07-27, 14:41 by tambunanw.
Avatar
Alex #2
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
can you please elaborate on what you want to do?

  • do you want to create custom packets (elements) only.
Avatar
tambunanw #3
User title: Welly
Member since Jul 2011 · 57 posts · Location: Jakarta
Group memberships: Members, Premium
Show profile · Link to this post
thanks for your quick reply

i just want to create custom packets only.

just trying to move from agsXmpp to MatriX.

i follow the tutorial for extending matrix here http://www.ag-software.net/matrix-xmpp-sdk/matrix-develope…
Avatar
Alex #4
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
in teh most cases <bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /> means that you are sending a packet to a non existing resource or idendity. So check the to attribute of your outgoing packet.

Alex
Avatar
tambunanw #5
User title: Welly
Member since Jul 2011 · 57 posts · Location: Jakarta
Group memberships: Members, Premium
Show profile · Link to this post
i've already capture onSendXml

sending: <iq id="MX_1" type="get" to="madya@jakwt/MatriX" xmlns="jabber:client">
  <weather xmlns="petrolink:weather">
    <zip>74080</zip>
  </weather>
</iq>

the receiver is running on the resource : Matrix.
Avatar
Alex #6
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
please post or attach the complete debug xml of the sessions, sender and receiver when possible.

Alex
Avatar
tambunanw #7
User title: Welly
Member since Jul 2011 · 57 posts · Location: Jakarta
Group memberships: Members, Premium
Show profile · Link to this post
hi alex,

thanks for your patience. the problem is solved. the problem is in the Jid

            XmppClientWrapper client = new XmppClientWrapper();
            client.Login("welly@jakwt", "welly");

            var wiq = new WeatherIq
            {
                Type = IqType.get,
                To = new Jid("madya", "jakwt", "MatriX"),
                [i]//To = "madya@jakwt/MatriX",[/i] -> not working
                Weather = new Weather { Zip = "74080" }
            };
            //Console.WriteLine(wiq);

i expect Jid will do auto convert for resource, but it's not

then i change this line
To = "madya@jakwt/MatriX"

to

To = new Jid("madya", "jakwt", "MatriX"),

then it works.

is my assumption right? am i missing something?
Avatar
Alex #8
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
for IQs you need always the full JabberId (with resource). MatriX always logs in with with the resource "MatriX" when you don't set another resource. But you should not rely on this feature.
You get the resource of all your subscribed contacts always in the OnPresence event. Hard-coding resources is not a very good idea.

Alex
Avatar
tambunanw #9
User title: Welly
Member since Jul 2011 · 57 posts · Location: Jakarta
Group memberships: Members, Premium
Show profile · Link to this post
oh.. ic..

Thanks a lot alex.  :-D
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:
Forum: MatriX RSS