Hi benjamin.
I am using a soap remote service.
The remote server has define as not chunk connections.
System.out.println ("*************************************************************************" );
System.out.println ("Preparamos los Datos para el envio eFace FacturaSSPPWebServiceProxyService" );
System.out.println ("*************************************************************************" );
System.out.println("JAVA2 START com.sunrisehs.face.proveedores.v1.FacturaSSPP GetEstadoeFace" );
String RcCode = "";
EnableWss4jVerbose wss4jLog = new EnableWss4jVerbose();
wss4jLog.enable();
try {
//URL wsdl = new URL("
https://se-face-webservice.redsara.es/facturasspp2?wsdl"); // WSDL (solo aquí)
//QName svc = new QName("
https://webservice.face.gob.es", "FacturaSSPP2Service");
//QName port= new QName("
https://webservice.face.gob.es", "FacturaSSPP2Port");
URL wsdlUrl = Thread.currentThread().getContextClassLoader().getResource("/resources/wsdl/eface/facturasspp2.wsdl");
if ( wsdlUrl != null )
System.out.println("Path.-" + wsdlUrl.getPath());
QName serviceName = new QName("
https://webservice.face.gob.es", "FacturaSSPPWebServiceProxyService");
QName portName = new QName("
https://webservice.face.gob.es", "FacturaSSPPWebServiceProxyPort");
//System.setProperty("javax.xml.soap.MetaFactory", "com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl");
//System.setProperty("javax.xml.soap.SAAJMetaFactory", "com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl");
System.setProperty("javax.xml.ws.spi.Provider","com.sun.xml.ws.spi.ProviderImpl");
System.setProperty("javax.xml.soap.SAAJMetaFactory","com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl");
FacturaSSPPWebServiceProxyService service = null;
if ( TipoSSL.equals("JSSEHelper") ) {
ClassLoader old = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
} finally {
Thread.currentThread().setContextClassLoader(old);
}
}
service = new FacturaSSPPWebServiceProxyService( wsdlUrl, serviceName);
//Service svc = Service.create(wsdlUrl, serviceName);
FacturaSSPPWebServiceProxyPort port = service.getPort(portName, FacturaSSPPWebServiceProxyPort.class);
//FacturaSSPPWebServiceProxyPort port = service.getFacturaSSPPWebServiceProxyPort();
// 2) Forzar endpoint si fuera necesario (misma URL sin ?wsdl)
//securePort(port, PfxFileName, PfxPwd, AliasName);
javax.xml.ws.Binding binding = ((javax.xml.ws.BindingProvider) port).getBinding();
java.util.List<javax.xml.ws.handler.Handler> chain =
new java.util.ArrayList<javax.xml.ws.handler.Handler>(binding.getHandlerChain());
if ( Modo.equals("TEST") )
chain.add(new com.sunrisehs.apiface.tools.WsSecuritySignHandler( PfxFileName, PfxPwd, AliasName, TipoSSLSign, "eFaceConsultaV1"));
else
chain.add(new com.sunrisehs.apiface.tools.WasSecuritySignHandler( PfxFileName, PfxPwd, AliasName, TipoSSLSign, "eFaceConsultaV1"));
chain.add(new com.sunrisehs.apiface.tools.SoapDumpHandler());
//chain.add(new com.sunrisehs.apiface.tools.SoapTraceHandler());
//chain.add(new com.sunrisehs.apiface.tools.SignedSoapDebugHandler());
binding.setHandlerChain(chain);
if ( Modo.equals("TEST") ) {
((javax.xml.ws.BindingProvider) port).getRequestContext().put(
javax.xml.ws.BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"
https://se-face-webservice.redsara.es/facturasspp2"
);
}
if ( TipoSSL.equals("JSSEHelper") ) {
BindingProvider bp = (BindingProvider) port;
java.util.Map<String,Object> rc = bp.getRequestContext();
rc.remove(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE);
rc.remove("com.sun.xml.ws.transport.http.client.streaming.chunk.size");
rc.put("http.conduit.client.AllowChunking", "false");
rc.put("com.sun.xml.ws.transport.http.client.streaming.chunk.size", -1);
rc.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, -1);
rc.put("com.ibm.websphere.webservices.useChunking", Boolean.FALSE);
rc.put("HTTPChunked", Boolean.FALSE);
rc.put("com.sun.xml.ws.transport.http.client.ClientTransportProperties.CHUNKING_PROPERTY", Boolean.FALSE);
rc.put("com.sun.xml.ws.developer.JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE", -1);
System.out.println("TipoSSL activando JSSEHelper");
//objX509.disableChunkedIfAxis2(Empresa, port );
//com.ibm.ws.webservices.engine.xmlsoap.Envelope=all
//com.ibm.ws.webservices.engine.xmlsoap=all
//com.ibm.ws.webservices.engine.xmlsoap.SOAPPart=all
//com.ibm.ws.webservices.engine.xmlsoap.Message=all
}
// 3) Construir la solicitud: identifica la factura por código de registro o CSV
System.out.println("WSDL: https.webservice_face_gob " + Modo + "/" + TipoSSL);
try {
ConsultarFactura Factura = new ConsultarFactura();
Factura.setNumeroRegistro(msNumFactura);
// 4) Invocar consultarEstados (método con parámetro)
ConsultarFacturaResponse request = port.consultarFactura(msNumFactura);
Factura = request.getFactura();
Resultado Respuesta = request.getResultado();
System.out.println("Respuesta eFaceConsultaV1 " + Modo );
if ( Factura != null ) {
System.out.println("Rc Registro:" + Factura.getNumeroRegistro());
EstadoFactura FacEstado = Factura.getTramitacion();
System.out.println("Estado Codigo: " + FacEstado.getCodigo());
System.out.println("Estado Desc: " + FacEstado.getDescripcion());
System.out.println("Estado Motivo: " + FacEstado.getMotivo());
RcCode = "Cod Estado=" + FacEstado.getCodigo() + "|" + FacEstado.getDescripcion() +
"|" + FacEstado.getMotivo();
Rc.addElement("OK");
Rc.addElement("" + Factura.getNumeroRegistro());
Rc.addElement("" + FacEstado.getCodigo());
Rc.addElement("" + FacEstado.getDescripcion());
Rc.addElement("" + FacEstado.getMotivo());
}
else {
System.out.println("Error Codigo: " + Respuesta.getCodigo());
System.out.println("Error Seguimiento: " + Respuesta.getCodigoSeguimiento());
System.out.println("Error Descripcion: " + Respuesta.getDescripcion());
RcCode = "Rc Codigo:"+ Respuesta.getCodigo() + "|" + Respuesta.getDescripcion();
Rc.addElement("ERROR");
Rc.addElement("" + msNumFactura );
Rc.addElement("" + Respuesta.getCodigo());
Rc.addElement("" + Respuesta.getDescripcion());
}
System.out.println("JAVA2 END com.sunrisehs.face.proveedores.v1.FacturaSSPP GetEstadoeFace" );
}
//catch ( ServerSOAPFaultException es ) {
catch ( javax.xml.ws.soap.SOAPFaultException e1 ) {
System.out.println("Soap Excepcion WseFace ConsultaEstado: " + e1.getMessage());
Map<String,Object> rc = ((BindingProvider) port).getResponseContext();
Object statusCode = rc.get(javax.xml.ws.handler.MessageContext.HTTP_RESPONSE_CODE);
System.out.println("HTTP status = " + statusCode);
Object statusMsg = rc.get(javax.xml.ws.handler.MessageContext.HTTP_RESPONSE_HEADERS);
System.out.println("HTTP headers = " + statusMsg);
// Si es 4xx/5xx, casi seguro que te devolvieron HTML -> causa del DOCTYPE
RcCode = "ERROR: " + statusCode + "|" + statusMsg + "|" + e1.getMessage();
Rc.addElement("ERROR");
Rc.addElement("" + statusCode);
Rc.addElement("" + statusMsg);
Rc.addElement("");
}
catch (WebServiceException e2) {
System.out.println("WS Excepcion WseFace ConsultaEstado: " + e2.getMessage());
Map<String,Object> rc = ((BindingProvider) port).getResponseContext();
Object statusCode = rc.get(javax.xml.ws.handler.MessageContext.HTTP_RESPONSE_CODE);
System.out.println("HTTP status = " + statusCode);
Object statusMsg = rc.get(javax.xml.ws.handler.MessageContext.HTTP_RESPONSE_HEADERS);
System.out.println("HTTP headers = " + statusMsg);
// Si es 4xx/5xx, casi seguro que te devolvieron HTML -> causa del DOCTYPE
RcCode = "ERROR: " + statusCode + "|" + statusMsg + "|" + e2.getMessage();
Rc.addElement("ERROR");
Rc.addElement("" + statusCode);
Rc.addElement("" + statusMsg);
Rc.addElement("");
}
catch ( Exception e ) {
System.out.println("Excepcion eFaceConsultaV1: " + e.getMessage());
Map<String,Object> rc = ((BindingProvider) port).getResponseContext();
Object statusCode = rc.get(javax.xml.ws.handler.MessageContext.HTTP_RESPONSE_CODE);
System.out.println("HTTP status = " + statusCode);
Object statusMsg = rc.get(javax.xml.ws.handler.MessageContext.HTTP_RESPONSE_HEADERS);
System.out.println("HTTP headers = " + statusMsg);
// Si es 4xx/5xx, casi seguro que te devolvieron HTML -> causa del DOCTYPE
// Si es 4xx/5xx, casi seguro que te devolvieron HTML -> causa del DOCTYPE
RcCode = "ERROR: " + statusCode + "|" + statusMsg + "|" + e.getMessage();
Rc.addElement("ERROR");
Rc.addElement("" + statusCode);
Rc.addElement("" + statusMsg);
Rc.addElement("");
}
}
catch ( Exception e ) {
System.out.println("Excepcion Global eFaceConsultaV1: " + e.getMessage());
Rc.addElement("ERROR");
if ( e.getCause() != null )
Rc.addElement("" + e.getCause().getMessage());
else
Rc.addElement("NO CAUSE");
Rc.addElement(e.getMessage());
}
Rc.addElement(RcCode);
return Rc;