Wednesday, August 26, 2015

Using Validate Mediator with source defined

In WSO2 ESB, you can use validate mediator to define your custom xsd, and validate the input you are getting. If it doesn't comply to the given xsd, you can execute a custom flow and send a fault message. Most examples available is where you don't define the source property so that the first child of the SOAP request will be evaluated. This is just a sample proxy that shows how you can add the xpath to source property.


<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="validateProxy"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <log level="full">
            <property name="Message" value="Inside Insequance"/>
         </log>
         <validate xmlns:nfs="http://www.example.org/testWSO2/"
                   source="//nfs:CustomerReq/Customer">
            <schema key="conf:/validateCustomer.xsd"/>
            <on-fail>
               <log level="custom">
                  <property name="MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
               </log>
               <makefault version="soap11">
                  <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/>
                  <reason value="Invalid request received"/>
               </makefault>
               <send/>
               <drop/>
               <property name="RESPONSE" value="true"/>
               <header name="To" expression="get-property('ReplyTo')"/>
            </on-fail>
         </validate>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>

                             
A sample request for above would be like,
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:nfs="http://www.example.org/testWSO2/">
<soapenv:Header/>
<soapenv:Body>
<nfs:CustomerReq  xmlns:nfs="http://www.example.org/testWSO2/">
  <Customer>
      <customerid>str1234</customerid>
      <amount>3.1415926535</amount>
      <officeid>str1234</officeid>
      <homeid>str1234</homeid>
    </Customer>
</nfs:CustomerReq>
</soapenv:Body>
</soapenv:Envelope> 


Finally you can add your xsd file to mentioned location in schema key. (Under browse->resources->config ->add resource)

Friday, August 21, 2015

Common issues when creating API Manager cluster

There are some common issues faced when users create WSO2 API manager clusters. Here are some points you could follow when troubleshooting.

1.  Make sure all relevant nodes are added in each others' axis2.xml cluster members. For example, if you have 4 Gateway nodes (2 Managers and 2 Workers) you need to make sure that you add all other members under cluster members (axis2.xml) , so that all the nodes are synced up. If this is not done properly, you might come across issues where some of your nodes are not updated with all changes.(Missing apis,missing edits done for apis)


You can check if all nodes are getting synced properly , by checking repository/deployment/server/synapsconfig/default/apis   sections of each node and see if all published APIs are listed.

2.  When you are fronting gateway nodes with a load balancer, your publisher/store node's api-manager.xml should point to the load balancer url.

3. When you are installing an external key manager (WSO2 Identity Server) , make sure that you set the url of IS, in <APIKeyManager> section of api-manager.xml.

Installing features in WSO2 products

When you are installing features in WSO2 products, make sure you look into following matrix. So that you can identify the supported platform version and related product version.

http://wso2.com/products/carbon/release-matrix/