我试图找出将以下代码移动到 spring .xml 配置文件中的最佳方法:(强制异步并禁用 chunkng 以便 NTLM 工作)
final WSSoap port = new WS().getWSSoap();
final Client client = ClientProxy.getClient(port);
final HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
final HTTPClientPolicy httpClientPolicy = httpConduit.getClient();
httpClientPolicy.setAllowChunking(false);
httpClientPolicy.setAutoRedirect(true);
final BindingProvider bindingProvider = (BindingProvider) port;
final Map<String, Object> requestContext = bindingProvider.getRequestContext();
final Credentials credentials = new NTCredentials("username", "password", "workstation", "domain");
requestContext.put(Credentials.class.getName(), credentials);
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://www.example.com/");
requestContext.put(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE);
我查看了 CXF 配置页面(此处:http ://cxf.apache.org/docs/configuration.html ),但我没有看到任何方法可以满足我的需要。
有没有一种干净的方法来使用弹簧处理 CXF 的 NTLM 身份验证?
更新:我已经想出了如何使用以下命令强制异步管道:
<cxf:bus name="asyncBus">
<cxf:properties>
<entry key="use.async.http.conduit" value="true"/>
</cxf:properties>
</cxf:bus>
<http-conf:conduit name="{http://www.webserviceX.NET}GlobalWeatherSoapPort.http-conduit">
<http-conf:client AllowChunking="false" Connection="Keep-Alive"/>
</http-conf:conduit>
<jaxws:client id="weatherClient" bus="asyncBus"
address="http://www.webservicex.com/globalweather.asmx"
serviceClass="net.webservicex.GlobalWeatherSoap"/>
但是,我仍然无法访问请求上下文,因此我可以添加我的 NTLM 凭据。