Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

279
Vistas
Cómo analizar SoapFaultClientException en spring-ws

Estoy usando spring-ws-2.3.1, mientras creo un cliente para servicios web en algún momento obtengo SoapFaultClientException como a continuación,

 <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:Server</faultcode> <faultstring>There was a problem with the server so the message could not proceed</faultstring> <faultactor>InvalidAPI</faultactor> <detail> <ns0:serviceException xmlns:ns0="http://www.books.com/interface/v1"> <ns1:messageId xmlns:ns1="http://www.books.org/schema/common/v3_1">5411</ns1:messageId> <ns1:text xmlns:ns1="http://www.books.org/schema/common/v3_1">Locale is invalid.</ns1:text> </ns0:serviceException> </detail> </SOAP-ENV:Fault>

Estoy tratando de obtener el "messageId" y el "Text" de ServiceException pero no pude. Busque el código a continuación,

 catch (SoapFaultClientException ex) { SoapFaultDetail soapFaultDetail = ex.getSoapFault().getFaultDetail(); // <soapFaultDetail> node // if there is no fault soapFaultDetail ... if (soapFaultDetail == null) { throw ex; } SoapFaultDetailElement detailElementChild = soapFaultDetail.getDetailEntries().next(); Source detailSource = detailElementChild.getSource(); Object detail = webServiceTemplate.getUnmarshaller().unmarshal(detailSource); System.out.println("Detail"+detail.toString());//This object prints the jaxb element }

El objeto "detalle" devuelve el JaxbElement. ¿Hay alguna forma elegante de analizar la falla del jabón?

Cualquier ayuda debe ser apreciada.

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Finalmente, puedo analizar la excepción de falla de jabón,

 catch (SoapFaultClientException ex) { SoapFaultDetail soapFaultDetail = ex.getSoapFault().getFaultDetail(); // <soapFaultDetail> node // if there is no fault soapFaultDetail ... if (soapFaultDetail == null) { throw ex; } SoapFaultDetailElement detailElementChild = soapFaultDetail.getDetailEntries().next(); Source detailSource = detailElementChild.getSource(); Object detail = webServiceTemplate.getUnmarshaller().unmarshal(detailSource); JAXBElement<serviceException> source = (JAXBElement<serviceException>)detail; System.out.println("Text::"+source.getText()); //prints : Locale is invalid. }

No encuentro ninguna otra forma elegante, así que espero que esta sea la solución.

about 4 years ago · Santiago Trujillo Denunciar

0

Lo hizo de esta manera, sin unmarshaller.

 String DETAIL_PATH = "//*[local-name()='Detail']"; SoapFaultDetail soapFaultDetail = ((SoapFaultClientException)exception).getSoapFault().getFaultDetail(); DOMSource sourceNode = (DOMSource) soapFaultDetail.getSource(); XPath xPath = XPathFactory.newInstance().newXPath(); XPathExpression exp = null; //Cibling detail field try { exp = xPath.compile(DETAIL_PATH); NodeList nl = (NodeList) exp.evaluate(sourceNode.getNode(), XPathConstants.NODESET); if (nl == null || nl.getLength() < 1) { return; } else { //Get value here String detailValue = nl.item(0).getTextContent(); } } catch (XPathExpressionException e) { LOG.debug("Can't get detail from Exception"); }
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda