Hi Ramesh,
take a look at JsonpRequestBuilder class..
here you can find javadoc http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/jsonp/client/JsonpRequestBuilder.html

Regards,
Ale

--------------------------------------------------
From: "ramesh chiluveri" <[email protected]>
Sent: Tuesday, February 23, 2010 4:03 PM
To: "Google Web Toolkit" <[email protected]>
Subject: RPC Call Failed from other domain(cross domain) due to SOP


Hai All,

I am trying to develop an application ,which will going to make
server calls from different domains. I am facing problem with SOP . I
am not able to make a sever call from different doamin.

Below is the my code.
When i make rpc call with this code,it is always failing.(onFailure)




import java.util.ArrayList;
import java.util.HashMap;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.http.client.RequestBuilder;


import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class invoxwidget  implements EntryPoint,ClickListener{



public static String userSharedId = "";

protected HashMap callbacks = new HashMap();
protected HashMap scriptTags = new HashMap();
protected int curIndex = 0;
public Button but  = null;
public void onModuleLoad() {



String serverURL = GWT.getModuleBaseURL()+"?callback=";
        String callbackName = reserveCallback();
        setup(this, callbackName);
        addScript(callbackName, serverURL + callbackName);

}


public String reserveCallback()
{
     while (true)
     {
      if (!callbacks.containsKey(new Integer(curIndex)))
      {
       callbacks.put(new Integer(curIndex), null);


       return "__gwt_callback" + curIndex++;
      }
     }
}

/**
  * <p>Adds the JSONP script to our widget so we can make XSS
requests baby</p>
  *
  * @param uniqueId The unique id of the call
  * @param url The URL of our Request
  */
public native void addScript(String id, String url)
/*-{


     var elem = document.createElement("script");
     elem.setAttribute("language", "JavaScript");
     elem.setAttribute("src", url);
     elem.setAttribute("id", id);
     document.getElementsByTagName("body")[0].appendChild(elem);
}-*/;

public void handle(JavaScriptObject jso)
{


     if( jso != null )
     {

    HashMap details = new HashMap();
    details.put("userSharedID",userSharedId);
    Window.alert("before ContactServer "+userSharedId);

ContactServer.Util.getInstance().getBusinessName(details,new
AsyncCallback(){

    public void onFailure(Throwable arg0) {

    Window.alert("In onFailure");

    }
    public void onSuccess(Object arg0) {
    Window.alert("In onSuccess");
    }
});



/**
  *
  * <p>Sets up our Javascript cross site JSON call</p>
  *
  * @param model Handles our Cross Site JSON call
  * @param callback
  */
public native static void setup(invoxwidget inv, String callback)
/*-{

      $wnd.__gwt_callback0 = function(someData)
      {
         alert("inside setup");
         [email protected]::handle(Lcom/
google/gwt/core/client/JavaScriptObject;)(someData);
      }
   }-*/;

}


I am not able to find what is wrong??

Please help me

Thanks
Ramesh

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


--
You received this message because you are subscribed to the Google Groups "Google 
Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to