Results 1 to 10 of 10

Thread: How to send data to asp.net xml webservice?

  1. #1

    Default How to send data to asp.net xml webservice?

    Hi,

    With jQuery I can send data to my asp.net XML webservice (asmx file).

    Code:
    $.ajax({
    	type: 'POST',
    	url: ... , // URL TO ASMX FILE WITH AT THE END THE NAME OF THE METHOD
    	data: ... , // SJON STRING
    	contentType: 'application/json; charset=utf-8',
    	dataType: 'json',
    	success: function (data, status) {
    How can I do this withing an ExtJs method, thus sending data to my service? Of course, without jQuery but with ExtJs.


    I've read the docs... I know it is somehow possible. An example is very welcome.
    Thanks!

  2. #2

    Default

    No one? Some one with an php example? In the php examples I found there is no url?! So, please let me if you can help me further.

  3. #3
    Sencha Premium User westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    1,038

    Default

    Hi,

    Personally I use an ext.direct http handler rather than a traditional asmx web service.
    Have also used a Jayrock handler with ext 2 that worked well.

    It is possible to call an asmx but it can be quite involved. You generally use httppost, and have to manually handle the http reponse codes.

    I'd recommend the ext.direct route, if need a traditional web service for integration then it's still possible to factor out the code that does the work to a class library so it can be shared. That's exactly what i do.

    Hope this helps, and sorry can't post any links at the moment, hard to from phone

    Cheers,
    Westy
    Product Architect
    Altus Ltd.

  4. #4

    Default

    Hi Westy,

    Thanks for your reply!

    I'm using the traditional web service to send back JSON, example:

    Code:
    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public object SaveObject(string data) {
    With jQuery it works fine and easy.

    In the past, I use the router of Evan Trimboli. Somehow, this does not work for me with ExtJS 4 (and ASP.NET 4).

    So, you suggest using the http handler instead (ashx) over traditional web services (asmx)? Examples remain welcome.

  5. #5
    Sencha Premium User westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    1,038

    Default

    I've always had trouble with ScriptService attributes myself, they often seem to wrap the JSON in XML for some reason best known to itself. Although saying that yours obviously work ok if they're being called from JQuery.

    Have you tried calling your service using the Server proxy object? That's how I believe it's meant to be done in Ext 4, or some controls abstract it out.

    WRT Ext Direct, I don't think the specification has changed at all since Ext 3. I using Evan's router ok, although I did modify it so that it works a little better. Perhaps you'll have more success with that version?
    Then for reading data I use Direct proxies, for grid data, say, and for single reads, updates or adds I just call the methods directly as shown in many of the Ext.Direct examples...
    Product Architect
    Altus Ltd.

  6. #6
    Sencha User
    Join Date
    Apr 2007
    Posts
    14

    Default

    You should be able to do the same with ExtJs4 using Ext.Ajax.request(). Something like this:
    Code:
    Ext.Ajax.request({
      method: 'POST',
      url: ... , // URL TO ASMX FILE WITH AT THE END THE NAME OF THE METHOD
      jsonData: ... , // JSON STRING
      success: function (response) {
      }
    });

  7. #7

    Default

    Thank you all for your replies, I will give it a shot.

  8. #8
    Sencha User
    Join Date
    Sep 2007
    Posts
    22

    Default Please share

    Hi, can you share a little sample of how to use your Router modification with asp.net please? I'm having some errors trying to configure the client side...

    Regards
    Virgilio

    Quote Originally Posted by westy View Post
    I've always had trouble with ScriptService attributes myself, they often seem to wrap the JSON in XML for some reason best known to itself. Although saying that yours obviously work ok if they're being called from JQuery.

    Have you tried calling your service using the Server proxy object? That's how I believe it's meant to be done in Ext 4, or some controls abstract it out.

    WRT Ext Direct, I don't think the specification has changed at all since Ext 3. I using Evan's router ok, although I did modify it so that it works a little better. Perhaps you'll have more success with that version?
    Then for reading data I use Direct proxies, for grid data, say, and for single reads, updates or adds I just call the methods directly as shown in many of the Ext.Direct examples...

  9. #9
    Sencha User
    Join Date
    Sep 2007
    Posts
    22

    Default

    if you can, please sendme and little sample of how to use your router modification to [email protected]

    Regards,
    Virgilio

  10. #10
    Sencha Premium User westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    1,038

    Default

    It's a little hard to just share all my code without knowing exactly what you're having trouble with.

    You got a HTTP handler service set up?
    Can you hit it in a browser and get the JSON back?
    What are you trying to do, populate a grid through a proxy, say, or call directly?

    Regards,
    Westy
    Product Architect
    Altus Ltd.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •