如何使用NTLM身份验证从Java客户端调用基于.Net的Web服务 [英] How to invoke the .Net Based webservice from a java client with NTLM authentication

查看:83
本文介绍了如何使用NTLM身份验证从Java客户端调用基于.Net的Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Java客户端代码调用基于.NET的Web服务.我使用wsimport工具生成了JAX-WS存根.

I want to invoke the .NET Based webservice from a java client code. I generated JAX-WS stubs using wsimport tool.

这是在.NET客户端中创建凭据的方式-

This is how credentials are being created in .NET client-

NetworkCredential credential = new NetworkCredential(userName, password, "domain");
client.ClientCredentials.Windows.ClientCredential = credential ;

我们如何在Java Client中类似地做到这一点?我进行了很多搜索,发现一些建议进行NTLM身份验证的帖子,但是我不确定该怎么做.

How do we do it similarly in Java Client? I searched a lot and found some posts suggesting to do NTLM authentication but I am not sure how to do that.

推荐答案

JAX-WS不支持NTLM身份验证,但是您仍然可以选择其他几种方式

NTLM authentication is not supported by JAX-WS but you still have a couple alternatives

替代1: 创建您自己的身份验证器并将其设置为默认值,它将用于您所有人的HTTP通信. 仅当通信是server2server时才使用此替代方法,因为使用多个多个用户帐户不是最佳选择. 您可以在此处查看如何实现的代码:

Alternative 1: Create your own authenticator and set it as default, it will be used for all of you HTTP communications. Use this alternative only if the communication is server2server, since it's not optimal to use multiple multiple user accounts. You can see the code of how to implement it here: http://docs.oracle.com/javase/7/docs/technotes/guides/net/http-auth.html

替代2: 另一种选择是使用Axis2,它在后台使用HTTPClient.它将选择适合您的方案的最佳身份验证方法. axis2客户端NTLM身份验证

Alternative 2: Another alternative is to use Axis2, which uses the HTTPClient behind the scene. It will select the best authentication method suited for your scenario. axis2 client NTLM authentication

注意:Axis2在某些版本的NTLM上存在问题,有些人建议使用CFX

Note: Axis2 has issues with some versions of NTLM and some people is recomending to move to CFX CXF SOAP Client with NTLM to SharePoint

这些替代方法要求您在代码中包括新的库,希望对您有所帮助

These alternative require you to include new libraries in your code, I hope it helps

这篇关于如何使用NTLM身份验证从Java客户端调用基于.Net的Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