@WebServiceClient wsdlLocation 动态给注解内容参数赋值

发布时间 2023-11-16 17:26:11作者: fchhk

动态给注解内容参数赋值

@WebServiceClient(name = "IXxxService", targetNamespace = "http://xxx.xxx.xxx.com", wsdlLocation = "${WSDL_URL}")
public class IXxxService extends Service {

	//静态变量在静态代码块加载后加载,且注解也在之后加载,完成动态注入修改注解里的参数
    private final static URL WSDL_LOCATION;
	private final static String WSDL_URL;
    private final static WebServiceException SERVICE_EXCEPTION;
    private final static QName SERVICE_QNAME = new QName("http://xxx.xxx.xxx.com", "IXxxService");

    static {
        URL url = null;
		String location = null;
        WebServiceException e = null;
        try {
			String address = SpringUtils.getProperty("xxx.xxx");
            url = new URL(address);
			location = address;
        } catch (MalformedURLException ex) {
            e = new WebServiceException(ex);
        }
        WSDL_LOCATION = url;
		WSDL_URL = location;
        SERVICE_EXCEPTION = e;
    }
}