具有NTLM身份验证的Jax-WS

时间:2017-10-14 20:19:10

标签: java web-services ntlm

当我读到Jax-ws可以使用NTLM进行身份验证时,但我遇到了问题;
首先,我在java文档中创建了MyAuthenticator java类(参见: http://docs.oracle.com/javase/7/docs/technotes/guides/net/http-auth.html)。

当我尝试连接soapUI时,一切正常,请参阅请求标题:

Request Headers Value
(Request-Line)  POST /Online/OnlineServices.asmx HTTP/1.1
Content-Type    text/xml;charset=UTF-8
SOAPAction  "http://CTL.COM/OnlineServices/AcquireTicket"
Host    172.22.2.144:8000
Connection  Keep-Alive
User-Agent  Apache-HttpClient/4.1.1 (java 1.5)
Authorization   NTLM TlRMTVNTUAADAAAAGAAYAEAAAACgAKAAWAAAAAYABgD4AAAAGAAYAP4AAAAMAAwAFgEAAAAAAAAiAQAA
Accept-Encoding gzip, deflate
Content-Length  702 

当我尝试连接java时,我得到500内部服务器错误,请参阅header:

Request Headers Value
(Request-Line)  POST /Online/OnlineServices.asmx HTTP/1.1
SOAPAction  "http://CTL.COM/OnlineServices/AcquireTicket"
Accept  text/xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Content-Type    text/xml;charset="utf-8"
User-Agent  JAX-WS RI 2.1.4-b01-
Host    172.22.2.144:8000
Connection  keep-alive
Authorization   NTLM TlRMTVNTUAADAAAAGAAYAIwAAAD8APwApAAAAAYABgBYAAAAIgAiAF4AAAAMAAwAgAAAAAAAAACgAQAABYKIogoAOTgAAAAP5/lqdc43ElnLlEh5ASEkQlUARgBDAGUAdgBnAGUAbgBpAC4AbwByAG0AbwB0AHMAYQBkAHoAZQBQAEMALQAyADMAMQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABXZ
Accept-Encoding gzip, deflate
Content-Length  443

这是我的代码:

        Authenticator.setDefault(new MyAuthenticator(domain + "\\kuser","kpass"));
        OnlineServicesSoap onlineServicesSoap = new OnlineServices(url, qName).getOnlineServicesSoap();
        Map<String, List<String>> headers = new HashMap<String, List<String>>();
        headers.put("Content-Type", Collections.singletonList("text/xml;charset=UTF-8"));
        headers.put("Accept-Encoding", Collections.singletonList("gzip, deflate"));
        ((BindingProvider) onlineServicesSoap).getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, headers);
        try {
            AcquireTicketResponse acquireTicketResponse = onlineServicesSoap.acquireTicket(acqTicket);
        } catch (RuntimeException ex) {
            System.out.println(ex.getMessage() + ex.getCause());
        }

我搜索了很多,发现一些帖子建议做NTLM身份验证,但我无法连接..我不想使用轴实现

0 个答案:

没有答案