1. #1
    Sencha User
    Join Date
    Jan 2011
    Posts
    27
    Vote Rating
    0
    lilford.immanuel is on a distinguished road

      0  

    Exclamation Calling RESTful webservice

    Calling RESTful webservice


    I am sure this is already in the forum.. I am just not able to find a solution yet..

    I am trying to call a RESTful webservice across domain. I keep getting an error code.

    I would be greatful if somebody can point me in the right direction.

    If NOT across domain, atleast within the same domain would be helpful...

    The following code does not seem to work...

    Code:
    Ext.Ajax.request({
    		 url: 'http://<URL>/services/businessunitcombo',
    		 waitMsg: "Sending Request...",
    		 method: 'POST',
    		 success: function(response, opts){alert('Must have been 2xx http status code');},
    		 failure: function(response, opts){alert('Must have been 4xx or a 5xx http status code:' + response.status);}
    		});

  2. #2
    Sencha User joseeight's Avatar
    Join Date
    Sep 2010
    Location
    New York, NY
    Posts
    85
    Vote Rating
    1
    joseeight is on a distinguished road

      1  

    Default


    You can't make an AJAX call cross domain, you must set up a proxy to do that. Here is what I used, got it a long time ago to solve the problem.

    PHP Code:
    <?php
    // Set content type here
    header('Content-type: text/xml');

    //Request URL
    $requestURL "URLofSERVICE" $_SERVER['QUERY_STRING'];

    //Getting data from URL requested
    $handle fopen($requestURL"r");

    //MAGIC!!!
    if ($handle) {
        while (!
    feof($handle)) {
            
    $buffer fgets($handle4096);
            echo 
    $buffer;
        }
        
    fclose($handle);
    }
    ?>
    You call this page on the same server with the parameters you need to send to the regular service. It will return the same data you would get as making the same direct call.

  3. #3
    Sencha User
    Join Date
    Jan 2011
    Posts
    27
    Vote Rating
    0
    lilford.immanuel is on a distinguished road

      0  

    Default


    Thank you Jose.. Will try this out...

  4. #4
    Sencha User
    Join Date
    Jan 2011
    Posts
    27
    Vote Rating
    0
    lilford.immanuel is on a distinguished road

      0  

    Default


    I got it working by calling a servlet which I am comfy with.. Works like a charm...

    Donna head or tail of PHP

    Thanks a bunch mate

Similar Threads

  1. calling java webservice using AJAX object
    By ramasekhar in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 27 Apr 2011, 10:35 PM
  2. [ExtJS 3.3] Calling webservice with parameters in ASP.NET
    By --miCZar-- in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 5 Nov 2010, 6:10 AM
  3. Extjs to call a RESTful webservice
    By vivekc in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 1 Dec 2009, 10:55 PM
  4. problem calling a webservice in webMethods environment
    By brikonwall in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 12 Feb 2008, 7:23 AM
  5. Error when calling a webservice
    By graphicsxp in forum Ext 2.x: Help & Discussion
    Replies: 8
    Last Post: 27 Dec 2007, 11:57 AM

Thread Participants: 1

Tags for this Thread