4 Replies Latest reply on Feb 9, 2015 6:50 AM by Sueleyman Vurucu

    Webservice Authentifaction from jsf app

    Sueleyman Vurucu Expert

      Hi guys,


      I have a strange situation here. I try to call a company internal webservice from microsoft navision. In java SE envorinment works everything as excpected. But if i try to call the same logic from a EJB then the webservice returns the response 401. So the authentifaction not works.


      I create the webservice with the maven plugin



      For the webservice client I follow the suggestions form this msdn blog.


      I assume that I modify the outgoing http request with user information.


      My environment:

      Wildfly 8.1.0.Final

      JDK 1.8 U 25


        • 1. Re: Webservice Authentifaction from jsf app
          Tomaz Cerar Master

          Start by marking dependency as provided








          • 2. Re: Webservice Authentifaction from jsf app
            Sueleyman Vurucu Expert

            Hı tomaz. Thanks for quick reply. I have this dependency not in my war project. I separate it in another jar project. But this dependency is transitive of course. I'll try it tomorrow. Thanks again.

            • 3. Re: Webservice Authentifaction from jsf app
              Sueleyman Vurucu Expert

              Hi Tomaz,


              that depependency is the plugin dependency and not project. The webserivce project has therefore no transitive dependencies.







                                      <id>Generate CustomerList</id>





                                          <!-- The name of your generated source package -->










                                            my url







                              <!-- if you want to use a specific version of JAX-WS, you can do so like this -->









              • 4. Re: Webservice Authentifaction from jsf app
                Sueleyman Vurucu Expert

                If I authentifacate the WS from Java SE then the Authenticator.getPasswordAuthentication is alled for every ws request. But in wildfly it called only once. Any ideas?


                    Authenticator.setDefault(new Authenticator() {
                        protected PasswordAuthentication getPasswordAuthentication() {
                            return new PasswordAuthentication(
                    URL url =  new URL("http://server:7047/DynamicsNAV/WS/S%20I%20E%20M%20A%20G/Page/CustomerList");
                    QName qNamePort = new QName("urn:microsoft-dynamics-schemas/page/customerlist", "CustomerList_Port");
                    QName qnameService = new QName("urn:microsoft-dynamics-schemas/page/customerlist", "CustomerList_Service");


                    Service service = Service.create(url,qnameService);
                    CustomerListPort port = service.getPort(qNamePort, CustomerListPort.class);


                //    BindingProvider prov = (BindingProvider) port;
                //    prov.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
                //            "user");
                //    prov.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
                //            "passwd");


                    CustomerListFilter customerListFilter = new CustomerListFilter();
                    List<CustomerListFilter> filters = new ArrayList<>();


                    CustomerListList customerListList = port.readMultiple(filters, null, 0);