I'm trying to implement transactions for some queries to Geoserver. I'm using plain HTTP Post to make the requests, from Java.

One of those queries looks something like :

<wfs:Transaction service='WFS' version='1.0.0'                        


If all three inserts succeed, they are commited. If one fails, none are commited and something like this is returned :

<?xml version="1.0" ?>
   xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd">
      java.lang.RuntimeException: Parsing failed for DIAMETRE: java.lang.NumberFormatException
Parsing failed for DIAMETRE: java.lang.NumberFormatException

This is fine, but I'd like to know which one of those three inserts actually failed!

Is there a way to give each action of the transaction an id, and make Geoserver output it somewhere in the returned ServiceExceptionReport so I'm able to identify which action the error is related to?

Update : I'm currently using WFS 1.0.0. Maybe there are more options for transactions with a newer version?


From the WFS 1.1.0 specification which is freely available in the net:

Individual exception messages are contained within the element. The mandatory code attribute may be used to associate an exception code with the accompanying message. The optional locator attribute may be used to indicate where an exception was encountered in the request that generated the error. A number of elements defined in this document include a handle attribute that can be used to associate a mnemonic name with the element. If such a handle exists, its value may be reported using the locator attribute of the element. If the handle attribute is not specified, then a web feature server implementation may attempt to locate the error using other means such as line numbers, etc... Example The following is an example of an exception report. This exception indicates that the first insert statement failed because of a missing closing XML tag in the request.

 <?xml version="1.0" ?>
> <ExceptionReport version="1.1.0" xmlns="http://www.opengis.net/ogc"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="owsExceptionReport.xsd"> <Exception code="999"
> locator="INSERT STMT 01"> <ExceptionText>parse error: missing closing
> tag for element wkbGeom</ExceptionText> </Exception>

For me it looks like this Geoserver error message is not totally correct because the exception code is missing. However, it works as it should for the all-or-nothing atomic operations. WFS standard has another rule for non-atomic transactions:

The optional element is included to support systems that do not support atomic transactions3 raising the possibility of partially successful transactions. The contents of the element indicate which actions of a transaction request failed to complete successfully.

As far as I know, Geoserver is using the atomic strategy and the information that you are after is not available from the error messages.

  • Thanks user30184. Sadly, I think you may be right and Geoserver simply doesn't provide the "locator" information in its ServiceExceptionReports. I tried adding handle attributes to the Transaction element and to the Insert elements but nothing more is displayed in the returned response. – electrotype Jun 4 '14 at 17:45
  • 2
    You can verify by sending mail to geoserver-users. You can include all fine details with your question now. – user30184 Jun 4 '14 at 17:50
  • I fear that it would be hard to fill correct information into locator information even if it existed. Geoserver is sending requests with many inserts/updates/deletes for database backends as one transactions, and databases themselves tend either to accept transaction or make a rollback without sending details about what went wrong. It is quite possible that Geoserver itself will never know why the database did not accept the transaction. If you want to make system robust send each request inside own transaction. That will be slower, though. – user30184 Jun 4 '14 at 18:28
  • I don't mind sending each action in its own request, but what if I need all actions to be transactional between them? Is there a way to control the transaction externally? Like to open a transaction, send some requests, then commit the transaction or rollback it by myself? – electrotype Jun 4 '14 at 18:37
  • 1
    Not without programming as far as I know. We do use a system that captures the WFS messages and saves them as BLOBs into log tables, alters them a bit and makes transactions into one or several tables and after successful or failed operation tells Geoserver if it was success or not. Heavily tailored system and I am not sure if I would recommend it for anybody. – user30184 Jun 4 '14 at 18:48

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.