如何将CXF Web服务使用的地址更改为与wsdl文件中指定的地址不同的地址?

当我根据配置获得wsdl时,我已经开始工作了,但是我想告诉它使用特定地址进行服务调用并使用wsdl的本地副本。

MyWebService serviceDefinition = new MyWebService(new URL(wsdlLocation)); service = serviceDefinition.getMyWebServicePort(); 

有谁知道这方面的最佳做法?

xml请求有效。

   Test Name 55555555   

代理xml请求不起作用。

   Test Name 55555555   

你可以使用ClientProxyFactoryBean吗? 如果您有已编译的存根,则甚至不需要WSDL。 例如:

 ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); factory.setServiceClass(HelloWorld.class); factory.setAddress("http://localhost:9000/Hello"); HelloWorld client = (HelloWorld) factory.create(); 
 MyWebService serviceDefinition = new MyWebService(new URL(wsdlLocation)); service = serviceDefinition.getMyWebServicePort(); ((BindingProvider)service).getRequestContext() .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8080/foobar"); 
 JaxWsProxyFactoryBeanfactory = new JaxWsProxyFactoryBean(); factory.setServiceClass(HelloWorld.class); factory.setAddress("http://localhost:9000/Hello"); HelloWorld client = (HelloWorld) factory.create(); 

JaxWS而不是FactoryBeanfactory客户端面向我们工作。