0

I am trying to activate a GeoServer OWS (WFS) service via the REST interface for a workspace.

In the GeoServer admin interface, there are two boxes to tick for enabling a service manually. One in the "Edit Workspace" page and one on the service page itself, as in the screenshots. Both need to be ticked to have the service enabled.

Edit Workspace page:

enter image description here

Service page:

enter image description here

I am able to enable the box on the service page via the REST call

PUT http://localhost:8080/geoserver/rest/services/wfs/workspaces/workspace/settings

sending this as the json body:

{"wfs":{"enabled":true}}

The problem is, I have to manually enable the WFS checkbox on the "Edit Workspace" page first, otherwise the REST call will return a 500 Internal Server Error.

How can I get the first checkbox ticked as well using a REST call?

4
  • 1
    did you try GETing the workspace before and after you changed it in the GUI to see what changed?
    – Ian Turton
    Jan 21, 2021 at 17:51
  • @IanTurton thanks! Yes I did that but there is no reference to the services. I also checked the settings.xml of that workspace on the server which does not change at all when I save that checkbox in the UI. For e.g. the settings/ contact info, it will change though. I wonder whether that checkbox is editable other than in the UI itself.
    – ulrich
    Jan 21, 2021 at 17:52
  • It will be stored somewhere (or GeoServer would forget it was checked) - try the workspace.xml rather than settings.xml
    – Ian Turton
    Jan 21, 2021 at 17:56
  • It is not in the workspace.xml either, had checked that. But, what changed is, when checking the box, it will create a wfs.xml in the workspace. So I guess I need to tell geoserver somehow to create that one.
    – ulrich
    Jan 21, 2021 at 18:03

1 Answer 1

0

I have managed to create a WFS service using the GeoServer REST API by sending the wfs.xml document to this URL:

PUT http:localhost:8080/geoserver/rest/services/wfs/workspaces/workspace/settings.xml

The wfs.xml stub looks basically like what GeoServer creates as wfs.xml in the workspace, just the workspace tag can be omitted and will be created by GeoServer.

<wfs>
  <id>wfs</id>
  <enabled>false</enabled>
  <name>WFS</name>
  <title>My WFS</title>
  ...
  <featureBounding>false</featureBounding>
  <canonicalSchemaLocation>true</canonicalSchemaLocation>
  <encodeFeatureMember>false</encodeFeatureMember>
  <hitsIgnoreMaxFeatures>false</hitsIgnoreMaxFeatures>
</wfs>

I found this process in the GeoServer test LocalWFSSettingsControllerTest.

Previously, I created the wfs.xml manually in the workspace folder, which will not have the same effect and did not create the WFS service correctly.

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.