WSO2 ESB
WSO2 ESB Learnings
To get HTTP Status code in a sequence
<property name="httpSc" expression="$axis2.HTTP_SC" />
Custom Make Fault in WSO2
1. Build payload factory with ERROR_CODE and ERROR_MESSAGE set by ESB when error occurs in mediation.<payloadFactory media-type="xml">
<format>
<Errors xmlns="http://wso2.com/make/fault">
<Error>
<ErrorCode>$1</ErrorCode>
<ErrorMessage>$2</ErrorMessage>
</Error>
</Errors>
</format>
<args>
<arg evaluator="xml" expression="get-property('ERROR_CODE')" />
<arg evaluator="xml" expression="get-property('ERROR_MESSAGE')" />
</args>
</payloadFactory>
2.Extract the "Errors" node and store in property as of type "OM" element.
<property xmlns:e="http://wso2.com/make/fault" name="ERRORS" expression="//e:Errors" type="OM"/>
3. Build "makefault" and add the "ERRORS" property to detail tag.
<makefault version="soap11">
<code xmlns:soap11="http://schema.xml.soap.org/soap/envelope" value="soap11:Server" />
<reason expression="get-property('ERROR_DETAIL')" />
<role>None</role>
<detail expression="get-property('ERRORS')" />
</makefault>
Access Parameters from axis2.xml inside custom mediator.
Locaion of axis2.xml in WSO2 ESB :/repository/conf/axis2/axis2.xml
Parameter entry inside axis2.xml
Access the parameter defined in axis2.xml inside custom mediator as
public boolean mediate(MessageContext messageContext) {
String transManager= messageContext.getConfigurationContext().getAxisConfiguration()
. getParameter("TransactionManagerJNDIName").getValue().toString();
}
To get ip address or host of client who sent request to WSO2 ESB in a Sequence
<property name="clientIp" expression="get-property('axis2', 'REMOTE_ADDR')"/>
<property name="clientHost" expression="get-property('axis2', 'REMOTE_HOST')"/>
If request reaches ESB via Proxy
To get HTTP Status code in a sequence
<property name="httpSc" expression="$axis2.HTTP_SC" />
Custom Make Fault in WSO2
1. Build payload factory with ERROR_CODE and ERROR_MESSAGE set by ESB when error occurs in mediation.<payloadFactory media-type="xml">
<format>
<Errors xmlns="http://wso2.com/make/fault">
<Error>
<ErrorCode>$1</ErrorCode>
<ErrorMessage>$2</ErrorMessage>
</Error>
</Errors>
</format>
<args>
<arg evaluator="xml" expression="get-property('ERROR_CODE')" />
<arg evaluator="xml" expression="get-property('ERROR_MESSAGE')" />
</args>
</payloadFactory>
2.Extract the "Errors" node and store in property as of type "OM" element.
<property xmlns:e="http://wso2.com/make/fault" name="ERRORS" expression="//e:Errors" type="OM"/>
3. Build "makefault" and add the "ERRORS" property to detail tag.
<makefault version="soap11">
<code xmlns:soap11="http://schema.xml.soap.org/soap/envelope" value="soap11:Server" />
<reason expression="get-property('ERROR_DETAIL')" />
<role>None</role>
<detail expression="get-property('ERRORS')" />
</makefault>
Access Parameters from axis2.xml inside custom mediator.
Locaion of axis2.xml in WSO2 ESB :
Parameter entry inside axis2.xml
<parameter name=
"TransactionManagerJNDIName"
>TransactionManager</parameter>
Access the parameter defined in axis2.xml inside custom mediator as
public boolean mediate(MessageContext messageContext) {
String transManager= messageContext.getConfigurationContext().getAxisConfiguration()
. getParameter("TransactionManagerJNDIName").getValue().toString();
}
To get ip address or host of client who sent request to WSO2 ESB in a Sequence
<property name="clientIp" expression="get-property('axis2', 'REMOTE_ADDR')"/>
If request reaches ESB via Proxy
<property name="clientHost" expression="$trp:X-Forwarded-For"/>
Remote Debugging
1, Navigate to <<WSO2ESBHOME>>/bin and Start the WSO2 ESB server using the following command.
> wso2server.bat -debug 5005
where 5005 is the port.
2.
Property Scopes
XPATH functions Used
concat
Comments
Post a Comment