Java Spring:如何在@WebServiceRef中注入wsdlLocation

Java Spring:如何在@WebServiceRef中注入wsdlLocation,java,web-services,jax-ws,Java,Web Services,Jax Ws,我正在使用spring,在我的客户端(一个web应用程序)中,我需要与Jax WS web服务交互。我目前通过@WebServiceRef注释服务接口使其工作。但是,我需要注入wsdlLocation属性,因为很明显,Sun Microsystems或Oracle生产中的web服务wsdl位置将与开发过程中使用的位置不同 如何注入wsdlLocation 下面是代码的一个极其简化的版本: //This client service lives in the web app. wsimport u

我正在使用spring,在我的客户端(一个web应用程序)中,我需要与Jax WS web服务交互。我目前通过@WebServiceRef注释服务接口使其工作。但是,我需要注入wsdlLocation属性,因为很明显,Sun Microsystems或Oracle生产中的web服务wsdl位置将与开发过程中使用的位置不同

如何注入wsdlLocation

下面是代码的一个极其简化的版本:

//This client service lives in the web app. wsimport used to generate artifacts.
@Component
public class MyClientServiceImpl implements MyClientService {

    @WebServiceRef(wsdlLocation = "http://localhost:8080/ws/MyOtherService/the.wsdl", value = MyOtherServiceService.class)
    //Interface generated by wsimport
    private MyOtherService otherService;

    @Override
    public List<SomeSearchData> search(String searchString) {
        return otherService.search(searchString);
    }
}
//此客户端服务存在于web应用程序中。wsimport用于生成工件。
@组成部分
公共类MyClientServiceImpl实现MyClientService{
@WebServiceRef(wsdlLocation=”http://localhost:8080/ws/MyOtherService/the.wsdl,value=MyOtherServiceService.class)
//由wsimport生成的接口
私人医疗服务;
@凌驾
公共列表搜索(字符串搜索字符串){
返回otherService.search(searchString);
}
}

这在中有半个概述。您需要将端点字符串作为标准成员变量注入,然后使用

((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, this.injectedEnpointURL); 

这在本手册中是半概述的。您需要将端点字符串作为标准成员变量注入,然后使用

((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, this.injectedEnpointURL); 
你可以用。您可以通过这个工厂bean配置WSDL URL(以及其他内容)。以下是来自的配置代码段:


然后,您可以让Spring将此依赖项自动连接到您的目标bean中(例如,
MyClientServiceImpl
)。

您可以使用。您可以通过这个工厂bean配置WSDL URL(以及其他内容)。以下是来自的配置代码段:



然后,您可以让Spring将此依赖项自动连接到目标bean中(例如,
MyClientServiceImpl
)。

在这种情况下,这是行不通的。web服务被注入@WebServiceRef注释。我从不直接与wsimport生成的服务实现类交互。在这种情况下,这是行不通的。web服务被注入@WebServiceRef注释。我从不直接与wsimport生成的服务实现类交互。