【发布时间】:2012-01-20 04:38:18
【问题描述】:
我有一个工作的骡子到我使用的 C# 服务端点。
服务托管在 WCF/C# 上 - mule 正在使用 apache cxf (Wsdl2java) 生成的一组类打开该服务的客户端。 然而,到目前为止,我使用的只是服务上的基本 httpbinding——这意味着没有安全/凭据验证。
现在 - 我想改变它。我想将 c# 服务的绑定设置为 WSHttpBinding。
有没有办法可以使用 NTLM 凭据来使用 c# 服务??
当前端点定义为:
<cxf:jaxws-client serviceClass="com.TimeLineListener.IBusListeningService"
operation="getMessage" />
<outbound-endpoint address="${TMSService.host}"
exchange-pattern="one-way" />
来自 Apache CXF 的文档:
NTLM 身份验证
//Set the jcifs properties
jcifs.Config.setProperty("jcifs.smb.client.domain", "ben.com");
jcifs.Config.setProperty("jcifs.netbios.wins", "xxx.xxx.xxx.xxx");
jcifs.Config.setProperty("jcifs.smb.client.soTimeout", "300000"); //5
minutes
jcifs.Config.setProperty("jcifs.netbios.cachePolicy", "1200"); //20 minutes
//jcifs.Config.setProperty("jcifs.smb.client.username", "myNTLogin");
//jcifs.Config.setProperty("jcifs.smb.client.password", "secret");
//Register the jcifs URL handler to enable NTLM
jcifs.Config.registerSmbURLHandler();
Finally, you need to setup the CXF client to turn off chunking. The reason is that the NTLM authentication requires a 3 part handshake which breaks the streaming.
//Turn off chunking so that NTLM can occur
Client client = ClientProxy.getClient(port);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(36000);
httpClientPolicy.setAllowChunking(false);
http.setClient(httpClientPolicy);
那么,我如何在上面的 XML 中定义这些项目???我还没有看到任何这样的例子......
另外,即使我尝试在没有安全性的情况下设置连接(WSHttpBinding with Security =none) - 我仍然无法使其工作,因为内容类型不匹配(假设是 application/xml,它是 text/xml或类似的东西)
我真的很想举一些例子来说明如何做到这一点。
谢谢(再次)!
【问题讨论】:
-
你读过这篇文章吗? cxf.apache.org/docs/…
-
我看了看,还是不太明白如何实现(修改了我的问题)
标签: cxf ntlm esb ws-security mule