2015-04-20 26 views
0

我不能在我的亂序變換的SOAPFault以JSON SOAP錯誤,請幫助。如何處理WSO2失序

這是SOAP響應:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
<soapenv:Body> 
    <soapenv:Fault> 
    <faultcode>soapenv:Server</faultcode> 
    <faultstring>Error en consultar: LA CONSULTA NO ARROJO NINGUN RESULTADO</faultstring> 
    <detail> 
     <ns8:consultarFault xmlns:ns8="http://colsanitas.com/Persona/"> 
      <consultarFault> 
       <ns7:errorCode xmlns:ns7="http://colsanitas.com/osi/comun/nofuncionales">38</ns7:errorCode> 
       <ns7:errorDesc xmlns:ns7="http://colsanitas.com/osi/comun/nofuncionales">LA CONSULTA NO ARROJO NINGUN RESULTADO</ns7:errorDesc> 
      </consultarFault> 
     </ns8:consultarFault> 
    </detail> 
    </soapenv:Fault> 

這是我的REST API:

<?xml version="1.0" encoding="UTF-8"?> 
<api xmlns="http://ws.apache.org/ns/synapse" name="PersonaOSI" context="/persona"> 
<resource methods="GET" uri-template="/{documento}?tipo={tipo}"> 
    <inSequence> 
     <log> 
      <property name="DOCUMENTO" expression="get-property('uri.var.documento')"/> 
      <property name="TIPO" expression="get-property('uri.var.tipo')"/> 
     </log> 
     <payloadFactory media-type="xml"> 
      <format> 
       <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:srv="http://colsanitas.com/osi/srv" xmlns:per="http://colsanitas.com/Persona/" xmlns:per1="http://colsanitas.com/osi/comun/persona" xmlns:nof="http://colsanitas.com/osi/comun/nofuncionales"> 
        <soapenv:Body> 
         <per:ConsultarPersonaEnt> 
          <consultarPersonaEnt xmlns=""> 
           <srv:consultaPersona> 
            <srv:identificacion> 
             <per1:Documento>$1</per1:Documento> 
             <per1:TipoDocumento>$2</per1:TipoDocumento> 
            </srv:identificacion> 
            <srv:aseguradora>?</srv:aseguradora> 
           </srv:consultaPersona> 
          </consultarPersonaEnt> 
         </per:ConsultarPersonaEnt> 
        </soapenv:Body> 
       </soapenv:Envelope> 
      </format> 
      <args> 
       <arg evaluator="xml" expression="get-property('uri.var.documento')"/> 
       <arg evaluator="xml" expression="get-property('uri.var.tipo')"/> 
      </args> 
     </payloadFactory> 
     <property name="FORCE_ERROR_ON_SOAP_FAULT" value="true" scope="default" type="STRING"/> 
     <header name="Action" scope="default" value="http://www.colsanitas.com/Persona/consultar"/> 
     <send> 
      <endpoint> 
       <address uri="https://osiapppre02.colsanitas.com/services/PersonaOSI" format="soap11"/> 
      </endpoint> 
     </send> 
    </inSequence> 
    <outSequence> 
     <send/> 
    </outSequence> 
    <faultSequence> 
     <payloadFactory media-type="json"> 
      <format> 
       {"Error" : $1} 
      </format> 
      <args> 
       <arg xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" evaulator="xml" expression="//soapenv:Fault/faultstring"/> 
      </args> 
     </payloadFactory> 
     <property name="messageType" value="application/json" scope="axis2" type="STRING"/> 
     <send/> 
    </faultSequence> 
</resource> 

但我得到一個異常:

org.apache.axiom.om.impl.llom.OMSourcedElementImpl cannot be cast to org.apache.axiom.soap.SOAPFault 

回答

1

作爲一種變通方法,你可以在PayloadFactory調停完整的SOAP信封克服這種錯誤

E.g

<payloadFactory media-type="xml"> 
<format> 
    <Envelope> 
     <Body> 
      <response> 
       <error>$1</error> 
      </response> 
     </Body> 
    </Envelope> 
</format> 
<args> 
    <arg xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" evaulator="xml" expression="//soapenv:Fault/faultstring"/> 
</args>