首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >来自IE11中GWT-开层的格式错误的WFS XMLHttpRequest

来自IE11中GWT-开层的格式错误的WFS XMLHttpRequest
EN

Stack Overflow用户
提问于 2014-01-21 10:15:29
回答 2查看 1.4K关注 0票数 0

我已经尝试过复制一个GWT开放层示例,其中包括WFS (这一个)。我保留了代码,并将其修改为一个简单的组合,而不是抽象示例,如下所示:

代码语言:javascript
复制
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
}
}

我部署了包含此面板的GWT应用程序,并在Internet 11上运行它。使用开发人员工具,我检查了WFS XMLHttpRequest,它要求具有指定id的特性。XML请求如下:

代码语言:javascript
复制
<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>

来自展示示例的相同请求如下所示:

代码语言:javascript
复制
<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.

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-01-22 12:27:22

这似乎是IE11中的一个已知错误。

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

解决方法是用一个删除一些流氓文本的方法覆盖OpenLayers.Format.XML.write方法(作者:斯蒂芬·巴蒂,从克鲁中修改):

代码语言:javascript
复制
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;
票数 2
EN

Stack Overflow用户

发布于 2014-01-21 10:51:38

删除以下行时,它是否有效?

代码语言:javascript
复制
OpenLayers.setProxyHost("olproxy?targetURL=");
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21255173

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档