Sono nuovo alla Spring-WS, e lentamente mi avvolge la testa. In questo momento sto scrivendo un semplice client per comunicare con un WS esistente. Sto usando il metodo WebServiceTemplate e il metodo marshalSendAndReceive. Tutto funziona beneCome annullare un errore SOAP in un errore FaultMessageResolver?
Tuttavia, quando si verifica un errore SOAP, il WST genera una SoapFaultClientException. Ho notato che posso creare il mio FaultMessageResolver per verificare cosa è contenuto nell'errore SOAP. Tuttavia, quando cerco di unmarshalling il WebServiceMessage nel mio FaultMessageResolver, ricevo il seguente messaggio di errore:
JAXB unmarshalling exception; nested exception is javax.xml.bind.UnmarshalException: unexpected element (uri:"http://schemas.xmlsoap.org/soap/envelope/", local:"Fault"). Expected elements are ....
Ovviamente, la mia unmarshaller non è configurato correttamente. Devo generare il modello di errore JAXB io stesso usando xjc per poter quindi annullare l'errore? Sono un po 'sorpreso che questo non esista già.
Esiste un modo migliore di aggiungere le informazioni di errore personalizzate dall'interno del mio sapone: risposta all'errore? Il mio errore è simile al seguente e sto cercando di estrarre/accedere all'elemento serviceErrors.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Blaze Data Error</faultstring>
<detail>
<ns14:serviceErrors xmlns="http://www.nb.com/ClientServices/LendingSimulation/CalculateProfitabilityRequest" xmlns:ns13="http://www.nb.com/fw/errorMgmt" xmlns:ns14="http://www.nb.com/ClientServices/LendingSimulation/V1" >
<ns13:faultstring>ServiceExecutionError</ns13:faultstring>
<ns13:serviceError>
<ns13:errorCode>C10F1013</ns13:errorCode>
<ns13:errorType>B</ns13:errorType>
<ns13:errorMessage>Unable to retreive additional data</ns13:errorMessage>
<ns13:fieldName>Message error received from PHClient : [An unexpected error code was received : system=PH context=[empty]]</ns13:fieldName>
<ns13:systemId>Calculator</ns13:systemId>
<ns13:time>2012-06-19 14:45:10.151-0400</ns13:time>
</ns13:serviceError>
</ns14:serviceErrors>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
Grazie!
Eric
Grazie. Questo è praticamente ciò che ho finito per fare. Ma questo ottiene solo un errore informazioni alla volta, che ho pensato fosse piuttosto strano. Mi sarei aspettato qualche sistema per consentirmi di eliminare tutti i difetti in una lista o in una serie di errori. –