and*_*nka 27 java web-services cxf client-side
我现在使用Apache CXF作为.NET服务的Web服务客户端来绕过NTLM身份验证.它工作得很好,但我想知道为什么我似乎无法设置Web服务目标端点.CXF似乎在运行时希望WSDL出于某种奇怪的原因 - 不确定.它需要来自WSDL的物理端点,我认为它在测试环境中工作正常,但在部署时它肯定会改变.
这里有一些代码来演示:
MyWebServices service = new MyWebServices ();
MyWebServicesSoap port = service.getMyWebServicesSoap12();
// 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);
port.doSomethingUseful();
Run Code Online (Sandbox Code Playgroud)
同样,我无法在CXF客户端API中看到允许我设置服务端点的地方.不是我能看到的.在这种情况下,目标是http://localhost/integration/webservices/mywebservices.asmx,但我可以在任何地方.当然这个行人问题以某种方式解决了?
Kev*_*vin 45
请尝试以下方法:
MyWebServicesSoap port = service.getMyWebServicesSoap12();
BindingProvider provider = (BindingProvider) port;
provider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);
Run Code Online (Sandbox Code Playgroud)
或者,MyWebServices
可能有其他getXXX方法采用WSDL位置的URL
小智 11
在cxf 2.6.1中工作
Client client = ClientProxy.getClient(port);
client.getRequestContext().put(Message.ENDPOINT_ADDRESS, "http://some-valid-endpoint") ;
Run Code Online (Sandbox Code Playgroud)