Popular Posts

Tuesday, February 26, 2013

How to configure soapUI to send HTTP chunked encoded requests

soapUI makes use of Apache HttpClient (based on HTTPComponents project) as the client side HTTP implementation. When submitting requests using soapUI, you may have noticed that, the requests always send Content-Length HTTP header. You can find it out in the Raw View of the request editor.

POST http://localhost:9000/services/SimpleStockQuoteService HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "urn:getQuote"
User-Agent: Jakarta Commons-HttpClient/3.1
Host: localhost:9000
Content-Length: 416

In functional and non-functional testing, we usually need to test the servers by sending HTTP requests with both Content-Length as well as chunked transfer encoding. How can we configure soapUI to send chunked encoded requests instead of Content-Length?

Step 1

Click on Global soapUI Preferences icon in the main tool bar (Or else, click on File --> Preferences)

Step 2

HTTP Settings tab will be selected by default. You will notice Chunking Threshold option. By default this is set to empty so that the chunking is disabled for any HTTP request.















Update this field with non negative integer value (e.g:- 1) and resubmit your request. You will notice chunked encoded request as shown below.

POST http://localhost:9000/services/SimpleStockQuoteService HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "urn:getQuote"
User-Agent: Jakarta Commons-HttpClient/3.1
Host: localhost:9000
Transfer-Encoding: chunked

For more information about various soapUI tips and tricks, read Web services Testing with soapUI book.

Saturday, February 16, 2013

How to connect WSO2 ESB to Apache ActiveMQ using simple authentication

There are different types of pluggable authentication mechanisms provided by Apache ActiveMQ message broker. One of the quickest and easiest mechanisms is to use simple authentication. As the name implies, it is as simple as adding authentication details to ACTIVEMQ_HOME/conf/activemq-security.xml


 <plugins>
        <!-- Configure authentication; Username, passwords and groups -->
        <simpleAuthenticationPlugin>
            <users>
                <authenticationUser username="system" password="${activemq.password}"
                    groups="users,admins"/>
                <authenticationUser username="user" password="${guest.password}"
                    groups="users"/>
                <authenticationUser username="guest" password="${guest.password}" groups="guests"/>
            </users>
        </simpleAuthenticationPlugin>


In this simple configuration, passwords of each user is defined in ACTIVEMQ_HOME/apache-activemq-5.7.0/conf/credential.properties file.


You can find more details about ActiveMQ simple authentication plugin in this blog.

Suppose, you have started Apache ActiveMQ with simple authentication. Then, any consumer of the destinations defined in your ActiveMQ broker should connect using the credentials defined under simple authentication plugin.

If WSO2 ESB needs to connect to ActiveMQ configured with simple authentication, we can simply update the broker configuration details in ESB_HOME/repository/conf/axis2/axis2.xml as shown below.

 <transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
        <parameter name="myTopicConnectionFactory" locked="false">
        	<parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
        	<parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>
                <parameter name="transport.jms.UserName">system</parameter>
                <parameter name="transport.jms.Password">manager</parameter>
         	<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter>
		    <parameter name="transport.jms.ConnectionFactoryType" locked="false">topic</parameter>
        </parameter>

        <parameter name="myQueueConnectionFactory" locked="false">
        	<parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
        	<parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>
                <parameter name="transport.jms.UserName">system</parameter>
                <parameter name="transport.jms.Password">manager</parameter>
        	<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
		    <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
        </parameter>

        <parameter name="default" locked="false">
        	<parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
        	<parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>
                <parameter name="transport.jms.UserName">system</parameter>
                <parameter name="transport.jms.Password">manager</parameter>
        	<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
		    <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
        </parameter>
    </transportReceiver>

Note that highlighted parameters (transport.jms.UserName and transport.jms.Password) which are used to connect to the broker using simple authentication.

The above configuration can be used to connect any Apache Axis2 based server (Apache Axis2, WSO2 Application Server etc..) to ActiveMQ using simple authentication.

Sunday, February 10, 2013

WSO2Con 2013 - 5 must attend talks




Anyone who missed the opportunity to attend the last WSO2Con (WSO2Con 2011 which was held in Colombo, Sri Lanka) should not miss WSO2Con 2013 which will be started on Tuesday, 12th at Park Plaza in London in sync with the live stream hosted in Colombo.
In WSO2Con 2011, I could not concentrate much on the great set of talks given by geniuses around the world. I was a speaker and I spent each minute practicing and preparing for my talk, Quality, Key to successful SOA :)
This year, I'm freed from that burden, I have the opportunity to watch and listen to the talks. Though I'm not going to miss any session from the interesting set of talks in the 2 day conference agenda, I prepared my favorite five which I should watch live from Cinnamon Lakeside, Colombo.

