我尝试通过创建一个NTLM引擎(按照http://hc.apache.org/httpcomponents-client-4.3.x/ntlm.html上的说明)来使用一个带有NTLM身份验证的SOAP服务,该引擎实现了AuthSchemeFactory,并最终将AuthSchemeFactory注册到我的HTTP客户端。当我使用HTTP客户端访问该服务时,我得到一个响应“Status code - 415,Message - The server cannot service the request because the media type is unsupported”。
有人能告诉我如何解决这个问题不受支持的媒体消费一个受NTLM保护的SOAP Web服务在Java平台上.使用JCIFS是一个正确的选择来conmbloom受保护的服务或有任何更好的方法(S).提前感谢.
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getAuthSchemes().register(AuthSchemes.NTLM,
new JCIFSNTLMSchemeFactory());
CredentialsProvider credsProvider = new BasicCredentialsProvider();
NTCredentials ntcred = new NTCredentials("USERNAME", "PASSWORD",
"HOST", "DOMAIN");
credsProvider.setCredentials(new AuthScope("HOST", 443,
AuthScope.ANY_REALM, "NTLM"), ntcred);
httpclient.setCredentialsProvider(credsProvider);
httpclient.getParams().setParameter(
CoreProtocolPNames.HTTP_CONTENT_CHARSET, "UTF-8");
Writer writer = new StringWriter();
writer.write("MY SOAP REQUEST BODY");
HttpPost httppost = new HttpPost(
"https://<HOST_NAME>/XiPay30WS.asmx");
httppost.setEntity(new StringEntity(writer.toString()));
httppost.setHeader("Content-Type",
"application/x-www-form-urlencoded");
HttpResponse httpresponse = httpclient.execute(
new HttpHost("HOST", 443, "https"),
httppost, new BasicHttpContext());
String statusCode = httpresponse.getStatusCode();
字符串
3条答案
按热度按时间j5fpnvbx1#
如果您使用Spring WS支持:
检查此解决方案http://dolszewski.com/spring/sharepoint-web-services-spring-and-ntlm-authentication/
字符串
sqougxex2#
在Apache HttpClient 5的情况下,您应该使用HttpClient 5MessageClient
字符串
例如Kotlin
型
unhi4e5o3#
示例python实现,使用NTFS Auth with FLASK。
如果你想使用java,运行下面的独立flask代码,并通过http请求从java代码调用url(例如POST请求/dora/httpWithNTLM)
字符串