Saturday, November 26, 2011

How to read HTTP headers through Synapse Config

You can use the following property mediator to read HTTP headers inside WSO2 ESB through Synapse Configuration.
<property name="Lang" expression="get-property('transport', 'Accept')"/>

Here, the value of the HTTP header called "Accept" get assigned in to property called "Lang"

Thursday, November 24, 2011

How to apply throttling policies through service.xml

You can always apply throttling to services deployed in WSO2 AS using the Management console. But what if you want to apply the throttling policy while the service get deployed. Then you can specify the throttling policy in the service.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file was auto-generated from WSDL -->
<!-- by the Apache Axis2 version: 1.6.1-wso2v1  Built on : Jun 08, 2011 (07:37:38 IST) -->
<serviceGroup>
    <service name="echo">
        <messageReceivers>
            <messageReceiver mep="http://www.w3.org/ns/wsdl/in-out" class="org.wso2.carbon.sample.service.echo.EchoMessageReceiverInOut"/>
        </messageReceivers>
        <parameter name="ServiceClass">org.wso2.carbon.sample.service.echo.EchoSkeleton</parameter>
        <parameter name="useOriginalwsdl">true</parameter>
        <parameter name="modifyUserWSDLPortAddress">true</parameter>
        <operation name="echoString" mep="http://www.w3.org/ns/wsdl/in-out" namespace="http://echo.services.core.carbon.wso2.org">
            <actionMapping>urn:echoString</actionMapping>
            <outputActionMapping>urn:echoStringResponse</outputActionMapping>
            <faultActionMapping faultName="echoFault">urn:echoFaultMessage</faultActionMapping>
            <faultActionMapping faultName="EchoFault">urn:echoFaultMessage</faultActionMapping>
            <faultActionMapping faultName="EchoFault_Exception">urn:echoFaultMessage</faultActionMapping>
        </operation>
        <operation name="throwAxisFault" mep="http://www.w3.org/ns/wsdl/in-out" namespace="http://echo.services.core.carbon.wso2.org">
            <actionMapping>urn:throwAxisFault</actionMapping>
            <outputActionMapping>urn:throwAxisFaultResponse</outputActionMapping>
        </operation>
        <operation name="echoStringArrays" mep="http://www.w3.org/ns/wsdl/in-out" namespace="http://echo.services.core.carbon.wso2.org">
            <actionMapping>urn:echoStringArrays</actionMapping>
            <outputActionMapping>urn:echoStringArraysResponse</outputActionMapping>
        </operation>
        <operation name="echoOMElement" mep="http://www.w3.org/ns/wsdl/in-out" namespace="http://echo.services.core.carbon.wso2.org">
            <actionMapping>urn:echoOMElement</actionMapping>
            <outputActionMapping>urn:echoOMElementResponse</outputActionMapping>
        </operation>
        <operation name="echoInt" mep="http://www.w3.org/ns/wsdl/in-out" namespace="http://echo.services.core.carbon.wso2.org">
            <actionMapping>urn:echoInt</actionMapping>
            <outputActionMapping>urn:echoIntResponse</outputActionMapping>
        </operation>
 
       <module ref="wso2throttle"/>
       <wsp:Policy wsu:Id="WSO2ServiceThrottlingPolicy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <wsp:ExactlyOne>
    <wsp:All>
      <throttle:ServiceThrottleAssertion xmlns:throttle="http://www.wso2.org/products/wso2commons/throttle">
        <wsp:Policy>
          <throttle:ID throttle:type="DOMAIN">172.16.49.1</throttle:ID>
          <wsp:Policy>
            <throttle:Control>
              <wsp:Policy>
                <throttle:MaximumCount>2</throttle:MaximumCount>
                <throttle:UnitTime>20000</throttle:UnitTime>
                <throttle:ProhibitTimePeriod wsp:Optional="true">30000</throttle:ProhibitTimePeriod>
              </wsp:Policy>
            </throttle:Control>
          </wsp:Policy>
        </wsp:Policy>
        <wsp:Policy>
          <throttle:ID throttle:type="DOMAIN">other</throttle:ID>
          <wsp:Policy>
            <throttle:Deny/>
          </wsp:Policy>
        </wsp:Policy>
      </throttle:ServiceThrottleAssertion>
    </wsp:All>
  </wsp:ExactlyOne>
</wsp:Policy>
    </service>
</serviceGroup>

Tuesday, August 9, 2011

WSO2Con 2011

Architects, Developers, IT Managers and technology enthusiasts, WSO2Con 2011, focuses on you! Newbie or seasoned professional, WSO2Con offers a great week of learning, sharing and the opportunity to connect with experts who have shaped the future enterprise. Register here

