4

Client: OpenLayers / Server: Geoserver

When I update a WFS Element,

JAVASCRIPT:

element.feature.attributes.ENAME = "Mystring";
saveStrategy.save();

HTTP-POST:

 <wfs:Property>
  <wfs:Name>ENAME</wfs:Name>
  <wfs:Value>MyString</wfs:Value>
</wfs:Property>

some features of Type String do not get fully updated, only the first letter ends up in the WFS layer.

<wfs:FeatureCollection ...>
    ...
   <Project:ENAME>
       M
   </Project:ENAME>
</wfs:FeatureCollection>
//only M ends up on the server, not Mystring as expected

the respective line in the logfile (catalina.out) says:

        name = ENAME
        value = Mystringproperty[0]:

strangely, the attached property[0] is on all attributes, not only on the one which is reduced to its first letter, but also on some strings that do not get shortened as well as some integers.

I would expect the type of the respective feature to be something like String[1], but as far as I can see the Type System, there are no length attributes to Strings.

Who knows what I can do?


UPDATE


When I change the value of any feature's attribute (ENAME) with OpenJump and upload the changed data, my application shows the feature correctly, which means, the geoserver itself CAN store a string longer than 1 in the respective attribute.

However, everytime I make an update via OpenLayers, regardless on which feature, any other feature's ENAME attribute gets shortened (like from 'MyString' to 'M'), even if it was a totally different feature that was updated on OpenLayers.

The log (catalina.out) says NOTHING about this perfidious update operation.


UPDATE


Content of the Firebug Post TAB, Content of the respective Log Section:

<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/WFS-transaction.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <wfs:Update typeName="feature:Graeber" xmlns:feature="myserver.de/ah_neu"> <wfs:Property> <wfs:Name>the_geom</wfs:Name> <wfs:Value> <gml:MultiPolygon xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:31466"> <gml:polygonMember> <gml:Polygon> <gml:outerBoundaryIs> <gml:LinearRing> <gml:coordinates decimal="." cs="," ts=" ">363261.475316,5770742.697063 363260.253031,5770742.452777 363260.011425,5770743.66165201 363261.233711,5770743.90593801 363261.475316,5770742.697063</gml:coordinates> </gml:LinearRing> </gml:outerBoundaryIs> </gml:Polygon> </gml:polygonMember> </gml:MultiPolygon> </wfs:Value> </wfs:Property> <wfs:Property> <wfs:Name>LAYER</wfs:Name> <wfs:Value>Grab</wfs:Value> </wfs:Property> <wfs:Property> <wfs:Name>GRABNAME</wfs:Name> <wfs:Value>Huber</wfs:Value> </wfs:Property> <wfs:Name>NUTZENDE</wfs:Name> <wfs:Value>2023-07-14</wfs:Value> </wfs:Property> <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc"> <ogc:FeatureId fid="Graeber.203"></ogc:FeatureId> </ogc:Filter> </wfs:Update> </wfs:Transaction>

2015-01-20 17:01:00,671 INFO [geoserver.wfs] - Request: transaction service = WFS version = 1.1.0 baseUrl = http://myserver.de:80/geoserver/ group[0] = wfs:update=net.opengis.wfs.impl.UpdateElementTypeImpl@53a7e8d6 (filter: [ Graeber.203 ], handle: null, inputFormat: <unset>, srsName: null, typeName: {myserver.de/ah_neu}Graeber) update[0]: property[0]: name = the_geom value = MULTIPOLYGON (((363248.39039900305 5770772.417071999, 363249.21531199943 5770770.058744, 363248.0047730003 5770769.655668, 363248.0010000006 5770769.667, 363247.17900000024 5770772.016999999, 363248.39039900305 5770772.417071999)))property[0]: name = LAYER value = Grabproperty[0]: name = GRABNAME value = Huberproperty[0]: name = NUTZENDE value = 2023-07-14 filter = [ Graeber.203 ] inputFormat = x-application/gml:3 typeName = {myserver.de/ah_neu}Graeber releaseAction = ALL


