发送xml文件出现 org.xmlpull.v1.XmlPullParserException: processing instruction can not have PITarget with reserveld xml name (position: START_DOCUMENT seen \n <?xml ... @2:13) \nprocessing instruction can not have PITarget with reserveld xml name (position: START_DOCUMENT seen \n <?xml ... @2:13) </ows:ExceptionText>\n问题
在发送xml请求的时候,返回的是如下图所示的情况。

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<ows:ExceptionReport
xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"
xmlns:ows=\"http://www.opengis.net/ows\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" version=\"1.0.0\" xsi:schemaLocation=\"http://www.opengis.net/ows http://localhost:8080/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd\">\n
<ows:Exception exceptionCode=\"NoApplicableCode\">\n
<ows:ExceptionText>org.xmlpull.v1.XmlPullParserException: processing instruction can not have PITarget with reserveld xml name (position: START_DOCUMENT seen \\n <?xml ... @2:13) \nprocessing instruction can not have PITarget with reserveld xml name (position: START_DOCUMENT seen \\n <?xml ... @2:13) </ows:ExceptionText>\n
</ows:Exception>\n
</ows:ExceptionReport>
解决方法
看一下我们发送的xml请求
<?xml version="1.0" ?>
<wfs:Transaction
version="2.0.02.0.2"
service="WFS"
xmlns="http://www.someserver.example.com/myns"
xmlns:fes="http://www.opengis.net/fes/2.0"
xmlns:wfs="http://www.opengis.net/wfs/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs/2.0
http://schemas.opengis.net/wfs/2.0.02.0/wfs.xsd">
<wfs:Update typeName="BuiltUpA_1M">
<wfs:Property>
<wfs:ValueReference>population</wfs:ValueReference>
<wfs:Value>4070000</wfs:Value>
</wfs:Property>
<fes:Filter>
<fes:ResourceId rid="BuiltUpA_1M.10131"/>
</fes:Filter>
</wfs:Update>
</wfs:Transaction>
可以看到xml文件的内容并没有进行闭合

可以删除首行解决
<?xml version="1.0" ?>
网友评论