Skip to content

Instantly share code, notes, and snippets.

@ricston-git
Created October 10, 2012 10:23
Show Gist options
  • Save ricston-git/3864598 to your computer and use it in GitHub Desktop.
Save ricston-git/3864598 to your computer and use it in GitHub Desktop.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Schema validation error on message from client: "?" does not satisfy the "int" type.</faultstring>
<detail>
<error-reply>
<error>Contact the administrator</error>
<ExternalReferenceNumber>321</ExternalReferenceNumber>
<PartnerID>123</PartnerID>
</error-reply>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
public class FaultInterceptor extends AbstractSoapInterceptor {
public FaultInterceptor() {
super(Phase.MARSHAL);
}
@Override
public void handleMessage(SoapMessage message) throws Fault {
Fault fault = (Fault) message.getContent(Exception.class);
if (fault.getCode() != null && fault.getCode().equals("READ_VALIDATION_ERROR")) {
Element detail = fault.getOrCreateDetail();
Element errorDetail = detail.getOwnerDocument().createElement("error-reply");
Element error = errorDetail.getOwnerDocument().createElement("error");
Element extRefNumber = errorDetail.getOwnerDocument().createElement("ExternalReferenceNumber");
Element partnerId = errorDetail.getOwnerDocument().createElement("PartnerID");
partnerId.setTextContent("123");
extRefNumber.setTextContent("321");
error.setTextContent("Contact the administrator");
errorDetail.appendChild(error);
errorDetail.appendChild(extRefNumber);
errorDetail.appendChild(partnerId);
detail.appendChild(errorDetail);
}
}
}
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:mule="http://ricston.com/">
<soapenv:Header/>
<soapenv:Body>
<mule:add>
<arg0>9</arg0>
<arg1>?</arg1>
</mule:add>
</soapenv:Body>
</soapenv:Envelope>
<flow name="proxy-service-validation">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081"
path="proxy-service-validation"/>
<cxf:proxy-service validationEnabled="true" wsdlLocation="service.wsdl" service="MyService"
payload="envelope" namespace="http://ricston.com/">
<cxf:outFaultInterceptors>
<spring:bean class="com.ricston.proxyvalidation.FaultInterceptor"/>
</cxf:outFaultInterceptors>
</cxf:proxy-service>
...
</flow>
<flow name="proxy-service-validation">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081"
path="proxy-service-validation"/>
<cxf:proxy-service validationEnabled="true" wsdlLocation="service.wsdl" service="MyService"
payload="envelope" namespace="http://ricston.com/"/>
...
</flow>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Schema validation error on message from client: "?" does not satisfy the "int" type </faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment