从wsimport生成的代码无法在Java 10.0.2中编译。我们尝试了各种库(包括此处提到的库)。
对于大多数建议的库,编译失败并缺少以下软件包:
error: package javax.xml.ws is not visible
error: package javax.jws is not visible
Run Code Online (Sandbox Code Playgroud)
我们可以使用以下库克服编译错误:
compile group: 'javax.xml.ws', name: 'jaxws-api', version: '2.3.0'
compile group: 'javax.jws.jsr181-api', name: 'jsr181-api', version: '2.1.1'
Run Code Online (Sandbox Code Playgroud)
我们还包括以下jaxb库:
compile group: 'org.glassfish.jaxb', name: 'jaxb-core', version: '2.3.0.1'
compile group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '2.3.0.1'
Run Code Online (Sandbox Code Playgroud)
但是,这在运行时由于NullPointerException而失败。
这是来自Service.java的代码:
protected Service(java.net.URL wsdlDocumentLocation, QName serviceName) {
delegate = Provider.provider().createServiceDelegate(wsdlDocumentLocation, // line 112
serviceName,
this.getClass());
}
Run Code Online (Sandbox Code Playgroud)
这是从为Web服务生成的代码中调用的:
public IMOTPWS(URL wsdlLocation) {
super(wsdlLocation, IMOTPWS_QNAME);
}
Run Code Online (Sandbox Code Playgroud)
这是示例再现的堆栈跟踪:
java.lang.NullPointerException
at javax.xml.ws.Service.<init>(Service.java:112)
at com.automationrhapsody.reststub.resources.IMOTPWS.<init>(IMOTPWS.java:47)
at com.automationrhapsody.reststub.RestStubApp.createImoSoapClient(RestStubApp.java:34) …Run Code Online (Sandbox Code Playgroud)