2

I am trying to implement a transactional WFS. For now, I am only focusing on supporting the insert operation.

I have been able to successfully parse the insert XML posted by QGIS to my endpoint, but I am unable to create an output XML document to signal QGIS that the operation was successful. QGIS throws "Unhandled response: TransactionResponse" upon receiving my response. I have based the response schema on OGC's documentation and currently don't see a mismatch.

Below is an example input XML posted by QGIS.

<?xml version="1.0" encoding="UTF-8"?>
<Transaction xmlns="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://localhost:7554/?SERVICE=WFS&amp;REQUEST=DescribeFeatureType&amp;VERSION=1.0.0&amp;TYPENAME=ExampleLayerName" version="1.0.0" service="WFS">
    <Insert>
        <ExampleLayerName>
            <geom>
                <gml:Polygon srsName="EPSG:4326">
                    <gml:outerBoundaryIs>
                        <gml:LinearRing>
                            <gml:coordinates ts=" " cs=",">-67.41570626436781311,-20.93247614942528756 -67.44912965517241332,-21.50067379310344862 -66.94777879310343849,-20.96589954022988422 -67.41570626436781311,-20.93247614942528756</gml:coordinates>
                        </gml:LinearRing>
                    </gml:outerBoundaryIs>
                </gml:Polygon>
            </geom>
        </Distritos>
    </Insert>
</Transaction>

Below is the generated response XML by my endpoint.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<wfs:TransactionResponse xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:fes="http://www.opengis.net/fes/2.0"
    xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:ows="http://www.opengis.net/ows/1.1"
    xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0.0"
    xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://localhost:8080/geoserver/schemas/wfs/2.0/wfs.xsd">
    <wfs:TransactionSummary>
        <wfs:totalInserted>1</wfs:totalInserted>
        <wfs:totalUpdated>0</wfs:totalUpdated>
        <wfs:totalReplaced>0</wfs:totalReplaced>
        <wfs:totalDeleted>0</wfs:totalDeleted>
    </wfs:TransactionSummary>
    <wfs:InsertResults>
        <wfs:Feature>
            <fes:ResourceId rid="0" />
        </wfs:Feature>
    </wfs:InsertResults>
</wfs:TransactionResponse>

EDIT:

Part of the GetCapabilities document:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<wfs:WFS_Capabilities xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wfs/2.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0.0" updateSequence="1913">
    <ows:ServiceIdentification>
        <ows:Title>My WFS</ows:Title>
        <ows:Abstract>My WFS</ows:Abstract>
        <ows:ServiceType>WFS</ows:ServiceType>
        <ows:ServiceTypeVersion>2.0.0</ows:ServiceTypeVersion>
    </ows:ServiceIdentification>
    <ows:OperationsMetadata>
        <ows:Operation name="Transaction">
            <ows:DCP>
                <ows:HTTP>
                    <ows:Get xlink:href="http://localhost:7554/v1/wfs/"/>
                    <ows:Post xlink:href="http://localhost:7554/v1/wfs/"/>
                </ows:HTTP>
            </ows:DCP>
            <ows:Parameter name="inputFormat">
                <ows:AllowedValues>
                    <ows:Value>application/gml+xml; version=3.2</ows:Value>
                </ows:AllowedValues>
            </ows:Parameter>
            <ows:Parameter name="AcceptVersions">
                <ows:AllowedValues>
                    <ows:Value>2.0.0</ows:Value>
                </ows:AllowedValues>
            </ows:Parameter>
        </ows:Operation>
    </ows:OperationsMetadata>
</wfs:WFS_Capabilities>

2 Answers 2

4

It's hard to be sure but it looks like QGIS is sending a version 1.0.0 request and you are responding with a version 2.0 response. I would expect QGIS to become confused when you do that.

You need to negotiate the version with the client when it first requests the getcapabilities document.

6.2.4 Version number negotiation

An OWS Client may negotiate with a Service Instance to determine a mutually agreeable specification version. Negotiation is performed using the GetCapabilities operation [sec. 13] according to the following rules.

All Capabilities XML must include a protocol version number. In response to a GetCapabilities request containing a version number, a web feature service must either respond with output that conforms to that version of the specification, or negotiate a mutually agreeable version if the requested version is not implemented on the server. If no version number is specified in the request, the server must respond with the highest version it understands and label the response accordingly.

Version number negotiation occurs as follows:

If the server implements the requested version number, the server must send that version. If the client request is for an unknown version greater than the lowest version that the server understands, the server must send the highest version less than the requested version. If the client request is for a version lower than any of those known to the server, then the server must send the lowest version it knows. If the client does not understand the new version number sent by the server, it may either cease communicating with the server or send a new request with a new version number that the client does understand, but which is less than that sent by the server (if the server had responded with a lower version). If the server had responded with a higher version (because the request was for a version lower than any known to the server), and the client does not understand the proposed higher version, then the client may send a new request with a version number higher than that sent by the server. The process is repeated until a mutually understood version is reached, or until the client determines that it will not or cannot communicate with that particular server.

Example 1: Server understands versions 1, 2, 4, 5 and 8. Client understands versions 1, 3, 4, 6, and 7. Client requests version 7. Server responds with version 5. Client requests version 4. Server responds with version 4, which the client understands, and the negotiation ends successfully.

Example 2: Server understands versions 4, 5 and 8. Client understands version 3. Client requests version 3. Server responds with version 4. Client does not understand that version or any higher version, so negotiation fails and client ceases communication with that server.

5
  • I see that the input document from QGIS indeed states WFS version 1.0.0. I added part of my GetCapabilities document in my question. As far as I know, the document negotiates for only 2.0.0, but QGIS still somehow puts 1.0.0 in. Maybe my GetCapabilities document is incorrect?
    – Minghai
    Nov 5, 2020 at 13:25
  • QGIS should only pick a version listed in your capabilities document
    – Ian Turton
    Nov 5, 2020 at 13:29
  • It may be that QGIS can do transactions only with WFS 1.0.0 so it might be best to stay with that all the time. But I just found a document that can be useful gist.github.com/SKalt/0f4b757209687331c8a1d40aecbf69f9.
    – user30184
    Nov 5, 2020 at 13:35
  • It seems that QGIS indeed only supports WFS-T 1.0.0. Source. I am going to create a WFS-T 1.0.0 response and see if that works.
    – Minghai
    Nov 5, 2020 at 14:30
  • I just did this and QGIS seems to find my response satisfactory. Thanks everyone for your help!
    – Minghai
    Nov 5, 2020 at 14:49
1

It seems that QGIS as of version 3.14.0-Pi, does not support WFS-T 2.0.0 yet (Source). Even though my WFS advertised to support only WFS 2.0.0, QGIS simply attempts to use WFS 1.0.0.

After I changed my response to a WFS 1.0.0 compliant response (Specification), QGIS stopped throwing errors after posting the transaction.

Below is an example response my endpoint created for WFS 1.0.0:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<wfs:WFS_TransactionResponse version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs"
    xmlns:ogc="http://www.opengis.net/ogc">
    <wfs:TransactionResult>
        <wfs:Status>
            <wfs:SUCCESS />
        </wfs:Status>
    </wfs:TransactionResult>
    <wfs:InsertResult>
        <ogc:FeatureId fid="62f617c3-22f0-40a7-9f64-9fd8b0ff11c2" />
    </wfs:InsertResult>
</wfs:WFS_TransactionResponse>

Thanks to Ian Turton and user30184 for their observations.

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.