saverioriotto.it

[ERROR] org.xml.sax.SAXParseException; systemId: http://www.w3.org/2005/05/xmlmime Premature end of file.

[ERROR] org.xml.sax.SAXParseException; systemId: http://www.w3.org/2005/05/xmlmime Prematu

saverio
18 Maggio 2023
17:20

Diverse applicazioni sviluppate in java riscontrano dei problemi con il servizio SOAP durante l'utilizzo dei servizi. Il problema riportato è:
 

[ERROR] Fine del file anticipata.
  riga 1 di http://www.w3.org/2005/05/xmlmime

[ERROR] org.xml.sax.SAXParseException; systemId: http://www.w3.org/2005/05/xmlmime; lineNumber: 1; columnNumber: 1; Fine del file anticipata.
  riga 1 di https://**************************************************?wsdl

Analisi di WSDL non riuscita.

Come è possibile risolvere?

Re:[ERROR] org.xml.sax.SAXParseException; systemId: http://www.w3.org/2005/05/xmlmime Prematu

saverio
18 Maggio 2023
17:29

Il problema segnalato è relativo alla libreria java jaxws-api-2.3.1 che all'interno dell'interfaccia javax.xml.ws.soap.SOAPBinding vi sono presenti URL verso gli schemi W3 in http e non seguono il redirect automatico https. 
 


public interface SOAPBinding extends Binding {

  /**
   * A constant representing the identity of the SOAP 1.1 over HTTP binding.
   */
  public static final String SOAP11HTTP_BINDING = "http://schemas.xmlsoap.org/wsdl/soap/http";

  /**
   * A constant representing the identity of the SOAP 1.2 over HTTP binding.
   */
  public static final String SOAP12HTTP_BINDING = "http://www.w3.org/2003/05/soap/bindings/HTTP/";

  /**
   * A constant representing the identity of the SOAP 1.1 over HTTP binding
   * with MTOM enabled by default.
   */
  public static final String SOAP11HTTP_MTOM_BINDING = "http://schemas.xmlsoap.org/wsdl/soap/http?mtom=true";

  /**
   * A constant representing the identity of the SOAP 1.2 over HTTP binding
   * with MTOM enabled by default.
   */
  public static final String SOAP12HTTP_MTOM_BINDING = "http://www.w3.org/2003/05/soap/bindings/HTTP/?mtom=true";

Per risolvere la problematica in qustione basterebbe estendere l'interfaccia in questione, SOAPBinding, con SOAPBindingExt e sostituire i puntamenti in https.


public interface SOAPBinding extends Binding {

  /**
   * A constant representing the identity of the SOAP 1.1 over HTTP binding.
   */
  public static final String SOAP11HTTP_BINDING = "https://schemas.xmlsoap.org/wsdl/soap/http";

  /**
   * A constant representing the identity of the SOAP 1.2 over HTTP binding.
   */
  public static final String SOAP12HTTP_BINDING = "https://www.w3.org/2003/05/soap/bindings/HTTP/";

  /**
   * A constant representing the identity of the SOAP 1.1 over HTTP binding
   * with MTOM enabled by default.
   */
  public static final String SOAP11HTTP_MTOM_BINDING = "https://schemas.xmlsoap.org/wsdl/soap/http?mtom=true";

  /**
   * A constant representing the identity of the SOAP 1.2 over HTTP binding
   * with MTOM enabled by default.
   */
  public static final String SOAP12HTTP_MTOM_BINDING = "https://www.w3.org/2003/05/soap/bindings/HTTP/?mtom=true";

All'interno dell'applicazione dove viene richiamata la classe SOAPBinding sostituirla con SOAPBindingExt.

Invece di:

BindingProvider provider = (BindingProvider) port;
SOAPBinding soapBinding = ( SOAPBinding) provider.getBinding();

Sostituire con:

BindingProvider provider = (BindingProvider) port;
SOAPBindingExt soapBinding = ( SOAPBindingExt) provider.getBinding();

In questo modo il problema viene superato.