STILL not solved

WFS Layer:


<xsd:schema elementFormDefault="qualified" targetNamespace="myserver.de/ah_neu"> <xsd:import namespace="http://www.opengis.net/gml" schemaLocation="http://myserver.de/geoserver/schemas/gml/2.1.2/feature.xsd"/> <xsd:complexType name="GraeberType"> <xsd:complexContent> <xsd:extension base="gml:AbstractFeatureType"> <xsd:sequence> <xsd:element maxOccurs="1" minOccurs="0" name="the_geom" nillable="true" type="gml:MultiPolygonPropertyType"/> <xsd:element maxOccurs="1" minOccurs="0" name="LAYER" nillable="true" type="xsd:string"/> <xsd:element maxOccurs="10" minOccurs="0" name="GRABNAME" nillable="true" type="xsd:string"/> <xsd:element maxOccurs="1" minOccurs="0" name="NUTZENDE" nillable="true" type="xsd:dateTime"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> <xsd:element name="Graeber" substitutionGroup="gml:_Feature" type="ah_neu:GraeberType"/> </xsd:schema>

Javascript definition:

layer_selectable = new OpenLayers.Layer.Vector("WFS", { strategies : [new OpenLayers.Strategy.BBOX(), saveStrategy], styleMap: new OpenLayers.StyleMap({ 'default': style, 'select': style_selected }), protocol : new OpenLayers.Protocol.WFS({ url : geoserver + config.wfs_layer, version : "1.1.0", featureType : "Graeber", featureNS : config.featureNS, srsName : epsg, }), renderers : renderer //tileOptions: {crossOriginKeyword: 'anonymous'} });

11
  • 1
    What does the schema of the feature type report about this attribute? You can read is with DescribeFeatureType request.
    – user30184
    Commented Jan 12, 2015 at 13:14
  • It says simply: <xsd:element maxOccurs="1" minOccurs="0" name="ENAME" nillable="true" type="xsd:string"/>
    – Lokomotywa
    Commented Jan 12, 2015 at 16:24
  • 1
    try turning the logging level up to see more info in the log file.
    – Ian Turton
    Commented Jan 19, 2015 at 13:12
  • 1
    That XSD definition is potentially your problem. Can you change it? An XSD element definition tells your XML Parser how it should handle the inbound XML tag by the given element name when it is found in any XML data it's dealing with. In your case the maxOccurs="1" and minOccurs="0" should mean that the string appears at most once, but may not be present at all, I have seen some parsers that get that horribly wrong and intemperate it as min 0 chars in length, max 1 char in length. If you can change the max to something like 10, then retest, and if you get 10 chars then you have a dodgy parser.
    – shawty
    Commented Jan 19, 2015 at 13:37
  • 1
    In theory, nothing. GeoServer should behave like a black box and layers coming from shapefiles should behave just like PostGIS or Oracle layers. In real life, for WFS-T, this is not true.
    – user30184
    Commented Jan 21, 2015 at 15:02

6 Answers 6

1
+50

You could edit your WFS-T Service directly with QGIS for example to see if it's an error of your javascript-application or of geoserver itself.

http://docs.qgis.org/2.2/en/docs/user_manual/working_with_ogc/ogc_client_support.html section "WFS and WFS-T Client" ( or in german: "QGIS als OGC Datenclient")

In QGIS you could also check which limit is set for the character-length of the column that gets cut off (in Layer-Properties):

feldlaenge

Have you considered importing the shapefile to postgis and then publish the layer directly from an postgis-store?

If you like to you can post the javascript-code on http://jsfiddle.net/ or http://www.codeshare.io/

The Content of the Firebug Post TAB and Content of the respective Log Section you posted shows different versions(1.0.0 vs. 1.1.1):

<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0"
and logfile:
2015-01-20 17:01:00,671 INFO [geoserver.wfs] - 
Request: transaction
    service = WFS
    version = 1.1.0

but I guess these were two different tries, weren't it?

9
  • yes, it were two different tries. Thanks a lot, I will check your promising hint tomorrow.
    – Lokomotywa
    Commented Jan 20, 2015 at 17:20
  • I try to edit my WFS-T Service directly with QGIS, but everytime I want to save my changes, I get an Commit errors: Could not commit changes to layer ah_neu:Graeber.
    – Lokomotywa
    Commented Jan 21, 2015 at 10:44
  • Thus, I cannot perform any update from QGIS, but I am pretty sure it does not have anything to do with Javascript - since it has the same outcome when I repeat the update from OpenLayers with a simple request from hurl.it . I think it has something to do with the geoserver itself.
    – Lokomotywa
    Commented Jan 21, 2015 at 10:55
  • In QGIS, the limit set for the character-length of the column that gets cut off, is set as the maximum length of the values that exists in the column, so if I increase the lenght of the value, the character-length increases as well. Says nothing about the cut-off.
    – Lokomotywa
    Commented Jan 21, 2015 at 10:58
  • The output of the geosever logfile is here: gis.stackexchange.com/questions/131137/…
    – Lokomotywa
    Commented Jan 21, 2015 at 11:25
1

have you tried to switch to a different WFS-version in your OpenLayers-Code before?

var wfsLayer = new OpenLayers.Layer.Vector(
    "Name", {
        strategies: [new OpenLayers.Strategy.Fixed()],
        protocol: new OpenLayers.Protocol.WFS({
            version: "1.0.0",
            url: "http://localhost/geoserver/wfs",
            featureType: "layername",
            srsName:"EPSG:900913",
            featureNS: "http://yournamespaceadress.org"
            //,geometryName: "geom"
        })
});

and could you please post the Content of Firebug/Network-Tab/Post-Tab? (see image) Firebug Network Tab Output

1
  • I just changed from version: "1.1.0" to version: "1.0.0", but that did not have any effect. I just inserted the content of the Firebug Post Tab above in the main section.
    – Lokomotywa
    Commented Jan 20, 2015 at 15:37
1

ok, then I would suggest two steps:

Reload Featuretype (in the layers-settings)

reload feature type

And right after an insert check the logfile within the Geoserver WebUI. There you should find informations about the wfs insert: (screenshot from geoserver with default logging properties): enter image description here

and one more question: when you used OpenJump did you edit the PostGIS-Layer or directly the WFS-T-Layer?

3
  • Reload FeatureType - done multiple times, no effect.
    – Lokomotywa
    Commented Jan 20, 2015 at 16:03
  • wfs insert section from the logs: see above:
    – Lokomotywa
    Commented Jan 20, 2015 at 16:04
  • I am not familiar enough with the whole thing to answer your question about openJump, but what I do is opening the shp File of the layer and then "View / Edit attributes".
    – Lokomotywa
    Commented Jan 20, 2015 at 16:13
1

You could try following: make sure that you don't use your workspace prefix in the geoserver-url

http://myserver.de:80/geoserver/wfs instead of something like
http://myserver.de:80/geoserver/ah_neu/wfs

and add some more parameters like the schema:

// version 1.1.1

layer_selectable = new OpenLayers.Layer.Vector("WFS", {
        strategies : [new OpenLayers.Strategy.BBOX(), saveStrategy],
        styleMap: new OpenLayers.StyleMap({
            'default': style,
            'select': style_selected }),
        protocol : new OpenLayers.Protocol.WFS({
            //url : geoserver + config.wfs_layer,
            url: "http://yourserver:yourport/geoserver/wfs"
            version : "1.1.0",
            featureType : "Graeber",
            featureNS : config.featureNS,
            srsName : epsg,
            featurePrefix: "ah_neu", // your workspace Alias
            geometryName: "geom",
            schema: "http://yourserver:yourport/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=ah_neu:Graeber"
        }),
        renderers : renderer
        //tileOptions: {crossOriginKeyword: 'anonymous'}
    });


// or as version 1.0.0




layer_selectable = new OpenLayers.Layer.Vector("WFS", {
        strategies : [new OpenLayers.Strategy.BBOX(), saveStrategy],
        styleMap: new OpenLayers.StyleMap({
            'default': style,
            'select': style_selected }),
        protocol : new OpenLayers.Protocol.WFS({
            //url : geoserver + config.wfs_layer,
            url: "http://yourserver:yourport/geoserver/wfs"
            version : "1.0.0",
            featureType : "Graeber",
            featureNS : config.featureNS,
            srsName : epsg,
            featurePrefix: "ah_neu", // your workspace Alias
            geometryName: "geom", // your geom name (listed in layer-Properties in Geoserver)
            schema: "http://yourserver:yourport/geoserver/wfs/DescribeFeatureType?version=1.0.0&typename=ah_neu:Graeber"
        }),
        renderers : renderer
        //tileOptions: {crossOriginKeyword: 'anonymous'}
    });

Does this make a difference?

4
  • What I get is: Layer is not even loaded, WFS Request says: <ows:Exception exceptionCode="InvalidParameterValue"> <ows:ExceptionText>Illegal property name: geom</ows:ExceptionText> </ows:Exception>
    – Lokomotywa
    Commented Jan 22, 2015 at 16:03
  • I omitted the line geometryName: "geom",. Now, I get the same result as before. After updating and reloading, the string attributes get reduced to their first letter.
    – Lokomotywa
    Commented Jan 22, 2015 at 16:06
  • 1
    have you tested both versions (1.0.0 and 1.1.1) in your OpenLayers-App?
    – Thomas B
    Commented Jan 22, 2015 at 16:09
  • yes. They both have the same result.
    – Lokomotywa
    Commented Jan 22, 2015 at 16:18
1

well strange thing...

what you could check is the featurestate... or just make a copy of the shapefile, delete your sensitiv/confidential data if neccessary ,insert two/three dummy-features and send me the file. Then I could give it a try.

here the code:

layer_selectable.events.register("loadend",map,function()
 {
     //layer_selectable.events.register("beforefeatureadded",map,testfunktion );
     layer_selectable.events.register("featureadded",map,testfunktion2
     );
 }
 );

 layer_selectable.events.register("loadstart",map,function()
 {
 //layer_selectable.events.unregister("beforefeatureadded",map, testfunktion);
 layer_selectable.events.unregister("featureadded",map, testfunktion2);
 }
 );


// set a global variable for debugging

 var globalevariable;


 function testfunktion2(feature)
 {
 globalevariable=feature;

//feature.state = OpenLayers.State.INSERT;

// check featurestate and eventually set the correct featurestate
console.log(feature.state);
 }
2
  • thanks a lot, just pass me a mail address, I gladly send you my shape files.
    – Lokomotywa
    Commented Jan 23, 2015 at 9:52
  • Concerning the feature state: I am pretty sure that the Javascript part does not cause any problem. The Feature's attributes are set correctly from javascript (Grabname = 'Huber' in my example). Only after reloading from geoserver, Grabname is shortened to 'H'.
    – Lokomotywa
    Commented Jan 23, 2015 at 9:57
0

I finally solved the problem, but I have no idea what exactly was the cause. After I added another attribute to the feature with QGIS, the problem disappeared. Now, any of the attributes that were shortened after every OpenLayers Update, remain in their original length. This means, the problem must have been caused by OpenJump, with which I created the string attributes. It turned out, that even a simple save operation with QGIS solved the problem. No clue why, but, hey, it is solved. Must be a bug in OpenJump 1.8.0. The bounty goes to Thomas who showed my QGIS.

Your Answer

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

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