我有一个盖瑟弗实例,它包含我们的数据。请通过GET工作正常,并返回预期的结果。但遗憾的是,它不适用于POST。
准确地说,下面是GET功能的请求,它返回一个有效的GetCapabilities Response:
http://myserver:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetCapabilities我用wget进行测试,所以命令如下所示:
wget -O wfs 'http://myserver:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetCapabilities'现在我尝试使用POST的功能-请求。我创建一个包含以下内容的请求(命名请求)的文件:
<GetCapabilities
service="WFS"
xmlns="http://www.opengis.net/wfs"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"/>我使用以下wget与Geoserver进行了竞争:
wget -O wfs --post-file=request 'http://myserver:8080/geoserver/wfs'但现在我得到了一个OWS例外:
<ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0.0" xsi:schemaLocation="http://www.opengis.net/ows/1.1 http://moa:8080/geoserver/schemas/ows/1.1.0/owsAll.xsd">
<ows:Exception exceptionCode="MissingParameterValue" locator="request">
<ows:ExceptionText>Could not determine geoserver request from http request org.geoserver.platform.AdvancedDispatchFilter$AdvancedDispatchHttpRequest@1e5c2cc</ows:ExceptionText>
</ows:Exception>
</ows:ExceptionReport>这看起来好像没有被发送过或者被忽略了。我在这里出什么错了?
编辑:好的,我解决了这个问题。问题是Geoserver需要一个内容类型标头来发布XML文件。因此正确的请求如下所示:
wget -O wfs --header='Content-Type: text/xml' --post-file=request.xml 'http://myserver:8080/geoserver/wfs'这将返回预期的结果。
发布于 2014-07-28 21:12:06
我试图调查你的案子,但我没有服务器,所以我用了http://demo.opengeo.org/geoserver/web/
GET测试: http://demo.opengeo.org/geoserver/wfs?service=wfs&version=1.1.0&request=GetCapabilities
我和你一样得到了全面的回应。
POST测试:我使用http://www.hurl.it/是因为我在Windows上。具有以下参数:
<GetCapabilities service="WFS" xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"/>
我得到了和GET版本一样的回应。
您能在这个演示服务器上尝试相同的测试吗?
更新
经过几个评论聊天,OP发现了自己的解决方案。POST调用缺少内容类型标头信息,这是强制性的。
https://stackoverflow.com/questions/24952960
复制相似问题