Saturday, February 15, 2014

Sending mails using mail transport in wso2esb


If any error occurs in a message mediation flow, Administrator has to send mail to manager.

Axis configuration

To send mails, we use mail transport. Enable the 'MailTransportSender' to send emails in specific scenarios.


<transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
        <parameter name=""></parameter>
       <parameter name="mail.smtp.port">587</parameter>
       <parameter name="mail.smtp.starttls.enable">true</parameter>
       <parameter name="mail.smtp.auth">true</parameter>
       <parameter name="mail.smtp.user"></parameter>
        <parameter name="mail.smtp.password">XXXXX</parameter>
       <parameter name="mail.smtp.from">Admin</parameter>

Proxy configuration

 <proxy xmlns=""
    <target faultSequence="sendErrMailSequence">


To get  a mail content in HTML format, we need to add HTML message formatter in axis2.xml
<messageFormatter contentType="text/html" class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>

SendErrMailSequence  configuration

<sequence xmlns="" name="sendErrMailSequence">
   <property name="messageType" value="text/html" scope="axis2"/>
   <property name="ContentType" value="text/html" scope="axis2"/>
  <property name="Subject" value=" Error occured" scope="transport"/>
   <property name="OUT_ONLY" value="true"/>
 <payloadFactory media-type="xml">
               <soapenv:Envelope xmlns:soapenv="">
                     <ErrorMessage xmlns=""> Please check endpoint errors</ErrorMessage>
      <endpoint name="MailEpr">
         <address uri=""/>


Friday, February 14, 2014

XML to Text transformation using smooks mediator

Smooks mediator can be used to apply transformations. Inputs can be provided as text/xml and smooks transformation resource has to be passed as an external resource.
Here is the sample smooks mediator configuration and smooks configuration which can be used to read an xml element from the input and parse it to a preferred output xml format.

Smooks meditaor config;

<smooks config-key="smooks">
               <input type="xml" expression="//csv/arg0"/>
               <output type="text"/>

Sample request;

<soapenv:Envelope xmlns:soapenv= >

Smooks configuration;

<smooks-resource-list xmlns="">
   <resource-config selector="org.xml.sax.driver">
    <param name="fields" type="string-list">RecordID,FileNumber,CorporationName</param>

<soapenv:Envelope xmlns:soapenv="">
<ax:text xmlns:ax="">
<csv-record number="1">

Thursday, February 13, 2014

Creating OMElement from a list of Array Elements

Creating an  OMElement  from an Array of elements , requires a custom xml root element, which will wrap all arguments.
Here is a sample code snippet to do that;

String[] csvArray = csvList.toArray(new String[csvList.size()]);
OMElement csvOMElement =  BeanUtil.getOMElement(qname, csvArray, null, false, null);

qname = new QName("csv"); // here user can  provide  prefered root element for his OMelement.

Monday, February 3, 2014

SAML 2.0 service provider meta file for WSO2 IS

SAML2.0 identity providers and service providers has to provide a SAML 2.0 metadata file representing entities. Metadata documents provided by a service provider must include an <md:SPSSODescriptor> element containing all necessary elements and identity provider must include an < md:IDPSSODescriptor> element which containing all necessary elements.

WSO2 Identity server can be configured as  a single sign on system, where it can act as identity provider and service provider. There is no option to generate meta files in WSO2 IS. User has to manually write IDP/SP meta files and need to import with other third party systems.
Here is a sample Service-provider meta file for WSO2 IS, which can be used with third party identity providers.