EGL Development User Group

  • 1.  NTLM authentication to a web service

    Posted Fri January 22, 2016 07:42 AM

    I have a requirement to communicate with Microsoft Dynamics Nav web services from our EGL Web Service application, deployed to Websphere.

    The MS web services have NTLM authentication activated.


    Is there any way to do NTLM authentication to a service?


    Kind regards,




  • 2.  Re: NTLM authentication to a web service

    Posted Wed January 27, 2016 03:05 AM

    Does anyone know?

    Is there any RFE for this?

    Should I use Java external types to accomplish this?


    Kind regards,




  • 3.  Re: NTLM authentication to a web service

    Posted Mon February 22, 2016 09:01 AM

    I've had a small success in java connecting to an ntlm web service in from microsoft navision.

    I've had to use axis2 for this.


    The plan is to use java externaltypes to wrap the web service calls an write our logic in egl, keeping EGL as the standard, central application.

    I've noticed our current egl webservices project uses axis instead of axis2.

    • Does anyone know how these libraries are selected?
    • Is it possible to use the axis2 libraries for my externaltypes without conflicting with the default egl project axis libraries?

    Thanks for any help!

    Kind regards,






  • 4.  Re: NTLM authentication to a web service

    Posted Tue February 23, 2016 06:58 PM

    Hi, Bram. Which server do you use? In tocmat, Jaxrpc use axis and Jaxws use axis2, you can change the service runtime in dd file.




  • 5.  Re: NTLM authentication to a web service

    Posted Wed February 24, 2016 02:23 AM

    Hi Jerry,


    Thanks for the clarification on axis and axis2. It makes sense now.


    We are using tomcat and jax-rpc. We need jax-rpc because a jax-ws does not seem to work with an external service we are consuming.

    I have found a work around, using axis 1 and the deprecated commons http client version 3.1: 


    public void test() throws ServiceException, RemoteException{        Customers_ServiceLocator cl = new Customers_ServiceLocator(getEngineConfiguration());        Customers_Port cp = cl.getCustomers_Port();         ((Stub) cp).setUsername("domain\\username");         ((Stub) cp).setPassword(password);         Customers_Filter cf = new Customers_Filter();         cf.setField(Customers_Fields.Name);         cf.setCriteria("AS*"); // all customers starting with AS        Customers_Filter[] filters = {cf};        Customers[] custs = cp.readMultiple(filters, "", 100);        for (Customers c : custs){                System.out.println(c.getName());         }}public static org.apache.axis.EngineConfiguration getEngineConfiguration() {        java.lang.StringBuffer sb = new java.lang.StringBuffer();        sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");        sb.append("<deployment name=\"defaultClientConfig\"\r\n");        sb.append("xmlns=\"\"\r\n");        sb.append("xmlns:java=\"\">\r\n");        sb.append("<globalConfiguration>\r\n");        sb.append("<parameter name=\"disablePrettyXML\" value=\"true\"/>\r\n");        sb.append("<parameter name=\"enableNamespacePrefixOptimization\" value=\"true\"/>\r\n");        sb.append("</globalConfiguration>\r\n");        sb.append("<transport name=\"http\" pivot=\"java:org.apache.axis.transport.http.CommonsHTTPSender\"/>\r\n");        sb.append("<transport name=\"local\" pivot=\"java:org.apache.axis.transport.local.LocalSender\"/>\r\n");        sb.append("<transport name=\"java\" pivot=\"\"/>\r\n");        sb.append("</deployment>\r\n");        return new org.apache.axis.configuration.XMLStringProvider(sb.toString());}

    Hopefully we will be able to use jax-ws in the future, and migrate to axis2. We can then ommit the deprecated commons http client and use proper authentication to the ntlm web service:

            public static void main(String[] args) throws RemoteException {                Customers_ServiceStub cs = new Customers_ServiceStub();                setOptions(cs._getServiceClient().getOptions());                                 ReadMultiple rm = new ReadMultiple();                Customers_Filter filter = new Customers_Filter();                Customers_Fields cf = Customers_Fields.No;                 filter.setField(cf);                filter.setCriteria("AS*");                 Customers_Filter[] arr = {filter};                 rm.setFilter(arr);                 ReadMultiple_Result result = cs.readMultiple(rm);                 Customers_List listResults = result.getReadMultiple_Result();                 Customers[] customers = listResults.getCustomers();                 for(Customers cust : customers){                        System.out.println(cust.getName());                 }        }                private static void setOptions(Options options){                  Authenticator auth = new Authenticator();                  auth.setUsername(username);                auth.setPassword(password);                auth.setDomain(domain);                auth.setHost(host);             List<String> authSchemes = new ArrayList<String>();              authSchemes.add(Authenticator.NTLM);               auth.setAuthSchemes(authSchemes);                                            options.setProperty(HTTPConstants.AUTHENTICATE, auth);                options.setProperty(HTTPConstants.CHUNKED, "false");                    } 

    I hope this can help someone in the future.


    Kind regards,




  • 6.  Re: NTLM authentication to a web service

    Posted Tue March 01, 2016 12:31 AM



  • 7.  RE: NTLM authentication to a web service

    Posted Mon June 06, 2022 09:48 AM
    Did you get the solution for this? , if yes can you share with me?.

    Muhammed ali

  • 8.  RE: NTLM authentication to a web service

    Posted Mon June 06, 2022 02:07 PM
    Hello Bram and Mohamed.

    A hint. I did some authentication work via WebServices, but I used EGL with external type, calling Native Java, because it was a lot of work and it was taking a long time to solve the solution using only EGL.

    Osvaldo Menezes
    @Osvaldo Jose de Oliveira Menezes

    Osvaldo Jose de Oliveira Menezes
    +55 16 3818-0203