如何向我的客户端发送wso2 esb错误消息或异常

时间:2013-04-09 21:46:55

标签: wso2 wso2esb

我在wso2ESB中引发错误,以便在客户端控制某些错误,而esb控制台显示:

ERROR {org.wso2.carbon.identity.entitlement.mediator.EntitlementMediator} -  Error occurred while evaluating the policy {org.wso2.carbon.identity.entitlement.mediator.EntitlementMediator}
org.apache.axis2.AxisFault: Access Denied. Authentication failed - Invalid credentials provided.
...
...

客户端控制台显示:

org.apache.axiom.soap.SOAPProcessingException: Transport level information does not match with SOAP Message namespace URI

我在控制台中看到不同的错误,我需要使用esb错误消息,以便客户端代码可以捕获相同的错误esb

此时我的序列'故障'配置如下:

<sequence xmlns="http://ws.apache.org/ns/synapse" name="fault" trace="enable">
   <makefault version="soap12">
     <code xmlns:soap12Env="http://www.w3.org/2003/05/soap-envelope" value="soap12Env:Receiver"/>
     <reason xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('ERROR_MESSAGE')"/>
   </makefault>
   <send/>
</sequence>

和我的代理服务的顺序序列配置如下:

<sequence xmlns="http://ws.apache.org/ns/synapse" name="InSequence" trace="enable">
   <entitlementService remoteServiceUrl="https://localhost:9443/services/" remoteServiceUserName="srxxx" remoteServicePassword="kiytr">
      <onReject/>
      <onAccept/>
      <advice/>
      <obligations/>
   </entitlementService>
   <header xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" name="wsse:Security" action="remove"/>
   <send/>
   <drop/>
</sequence>

如果有人能帮助我,我已经尝试了几种方法来解决我的客户端错误而没有成功我会非常感激

1 个答案:

答案 0 :(得分:1)

在代理服务中配置faultSequence,如下所示。在您的情况下,您必须在faultSequence中使用故障中介。

<faultSequence>
    <makefault version="soap12">
        <code xmlns:soap12Env="http://www.w3.org/2003/05/soap-envelope" value="soap12Env:Receiver"/>
        <reason xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('ERROR_MESSAGE')"/>
    </makefault>
    <send/>
</faultSequence>

有关向客户端发送错误消息所需的详细信息,请使用以下文档

[1] http://docs.wso2.org/wiki/display/ESB460/Error+Handling+and+Error+Codes

[2] http://docs.wso2.org/wiki/display/ESB460/Fault+Mediator