2012-03-06 1 views
4

WFS-T xmlhttpのポストの長さ制限?長い時間は私が助けを今求めている検索としようとした後

マイ状況:

  • 私は、ユーザーが属性を持つシンプルな geoemtriesを作成することができますjqueryの/ OpenLayersを-アプリをしました...
  • 私はtomcat6(:80-iptables)とgeoserver 2.1.3(jetty:8181)でdebian6を実行しています。 Tomcatとgeoserver間のすべてのクロスドメインの問題は、ユーザーが何の問題もなく、すべて私のWFS-レイヤを表示し、 ことができますすることができ、簡単なJSP-プロキシ
  • で解決されているシンプルなジオメトリ

私の問題を作成します:

  • より複雑なジオメトリを作成しているユーザーは、 wfs-tに保存できません。より複雑なのは、結果として得られるXML-POSTのコンテンツ長が を超えていることを意味します。 2100文字。例えば、 2000文字は が正常に挿入されています。
  • 私はTomcatのサーバの設定と無効にすべての制限 (maxHTTPHeaderSize、maxSavePostSize、...)に掘っもgeoserver-桟橋ウェブサーバで maxpostsize上昇してきました - 応答後> NO EFFECT
  • をユーザーは、より複雑な ジオメトリを作成し、エラーメッセージ:

org.xml.sax.SAXParseException:無効なXML文字(ユニコード:0x0の)は、文書の要素コンテンツで発見されました。文書の要素内容に無効なXML文字(Unicode:0x0)が見つかりました。


  • 私はXMLのPOSTリクエストは私が以前に正常に挿入されたジオメトリにもう一つの頂点を追加ユニコード・エラー毎回の原因になっている理由はさっぱりだが。
  • 私の要求と応答コード:

successful POST request

successful response

successful POST request headers

not successful POST request

not successful response

not successful POST request headers

my jsp-proxy

私は私の問題を解決するためにどのように任意のヒントのために非常に満足しています!

事前のおかげで、

乾杯ユベール

+0

私は問題を回避しました...私のjsp-proxyが正しく動作していません。私はopenlayersアプリをgeoserver webappsフォルダ(桟橋)に転送しました - >プロキシは必要なく、すべてのWFSトランザクション(特に大きなもの)は動いています...しかし、将来はtomcatの中にアプリをホストしたいので、ソリューション...私は風刺のプロキシソリューションを見てみましょう – user1252188

答えて

1

以下、決して:) コードは(少なくとも私にとって)大きなジオメトリのために働くよりも優れ後半

YEAHああ、これは簡単なのコードですjspプロキシ

<%@page session="false"%> 
<%@page import="java.net.*,java.io.*" %> 
<%@page trimDirectiveWhitespaces="true"%> 
<% 

/** 
* This is a white list proxy that could be used the prevent an error due to 
* JavaScript Same Origin Policy. 
* 
* CAUTION: It might break some sites and it's a security risk because 
* people can use this proxy to browse the web and possibly do bad and/or illegal stuff 
* with it. 
* It can load any content type. 
* This proxy implementation was inspired by the proxy.cgi script of OpenLayers 
* {@link http://openlayers.org} 
* To use this in OpenLayers you have to set OpenLayers.ProxyHost = "Url/To/This/Proxyfile/proxy.jsp?"; 
* within your JavaScript code <br> 
* The base code of the proxy has been provided by SNIPPLR 
* {@link http://snipplr.com/view/17987/jsp-proxy-for-javascript-applications/} 
* 
* @author terrestris GmbH & Co. KG 
* @author Christian Mayer 
* @author Marc Jansen 
* 
* @license BSD see license.txt 
* 
*/ 
String[] allowedHosts = { 
    "www.openlayers.org", "openlayers.org", 
    "labs.metacarta.com", "world.freemap.in", 
    "prototype.openmnnd.org", "geo.openplans.org", 
    "sigma.openplans.org", "demo.opengeo.org", 
    "www.openstreetmap.org", "sample.azavea.com", 
    "v-swe.uni-muenster.de:8080", 
    "vmap0.tiles.osgeo.org", 
    "192.168.197.95:8080" 
}; 
HttpURLConnection con = null; 
try { 
    String reqUrl = request.getQueryString(); 
    String decodedUrl = ""; 
    if (reqUrl != null) { 
     reqUrl = URLDecoder.decode(reqUrl, "UTF-8"); 
    } 
    else { 
     response.setStatus(400); 
     out.println("ERROR 400: No target specified for proxy."); 
    } 

    // extract the host 
    String host = ""; 
    host = reqUrl.split("\\/")[2]; 
    boolean allowed = false; 

    // check if host (with port) is in white list 
    for (String surl : allowedHosts) { 
     if (host.equalsIgnoreCase(surl)) { 
      allowed = true; 
      break; 
     } 
    } 

    // do the proxy action (load requested ressource and transport it to client) 
    // if host is in white list 
    if(allowed) { 
     // replace the white spaces with plus in URL 
     reqUrl = reqUrl.replaceAll(" ", "+"); 

     // call the requested ressource  
     URL url = new URL(reqUrl); 
     con = (HttpURLConnection)url.openConnection(); 
     con.setDoOutput(true); 
     con.setRequestMethod(request.getMethod()); 
     String reqContenType = request.getContentType(); 
     if(reqContenType != null) { 
      con.setRequestProperty("Content-Type", reqContenType); 
     } 
     else { 
      con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); 
     } 

     int clength = request.getContentLength(); 
     if(clength > 0) { 
      /* NOT WORKING FOR LARGE POST BODY 
      con.setDoInput(true); 
      byte[] idata = new byte[clength]; 
      request.getInputStream().read(idata, 0, clength); 
      con.getOutputStream().write(idata, 0, clength); 
      */ 
      con.setDoInput(true); 
      InputStream istream = request.getInputStream(); 
      OutputStream os = con.getOutputStream(); 
      final int length = 5000; 
      byte[] bytes = new byte[length]; 
      int bytesRead = 0; 
      while ((bytesRead = istream.read(bytes, 0, length)) > 0) { 
       os.write(bytes, 0, bytesRead); 
      } 
     } 

     // respond to client 
     response.setContentType(con.getContentType()); 

     BufferedReader rd = new BufferedReader(new InputStreamReader(con.getInputStream())); 
     String line; 
     int i = 0; 
     while ((line = rd.readLine()) != null) { 
      out.println(line); 
     } 
     rd.close(); 
    } 
    else { 
     // deny access via HTTP status code 502 
     response.setStatus(502); 
     out.println("ERROR 502: This proxy does not allow you to access that location."); 
    } 

} catch(Exception e) { 

    // resond an internal server error with the stacktrace 
    // on exception 
    response.setStatus(500); 
    byte[] idata = new byte[5000]; 

    if(con.getErrorStream() != null) { 
     con.getErrorStream().read(idata, 0, 5000); 
    } 

    out.println("ERROR 500: An internal server error occured. " + e.getMessage() + " " + new String(idata));  
} 
%> 
+0

ありがとう!私の "jsp"プロキシは、あなたのサブセットであることに言及するのを忘れました...乾杯 – user1252188