@WebServiceClient wsdlLocation 动态给注解内容参数赋值、使用cmd webservice wsdl网址生成客户端代码

动态给注解内容参数赋值

@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;
    }
}

使用cmd webservice wsdl网址生成客户端代码

wsimport -keep -p com.test -d D:\\  xxxx?wsdl

命令参数说明:
-d:生成客户端执行类的class文件的存放目录(默认存放在C:\Users\Administrator\)包含.java和.class文件

-s:生成客户端执行类的源文件的存放目录(默认存放在C:\Users\Administrator\) 只包含.java文件

-p:定义生成类的包名

最终生成在在D盘com/test目录下

posted @ 2023-11-16 17:20  fchhk  阅读(443)  评论(0编辑  收藏  举报