2014-01-21 6 views
0

WFS 요청 (this one)과 관련된 GWT-openlayers 쇼케이스 예제 중 하나를 재현 해 보았습니다. 나는 개발자 도구를 사용하여 인터넷 익스플로러 (11)에 그것을이 패널을 포함하는 내 GWT 응용 프로그램을 배포하고 실행변형 된 WFS XMLHttpRequest from GWT-openlayers from IE11

public class Example extends Composite { 

public Example() { 
    buildPanel(); 
} 

public void buildPanel() {   
    OpenLayers.setProxyHost("olproxy?targetURL=");   
    //create some MapOptions   
    MapOptions defaultMapOptions = new MapOptions();   
    defaultMapOptions.setNumZoomLevels(16);   
    MapWidget mapWidget = new MapWidget("500px", "500px", defaultMapOptions);   
    Map map = mapWidget.getMap();   
    WMSParams wmsParams = new WMSParams();   
    wmsParams.setFormat("image/png");   
    wmsParams.setLayers("topp:states");   
    wmsParams.setStyles("");   
    WMSOptions wmsLayerParams = new WMSOptions();  
    wmsLayerParams.setUntiled();   
    wmsLayerParams.setTransitionEffect(TransitionEffect.RESIZE); 
    String wmsUrl = "http://demo.opengeo.org/geoserver/wms";   
    WMS wmsLayer = new WMS("Basic WMS", wmsUrl, wmsParams, wmsLayerParams);   
    //Create a WFS layer   
    WFSProtocolOptions wfsProtocolOptions = new WFSProtocolOptions();   
    wfsProtocolOptions.setUrl("http://demo.opengeo.org/geoserver/wfs");  
    wfsProtocolOptions.setFeatureType("states");   
    wfsProtocolOptions.setFeatureNameSpace("http://www.openplans.org/topp");   
    //if your wms is in a different projection use wfsProtocolOptions.setSrsName(LAMBERT72);   
    WFSProtocol wfsProtocol = new WFSProtocol(wfsProtocolOptions);   
    VectorOptions vectorOptions = new VectorOptions();   
    vectorOptions.setProtocol(wfsProtocol);   
    vectorOptions.setStrategies(new Strategy[]{new BBoxStrategy()});   
    //if your wms is in a different projection use vectorOptions.setProjection(LAMBERT72);   
    final Vector wfsLayer = new Vector("wfsExample", vectorOptions);  
    wfsLayer.setFilter(new FeatureIdFilter(new String[]{"states.30"})); 
    //note that you can request the FID of a VectorFeature using getFID() 
    map.addLayer(wmsLayer);  
    map.addLayer(wfsLayer);  
    //Lets add some default controls to the map  
    map.addControl(new LayerSwitcher()); //+ sign in the upperright corner to display the layer switcher  
    map.addControl(new OverviewMap()); //+ sign in the lowerright to display the overviewmap 
    map.addControl(new ScaleLine()); //Display the scaleline  
    //Center and zoom to a location  
    map.setCenter(new LonLat(-100, 40), 4);   
    initWidget(mapWidget);  
    mapWidget.getElement().getFirstChildElement().getStyle().setZIndex(0); //force the map to fall behind popups 
} 
} 

:이 같은 코드를 유지하고 단지 대신 추상 예제의 간단한 합성으로 그것을 수정 필자는 지정된 id를 가진 기능을 요구하는 WFS XMLHttpRequest를 조사했다. 다음과 같이 XML 요구했다 : 쇼케이스 예의

<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd"> 
<wfs:Query typeName="feature:states" xmlns:NS1="" NS1:xmlns:feature="http://www.openplans.org/topp"> 
    <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc"> 
     <ogc:And> 
      <ogc:FeatureId fid="states.30" /> 
      <ogc:BBOX> 
       <ogc:PropertyName>the_geom</ogc:PropertyName> 
       <gml:Box xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326"> 
        <gml:coordinates decimal="." cs="," ts=" ">-143.9453125,-3.9453125 -56.0546875,83.9453125</gml:coordinates> 
       </gml:Box> 
      </ogc:BBOX> 
     </ogc:And> 
    </ogc:Filter> 
</wfs:Query> 
</wfs:GetFeature> 

동일한 요청, 발신을이 대신 같다 :

<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd"> 
<wfs:Query typeName="feature:states" xmlns:feature="http://www.openplans.org/topp"> 
    <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc"> 
     <ogc:And> 
      <ogc:FeatureId fid="states.30"/> 
      <ogc:BBOX> 
       <ogc:PropertyName>the_geom</ogc:PropertyName> 
       <gml:Box xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326"> 
        <gml:coordinates decimal="." cs="," ts=" ">-143.9453125,-3.9453125 -56.0546875,83.9453125</gml:coordinates> 
       </gml:Box> 
      </ogc:BBOX> 
     </ogc:And> 
    </ogc:Filter> 
</wfs:Query> 
</wfs:GetFeature> 

이들은 라인 (2)에이 비트를 제외하고는 동일하다 :. .. xmlns : NS1 = ""NS1 : xmlns : feature = ... Geoserver에서 내 요청을 파싱 할 수 없으므로 문제입니다 (org.xml.sax.SAXParseException : 속성 값 "prefix ="xmlns ", localpart ="ns1 ", rawname ="xmlns : ns1 ""은 유효하지 않습니다. 접두사가 붙은 네임 스페이스 바인딩이 비어 있지 않을 수 있습니다.). 이것은 여러 종류의 WFS 피쳐 필터 (즉, 논리)에서도 발생하는 것으로 보입니다. 또한 IE11에서만 발생합니다. 요청은 Firefox 및 Chrome에서 실행될 때 올바르게 작성됩니다. 나는 GWT 2.5.1과 GWT-openlayers 1.0을 사용하고있다.
작동하도록해야하지만 IE에서이 비정상적인 동작을 일으키는 원인을 찾을 수 없습니다 ...

답변

2

이것은 IE11의 알려진 버그 인 것 같습니다.

자료 : http://osgeo-org.1560.x6.nabble.com/WFS-and-IE-11-td5090636.html

해결 일부 악성 텍스트 제거 하나 OpenLayers.Format.XML.write 방법을 덮어이다 (저자 : Stephen Battey 변형 krooole에서)

var _class = OpenLayers.Format.XML; 
var originalWriteFunction = _class.prototype.write; 

var patchedWriteFunction = function() { 
    var child = originalWriteFunction.apply(this, arguments); 

    // NOTE: Remove the rogue namespaces as one block of text. 
    child = child.replace(new RegExp('xmlns:NS\\d+="" NS\\d+:', 'g'), ''); 

    return child; 
} 

_class.prototype.write = patchedWriteFunction; 
+1

고맙습니다. 제 경우에도 도움이되었습니다. 링크를 더 이상 사용할 수없는 경우에 대비하여 해결 방법 코드를 인용해야합니다. – denu

0

다음 줄을 제거 할 때 작동합니까?

OpenLayers.setProxyHost("olproxy?targetURL="); 
+0

아니요 요청의 본문은 여전히 ​​도착 URL의 유효성과 무관하게 조작되지 않습니다. – Lorenzo