1. Raspberry Pi - WSO2 Style

WSO2 is THE knowledge hub in Sri Lankan software industry. I have no doubt about that. Folks at WSO2 pursuit for excellence by doing many crazy things everyday. Everyone is driven by the organizational vision of taking over the world. The perception of general public about enterprise middleware is, you always need heavy infrastructure and resources to run them. This is true for some proprietary middleware since it takes days/weeks to configure them and run a simplest use case. However, leanness is one of the primary objective of any WSO2 product. Running enterprise grade middleware in a Raspberry Pi can be a dream for some heavy weight proprietary middleware since their pre-requisites include more than 1G memory, 1G disk capacity etc.. Afkham Azeez, Sumedha Rubasinghe and  Lakmal Warusawithana are going to demonstrate how WSO2 enterprise middleware can be launched in a resource constrained environment, in the last session of conference day 1. 

2. Enterprise Identity Management and Security: Patterns and Practices

Security is a complex subject when comparing to the other aspects of SOA. However, you cannot avoid security and identity management models when building solutions. You may have come across many situations where there are enormous amount of resources publicly available for the subjects related to enterprise security, but those are explained in non-human terms using various acronyms. Prabath Siriwardhana is presenting about enterprise identity management patterns at 2PM on conference day 1. The unique ability of Prabath's is, he can explain complex subject matters in extremely simple terms. You should not miss this talk by Prabath. He will clear most of the doubts you had about enterprise security and identity management. 

3. Running operations for Carbon and Stratos

It is really important to understand the best practices associated with building operational infrastructure. It will be interesting to listen to Chamith Kumarage who will share his experience of deployment automation, scaling in the cloud, backup procedures and monitoring in enterprise middleware. Chamith will conduct his session at 2.30 PM on conference day 1.

4. Enterprise Governance with WSO2 Governance Registry and more

To achieve the true benefits of SOA, managed governance framework is a primary necessity. WSO2 Governance Registry provides users with the facilities to achieve all aspects of SOA governance including design and run-time governance, life cycle management, development process governance etc..
Senaka Fernando, the SOA governance expert at WSO2, presents how SOA governance can be adopted in an organization to realize competitive advantage, in his session at 1.30 PM on the conference day 2.  

5. Enabling a Data-Driven agile business

The talk given by Tharindu Mathew in WSO2Con 2011 was really interesting. He did that in very interactive manner asking many questions from the audience. During that session, he introduced WSO2 Business Activity Monitor and explained the key features provided by a business activity monitoring tool in general. Now, in WSO2Con 2013, Tharindu is going to demonstrate how users can get most out of data stored in your systems using WSO2 Business Activity Monitor. His session will be held at 4.30 PM of the conference day 1.


Friday, February 8, 2013

How to preserve User-Agent HTTP header when messages passing through WSO2 ESB

When WSO2 ESB forwards a request to the back-end web service, ESB alters the User-Agent of the incoming request and sets it to Synapse-HttpComponent-NIO.

Suppose, you want to avoid this and preserve User-Agent header sent by client. You can simply do it using the following method.

Step 1

Open ESB_HOME/repository/conf/nhttp.properties file

Step 2

Add the following property and save nhttp.properties file.

http.user.agent.preserve=true


Step 3

Restart ESB and send a HTTP request to ESB. Monitor the HTTP traffic between ESB and the back-end web service. You will see the User-Agent value is not altered by ESB.

HTTP headers of the inbound request (client to ESB)

POST http://localhost:8280/services/Axis2Proxy HTTP/1.1

Accept-Encoding: gzip,deflate

Content-Type: text/xml;charset=UTF-8

SOAPAction: "urn:echoString"

User-Agent: Jakarta Commons-HttpClient/3.1

Host: localhost:8280

Content-Length: 299


HTTP headers of the outbound request (ESB to back-end service)

POST /services/Axis2Service HTTP/1.1

Content-Type: text/xml; charset=UTF-8

Accept-Encoding: gzip,deflate

User-Agent: Jakarta Commons-HttpClient/3.1

SOAPAction: "urn:echoString"

Transfer-Encoding: chunked

Host: 127.0.0.1:9765

Connection: Keep-Alive