2012-08-27 119 views
2

我有一个GWT应用程序,我的标准GWT 8888端口与端口8080工作围绕GWT同源策略

运行的JAX-RS /新泽西/ Glassfish的服务comunicate上调试这是GWT代码:

StringBuffer postData = new StringBuffer(); 

postData.append(URL.encode("username")).append("=").append(URL.encode(user)); 
postData.append("&"); 
postData.append(URL.encode("password")).append("=").append(URL.encode(password)); 

RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, "http://localhost:8888/gestdoc/resources/data/login"); 
builder.setHeader("Content-type", "application/x-www-form-urlencoded"); 
try { 
    builder.sendRequest(postData.toString(), new RequestCallback() { 

      public void onResponseReceived(Request request, Response response) 
      { 
       String responseText = response.getText(); 
       String headers= response.getHeadersAsString(); 
       String statusText= response.getStatusText(); 
       int statusCode= response.getStatusCode(); 
       String toString= response.toString(); 


       System.out.println("responseText: "+responseText); 
       System.out.println("headers: "+headers); 
       System.out.println("statusTest: "+statusText); 
       System.out.println("statusCode: "+statusCode); 
       System.out.println("toString: "+toString); 

       GestoreUtenze.this.cddoc.loginResponse(true); 
      } 


      public void onError(Request request, Throwable exception) { 
      // exception handling 
      } 
     }); 
} catch (RequestException e) { 
    // TODO Auto-generated catch block 
    e.printStackTrace(); 
} 

这是输出:

responseText: 
headers: 
statusTest: 
statusCode: 0 
toString: [email protected] 

我有一个java批量客户机与我过我的球衣服务,都OK。

我看了很多文章,我想我有一个相同的原始政策问题。

我已经尝试了许多解决方案:

  1. 运行浏览器在那里我调试我与非同源策略(Chrome和Firefox)GWT应用
  2. 添加的行中我的GWT配置文件
  3. 我试图建立一个没有成功的代理。我能怎么做?

请问您能帮我解决这个问题吗?

回答

1

唯一可用的办法,我发现这样的票价已开始谷歌浏览器与

--disable-web-security 

这将禁用同源策略。

您可以在Win 7中通过按[Strg + SHift +右键单击] - >属性并将--disable-web-security添加到目标属性中执行此操作。但是,您应该只在调试时使用该属性!

FF和IE似乎没有一种绕过SOP策略的工作方式(无法获得我在网上找到的任何示例,无法在工作中尝试并至少尝试一周!):