我使用来自以下 WSDL 的 Apache CXF 2.x 在 eclipse 中创建了一个 Web 服务客户端:
https://test.timbrado.com.mx/cfdi/wstimbrado.asmx?WSDL
在进行 Web 服务调用时,我收到以下错误堆栈跟踪(服务器无法处理请求 ---> 对未建立为对象实例的对象的引用):
javax.xml.ws.soap.SOAPFaultException: El servidor no puede procesar la solicitud. ---> Referencia a objeto no establecida como instancia de un objeto.
[java] at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(Unknown Source)
[java] at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(Unknown Source)
[java] at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
[java] at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
[java] at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
[java] at $Proxy34.generaTimbre(Unknown Source)
[java] at com.vital.fevital.funciones.FacturaElectronica.timbrarWebService(FacturaElectronica.java:1258)
[java] at facturaVital.factura.servlet.FacturaVenta.generaFactura(FacturaVenta.java:1128)
[java] at facturaVital.factura.servlet.FacturaVenta.doPost(FacturaVenta.java:127)
[java] at facturaVital.factura.servlet.FacturaVenta.doGet(FacturaVenta.java:86)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
[java] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
[java] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[java] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
[java] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
[java] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
[java] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
[java] at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
[java] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
[java] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:383)
[java] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
[java] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
[java] at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
[java] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
[java] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
[java] at java.lang.Thread.run(Unknown Source)
我这样做的电话是这样的:
ObjectFactory of = new ObjectFactory();
AuthenticationHeader ah = of.createAuthenticationHeader();
ah.setUserName(cfdi.getUsuarioPAC());
ah.setPassword(cfdi.getPasswordPAC());
JAXBElement<AuthenticationHeader> jah = of.createAuthenticationHeader(ah);
ServicioTimbradoPruebas stp = new ServicioTimbradoPruebas();
ServicioTimbradoPruebasSoap stpSoap = stp.getServicioTimbradoPruebasSoap();
try{
WSBindingProvider bp = (WSBindingProvider)stpSoap;
Header hdr = Headers.create((JAXBRIContext) JAXBContext.newInstance(AuthenticationHeader.class),jah);
bp.setOutboundHeaders(hdr);
}catch(Exception ex){
ex.printStackTrace();
error = "Error en webservice ";
}
byte [] xmlBytes = cfdi.getXml().getBytes("UTF-8");
String result = stpSoap.generaTimbre(xmlBytes);
我在以下行中得到它的错误:
String result = stpSoap.generaTimbre(xmlBytes);
在我能够进行 Web 服务调用之前,但现在我无法做到这一点,并且出现以下错误。关于如何解决这个问题的任何建议?