我已经在GeoServer上安装了WPS扩展。我已经使用GeoServer的WPS请求生成器生成了WPS请求。为此,我选择了process = gs:Bounds,过程输入= VECTOR_LAYER,并选择了我上载的任何一个矢量层,然后从WPS Request Builder选择了选项“从过程输入/输出生成XML”。生成一个XML文件后,并且我用.xml扩展名保存了我。我已经使用HTML,CSS和Java脚本创建了一个网站。现在,我想从网站访问此XML文件。我如何定义该代码?
获得XML之后,您只需要对其执行POST请求。例如:
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/xml");
var raw = `<?xml version="1.0" encoding="UTF-8"?>
<wps:Execute version="1.0.0" service="WPS"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.opengis.net/wps/1.0.0" xmlns:wfs="http://www.opengis.net/wfs"
xmlns:wps="http://www.opengis.net/wps/1.0.0"
xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml"
xmlns:ogc="http://www.opengis.net/ogc" xmlns:wcs="http://www.opengis.net/wcs/1.1.1"
xmlns:xlink="http://www.w3.org/1999/xlink"
xsi:schemaLocation="http://www.opengis.net/wps/1.0.0
http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
<ows:Identifier>gs:Bounds</ows:Identifier>
<wps:DataInputs>
<wps:Input>
<ows:Identifier>features</ows:Identifier>
<wps:Data>
<wps:ComplexData mimeType="application/json">
<![CDATA[${FEATURES_COLLECTION}]]>
</wps:ComplexData>
</wps:Data>
</wps:Input>
</wps:DataInputs>
<wps:ResponseForm>
<wps:RawDataOutput>
<ows:Identifier>bounds</ows:Identifier>
</wps:RawDataOutput>
</wps:ResponseForm>
</wps:Execute>`;
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("http://GEOSERVER_URL/wps", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
位置: