4

I am using ol.format.WFS.writeTransaction() (OL3.5) to generate WFS-T statements. This works well for insert and delete. The problem is with the update statement.

Any update statement returns following exception from GeoServer:

<ows:Exception exceptionCode="NoApplicableCode">
<ows:ExceptionText>java.lang.StringIndexOutOfBoundsException: String index out of range: -1 String index out of range: -1</ows:ExceptionText>
</ows:Exception>

Edits via QGIS work as expected.

This is an example POST generated by OL3.5

<Transaction xmlns="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.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Update typeName="feature:playa_poly_noattribute" xmlns:feature="http://argeomatica.com">
    <Property>
      <Name>boundedBy</Name>
      <Value>-9693316.43121855,2347365.748407976,-9692555.877885746,2347961.5151853375</Value>
    </Property>
    <Property>
      <Name>geometry</Name>
      <Value>
        <Polygon xmlns="http://www.opengis.net/gml">
          <exterior>
            <LinearRing>
              <posList>-9693072.420357607 2347961.5151853375 -9693316.43121855 2347628.7731022364 -9692822.071552228 2347365.748407976 -9692555.877885746 2347758.700963257 -9692555.877885746 2347758.700963257 -9692737.951605482 2347825.076779921 -9692893.214319186 2347748.042587353 -9693072.420357607 2347961.5151853375</posList>
            </LinearRing>
          </exterior>
        </Polygon>
      </Value>
   </Property>
   <Filter xmlns="http://www.opengis.net/ogc">
     <FeatureId fid="playa_poly_noattribute.1"></FeatureId>
   </Filter>
 </Update>
</Transaction>
6

This is because boundedBy / bbox is a property that OpenLayers creates when parsing the GML, it is not a real feature property. So when you update, you should clone the feature and get rid of it. Some example code:

// do a WFS transaction to update the geometry
var properties = feature.getProperties();
// get rid of bbox which is not a real property
delete properties.bbox;
var clone = new ol.Feature(properties);
clone.setId(fid);

If you need more example code, here is the code we use in the OpenGeo Suite SDK for WFS-T: https://github.com/boundlessgeo/suite/blob/master/sdk/src/main/resources/client/ol3-common/app/TransactionHandler.js#L105:L110

  • Thanks Bart. That makes complete sense to me. I will only get to test this on Monday but I am sure that this will work. I will also have a read through the SDK code for future reference. I already used your excellent guide on the Boundless website to get started with WFS-T editing. Maybe you can add a quick note in regard to this issue in the section on updates. – Dennis Bauszus May 23 '15 at 18:29
  • Hi Bart, I just got around to test this. Works like a treat. Thanks again for your help. – Dennis Bauszus May 25 '15 at 16:46

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.