I'm trying to retrieve data from remote WFS server which requires basic https authentication using GeoTools. I defined connection parameters for username and password like

connectionParameters.put("WFSDataStoreFactory:USERNAME", "username" );
connectionParameters.put("WFSDataStoreFactory:PASSWORD", "pass" );

However I get

"Server returned HTTP response code: 401 for URL: http://...".

What is the solution for basic https authentication in GeoTools WFS support.

  • 1
    try turning logging up and see if that shows you what is sent
    – Ian Turton
    Commented Dec 15, 2014 at 8:27
  • Can you show how you're applying the connectionParameters?
    – BradHards
    Commented Dec 15, 2014 at 9:54
  • For connectionParameters: Map connectionParameters = new HashMap(); Commented Dec 16, 2014 at 6:22
  • I get: IOException: Server returned HTTP response code: 500 for URL: wfsserver/wfs (unfortunately I had to change wfs server name) and IOException: org.xml.sax.SAXException: Server returned HTTP response code: 401 for URL: wfsserver/… (unfortunately I had to change wfs server name) Commented Dec 16, 2014 at 6:34
  • I have the same case that you report. I have a connection with basicAuthentication, the getCapabilities and getFeatureStore return me correct data but when i try to commit a transaction I get the next exception: "HTTP response code:401 for url ...." Here's my code: public boolean anadirIncidencia(String getCapabilities, String capa, SimpleFeature incidencia, String username, String password) throws Exception { boolean b = false; Map connectionParameters = new HashMap(); connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL", getCapabilities); connectionParameters.put("WFSDataStore
    – Dani
    Commented May 21, 2015 at 10:57

1 Answer 1


I can recreate this response from a local GeoServer but only when I send a connection request to a GeoServer that doesn't have a user of the name requested. When I have set up a user then it works exactly as I expect.

With regards to @Dani's comment I don't get a FeatureStore which is expected as the WFSStore doesn't support writes when you use version 1.1.0. For version 1.0 it works as expected when the user exists on the server.

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.