1

I have a local server with a geoserver 2.7. I use python requests in order to add geometry in a postgis store. It works great. This is how it looks like:

headers = {'Content-Type': 'application/xml'}
url = 'http://localhost:8080/geoserver/gn/wfs'
xmlstr = """<wfs:Transaction service="WFS" version="1.1.0"
  xmlns:wfs="http://www.opengis.net/wfs"
  xmlns:gml="http://www.opengis.net/gml">
  <wfs:Insert>
   <dkar>
    <the_geom>
     <Point srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
      <pos>16.259765625 38.16911413556086</pos>
     </Point>
    </the_geom>
   </dkar>
 </wfs:Insert>

"""

status_code = requests.post(url, data=xmlstr, headers=headers, auth=('user', 'pass')).status_code

This worked fine but when I try to execute the same code on the server (with geoserver 2.5) I get an error:

No such feature type http://www.opengis.net/wfs:dkar

I did a DescribeFeature and I got:

<?xml version="1.0" encoding="UTF-8"?><xsd:schema    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:geonode="http://geonode.org/" xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified" targetNamespace="http://geonode.org/">
 <xsd:import namespace="http://www.opengis.net/gml" schemaLocation="http://staging.geonode.wfp.org:80/geoserver/schemas/gml/2.1.2/feature.xsd"/>
 <xsd:complexType name="dkarType">
 <xsd:complexContent>
  <xsd:extension base="gml:AbstractFeatureType">
    <xsd:sequence>
      <xsd:element maxOccurs="1" minOccurs="0" name="the_geom" nillable="true" type="gml:PointPropertyType"/>
      <xsd:element maxOccurs="1" minOccurs="0" name="countries" nillable="true" type="xsd:string"/>
      <xsd:element maxOccurs="1" minOccurs="0" name="numbers" nillable="true" type="xsd:int"/>
    </xsd:sequence>
  </xsd:extension>
 </xsd:complexContent>
</xsd:complexType>
<xsd:element name="dkar" substitutionGroup="gml:_Feature" type="geonode:dkarType"/>
</xsd:schema>

Any idea what can cause this error?

  • 1
    Your feature class is not in the WFS namespace. You need to use your workspace URI. – Ian Turton Aug 22 '16 at 17:42
  • I see. Thank you. But I don't understand why this is not necessary when in localserver. Why it makes a difference? – user1919 Aug 23 '16 at 14:42
  • 1
    there is probably a cross origin problem aswell – Ian Turton Aug 23 '16 at 15:12
1

As @iant suggested, I had to use my workspace URI (geonode) in order to make things work. But this wasn't not the only case. Upon adding the workspace name and the URI (copied from the Describe layer response) things were working fine in the remote server but not in the localserver.

I've noticed that the URI in localserver was slightly different from the one in the remote:

  localserver: namespace="http://opengis.net/gn
  remoteserver: namespace="http://www.opengis.net/gn

The way to solve this was to use Python and Requests to get the response of a Describe layer request, take the right URI and pass it in my add_feature request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.