Tuesday 1 January 2019

wfs t - Failed to insert data to geoserver layer with WFS-T


I am trying to make a POST request to geoserver in order to Insert a new feature. I am using the example provided by the Demo section of geoserver.


I have modified it as following:


  xmlns:wfs="http://www.opengis.net/wfs"

xmlns:geonode="http://www.openplans.org/geonode"
xmlns:gml="http://www.opengis.net/gml">







88.247354197,21.438097723 89.247354197,18.438097723






alley





When trying to execute it I get a message:


 Feature type 'bgd_uti_transmissionline_nrel' is not available:

Any idea why this is happening?


EDITED I tried to make a DescribeFeature request as:


  version="1.0.0"
service="WFS"
xmlns="http://www.opengis.net/wfs"
xmlns:topp="http://www.openplans.org/topp"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs http://www.opengis.net/wfs">
geonode:bgd_uti_transmissionline_nrel


I did the request through the Demo section of geoserver. I get nothing back. Checking the Developer's tools, I see the request is pending.


EDIT II


I did the DescribeFeature request using PYTHON Requests and I get something meaningful:



























When I tried to do the InsertFeature request using PYTHON Requests, I got this error:




Feature type 'bgd_uti_transmissionline_nrel' is not available:



Answer



There were two issues in my requests. The first one was related with the URL. Initially I was using this URL:


url = 'http://localhost:8080/geoserver/wfs'


Including my_workspace name in the URL is necessary for this WFS-T Insert (according to here):


url = 'http://localhost:8080/geoserver/my_workspace/wfs'

The second issue was related with the namespace I have defined: geonode In the end the xml I used looked like this:


 xmlns:wfs="http://www.opengis.net/wfs"
xmlns:gml="http://www.opengis.net/gml">








39.247354197,21.438097723 89.247354197,18.438097723










The rest of the request command (using PYTHON Requests lib) is straightforward:


headers = {'Content-Type': 'application/xml'}

print requests.post(url, data=xmlstr, headers=headers, auth=('geoserver_user', 'geoserver_pass')).text

The problem to solve now is how to pass non spatial data in the request. Meaning values of the attributes.



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...