我的目标是使用mvn程序集创建一个在具有所有依赖项的独立jar中运行的Web Service客户端:
我使用CXF代码生成器wsdl2java生成了客户端,并创建了一个名为NetBanxAutostatementService的@WebServiceClient。
对于依赖我
2.5.2
org.apache.cxf
cxf-rt-frontend-jaxws
${cxf.version}
runtime
org.apache.cxf
cxf-rt-transports-http
${cxf.version}
runtime
拼命地我什至试图添加更多的“东西”
org.apache.cxf
cxf-rt-core
2.5.2
runtime
org.apache.cxf
cxf
2.5.2
pom
runtime
问题:每次我尝试运行“ java -jar target / Netbanx-0.0.1-SNAPSHOT-jar-with-
dependencies.jar”
INFO [main] (Netbanx.java:97) - autostatement_wsdlLocation:https://www.test.netbanx.com/cgi-bin/autostatement_wsdl
Exception in thread "main" java.lang.NullPointerException
at org.apache.cxf.wsdl11.WSDLServiceFactory.(WSDLServiceFactory.java:92)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:204)
at org.apache.cxf.jaxws.ServiceImpl.(ServiceImpl.java:148)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:91)
at javax.xml.ws.Service.(Service.java:56)
at com.netbanx.autostatement.NetBanxAutostatementService. (NetBanxAutostatementService.java:39)
at my.project.netbanx.Netbanx.(Netbanx.java:98)
at my.project.netbanx.Netbanx.main(Netbanx.java:130)
这在调用WebServiceClient autostatementService = new
NetBanxAutostatementService(autostatement_wsdlLocation)的行中发生;我通过日志行知道我没有将autostatement_wsdlLocation传递为null
Java代码:
URL autostatement_wsdlLocation = null;
URL payment_wsdlLocation = null;
try {
autostatement_wsdlLocation = new URL(properties.getProperty("autostatement_wsdlLocation"));
payment_wsdlLocation = new URL(properties.getProperty("payment_wsdlLocation"));
} catch (MalformedURLException e) {
logger.error("MalformedURLException",e);
}
/**
* Load the Netbanx's webservices AutostatementService and PaymentService
*/
try {
logger.info("autostatement_wsdlLocation:"+autostatement_wsdlLocation.toString());
autostatementService = new NetBanxAutostatementService(autostatement_wsdlLocation); //it is here I get the NullPointerException error
logger.info("payment_wsdlLocation:"+payment_wsdlLocation.toString());
paymentService = new NetBanxPaymentService(payment_wsdlLocation);
webServiceStarted = true;
} catch(javax.xml.ws.WebServiceException wsException ){
String error = "Cannot create NetBanx web service please make sure this host can reach:" + autostatement_wsdlLocation +" and " + payment_wsdlLocation;
logger.error(error);
logger.error("WebServiceException",wsException);
}