1

Here is the code block (the layers are stored in Oracle database):

var saveStrategy = new OpenLayers.Strategy.Save();

var adresspt_wfs = new OpenLayers.Layer.Vector("Address points WFS", {
     strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],
        protocol: new OpenLayers.Protocol.WFS({
        url: "http://localhost:8080/geoserver/wfs",
        featureType: "RAILWAY",
        featureNS: "http://localhost:8080/MIA",
        srsName: "EPSG:900913",
        geometryName: "SDO_GEOMETRY"
      })
    });

map.addLayer(adresspt_wfs);   

Please correct me if I'm wrong: It adds new vector layer "Address points WFS", on which we can edit/delete/add some vector objects. After save all that will be saved RAILWAY table as a geometry objects in SDO_GEOMETRY column using WFS service, that is part of GeoServer (in my case I use GeoServer)... Is that right?

Also, I don't quite understand what is "featureNS" and where to find the proper one for my layer.

If I open: http://localhost:8080/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=MIA:RAILWAY in address bar, the browser hangs on opening that schema...

MIA is my default workspace, its URI is http://localhost:8080/MIA

I've tried many configurations for initializing the WFS protocol, but can't save drawn geometry into database... Please show me what am I doing wrong during this initialization.

Please consider that I'm completely new to "geo" programming.

1
  • could you find the solution? Jul 10, 2016 at 9:25

2 Answers 2

10

Take a look at this code example:

var adresspt_wfs = new OpenLayers.Layer.Vector("Address points WFS", {
 strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],
    protocol: new OpenLayers.Protocol.WFS({
    url: "http://localhost:8080/geoserver/wfs",
    featurePrefix: "XXXX" //<-- GeoServer workspace name
    featureType: "RAILWAY",//<-- layer name
    featureNS: "http://localhost:8080/MIA", //<-- Edit Workspace Namespace URI
    srsName: "EPSG:900913",
    geometryName: "SDO_GEOMETRY" //<-- geometry field
  })
});

The featureNS property is equivalent to your Namespace URI in the Edit Workspace page of GeoServer:

enter image description here

Here's a tutorial

2
  • Did everything as you wrote, but request timed out. If i try to open domain:8080/geoserver/wfs i get schema with exception: <ows:Exception exceptionCode="MissingParameterValue" locator="request"> <ows:ExceptionText> Could not determine geoserver request from http request org.geoserver.platform.AdvancedDispatchFilter$AdvancedDispatchHttpRequest@3f40a025 </ows:ExceptionText> </ows:Exception>
    – 0x49D1
    Mar 7, 2012 at 6:33
  • ..Think i have some problems with reverse proxy.
    – 0x49D1
    Mar 7, 2012 at 8:22
1

As CaptDragon says it is the namespace for the features returned by the server.

As a sample if you make a request to the open server 'http://demo.opengeo.org/geoserver/wfs'

you will get a XML (a GML file) like:

<?xml version="1.0" encoding="UTF-8"?>
<wfs:FeatureCollection 
    xmlns="http://www.opengis.net/wfs" 
    xmlns:wfs="http://www.opengis.net/wfs"     
    xmlns:topp="http://www.openplans.org/topp"  <--- THIS !!!
    xmlns:gml="http://www.opengis.net/gml" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.openplans.org/topp 
    http://demo.opengeo.org/geoserver/wfs?service=WFS&amp;version=1.0.0&amp;request=DescribeFeatureType&amp;typeName=topp%3Astates http://www.opengis.net/wfs http://demo.opengeo.org/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd">

<topp:the_geom>  <--- YOUR GEOM IS WITHIN THE topp Namespace
   <gml:MultiPolygon srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
       <gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing>
          <gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">-88.071564,37.51099 -88.087883,37.476273 -88.311707,37


    <gml:boundedBy>
        <gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">       
            <gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">-124.731422,24.955967 

As you can see your the requestes features are named "topp:the_geom".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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