Sunday, April 3, 2011

How to hide vertical grid lines in jQuery flot

There is a straight forward method to hide vertical or horizontal grid lines in your jQuery flot bar chart. First of all you need to checkout the flot trunk and include jquery.flot.js and jquery.flot.stack.js scripts in your script. You need the trunk, since released flot - 0.6 does not support this feature.

Then include the following as the options.
xaxis: {
  tickLength: 0
}

 i.e.
<script id="source">
$(function () {
    var d1 = [];
    for (var i = 0; i <= 10; i += 1)
        d1.push([i, parseInt(Math.random() * 30)]);
 
    var d2 = [];
    for (var i = 0; i <= 10; i += 1)
        d2.push([i, parseInt(Math.random() * 30)]);
 
    var d3 = [];
    for (var i = 0; i <= 10; i += 1)
        d3.push([i, parseInt(Math.random() * 30)]);
 
    var stack = 0, bars = true, lines = false, steps = false;
 
    function plotWithOptions() {
        $.plot($("#placeholder"), [ d1, d2, d3 ], {
            series: {
                stack: stack,
                lines: { show: lines, steps: steps },
                bars: { show: bars, barWidth: 0.6, align: "center" }
            },
            xaxis: { tickLength: 0}
        });
    }
 
    plotWithOptions();
});
</script>






Friday, March 4, 2011

How to list all svn externals recursively

You can use the following command to list all the svn externals in a directory structure.

svn propget svn:externals -R

Wednesday, March 2, 2011

How to get the transitive dependency list using Maven

You may need to find the list of transitive dependencies, so that you can exclude unnecessary dependencies. Add the following maven plugin

  <build>
      <plugins>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
         </plugin>
      </plugins>
   </build>

Use dependency:tree as the goal.

mvn clean install dependency:tree

If maven fails with some error, then, use dependency:tree as the goal with -X option.

mvn clean install dependency:tree -X

Sample:

com.hp.hpl.jena.wso2:arq:bundle:1.0.0.wso2v1
+- com.ibm.icu:icu4j:jar:3.8:compile
\- com.hp.hpl.jena:arq:jar:2.8.3:compile
   +- com.hp.hpl.jena:jena:jar:2.6.2:compile
   |  +- org.slf4j:slf4j-log4j12:jar:1.5.6:runtime
   |  \- log4j:log4j:jar:1.2.13:runtime
   +- com.hp.hpl.jena:iri:jar:0.8:compile
   +- org.codehaus.woodstox:wstx-asl:jar:3.2.9:compile
   |  \- stax:stax-api:jar:1.0.1:compile
   +- org.apache.lucene:lucene-core:jar:2.3.1:compile
   +- junit:junit:jar:3.8.1:compile (version managed from 4.5)
   +- org.slf4j:slf4j-api:jar:1.5.8:compile
   \- xerces:xercesImpl:jar:2.7.1:compile
------------------------------------------------------------------------

Tuesday, February 8, 2011

How to Deploy WSO2 BPS on JBoss

This article from Pavithra provides step by step directions to deploy WSO2 BPS 2.0.2 in JBoss 5.1.0 GA.
WSO2 BPS can also be installed on other application servers as well. Refer Oxygen Tank for more information.

Monday, February 7, 2011

Orchestration vs Choreography

Service orchestration and service choreography are widely spoken topics when it comes to service composition. Lets take a look at the definitions.

Orchestration

Analogy: Orchestra

Applause

The conductor of the orchestra is the one who knows the entire composition. The musicians in the orchestra do not necessarily have to know what other musicians part or what they do. The musicians just have to know how play their instrument in which they best at. The conductor orchestrate the group of musicians to achieve the final output (composition).

Orchestration is the coordination of web services in order to compose the business processes. The business process plays the role of orchestrator/conductor and coordinate the services to fulfill the business process. The individual web services do not aware (it is not necessarily need to know) of the other services involved in the process and the services even do not know that they participate in a business process, they just serve the requests. WS-BPEL specification is an example. WS-BPEL is a language for defining processes that can be executed on an orchestration engine such as WSO2 BPS.

Choreography

Analogy: Group Dance
Hacettepe University Folk Dances Group

Each and every dancer know, exactly what to do and what other dances will do. They synchronize them selves according to the other dances.  The dancers aware of the each others moves.

Therefore, in choreography, services do not rely on a central coordinator. Each of the service, knows exactly when to execute them selves and when to talk to its peers and sync up. WS-CDL standard is an example.

References: http://www.infoq.com/news/2008/09/Orchestration