简体   繁体   English

使用Java使用NTML身份验证在Navision Web服务上调用方法

[英]call a method on Navision webservice using NTML authentication using Java

I've created a SOAP web-service client on Netbeans. 我已经在Netbeans上创建了一个SOAP Web服务客户端。 The web-service is exposed on Navision with NTML authentication. 该Web服务在具有NTML身份验证的Navision上公开。 During class generation, a login pop-up picks the required credentials and uses them for authentication. 在类生成期间,登录弹出窗口会选择所需的凭据并将其用于身份验证。 The issue is once the classes are generated and I try to invoke any method; 问题是一旦生成了类,我就尝试调用任何方法。

    ServicePort webservice_port = new WService().getServicePort();
    webservice_port.retrieveData();

I get an exception. 我有一个例外。

java.io.IOException: Server returned HTTP response code: 401 for URL: ...

Exception in thread "main" com.sun.xml.ws.wsdl.parser.InaccessibleWSDLException: 2 counts of InaccessibleWSDLException.
    at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:275)
    at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:246)
    at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:209)
    at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:178)
    at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:363)
    at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:321)
    at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:230)
    at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:211)
    at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:207)
    at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:114)
    at javax.xml.ws.Service.<init>(Service.java:57)
    at com.ntml.remote.MSACCO.<init>(MSACCO.java:42)

Is this an issue with NTLM authentication or is there another way to pass the credentials? 这是NTLM身份验证的问题,还是还有另一种方式来传递凭据?

Found a working solution. 找到了可行的解决方案。 Injecting an authentication mechanism to the client using the web service port. 使用Web服务端口向客户端注入身份验证机制。

        Port webservice_port = new Wservice().getServicePort();
        Client client = ClientProxy.getClient(webservice_port);
        HTTPConduit conduit = (HTTPConduit) client.getConduit();
        AuthorizationPolicy authorization = conduit.getAuthorization();
        authorization.setUserName(username);
        authorization.setPassword(password);
        conduit.getClient().setAllowChunking(false);
        conduit.getClient().setAutoRedirect(true);
        webservice_port.callWebMethod();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM