Tuesday, October 18, 2011

WSO2 Carbon Studio: How to specify the namespace to a synapse artifact (endpoint/sequence/proxy/local entry)

Synapse changed it default namespace from "http://ws.apache.org/ns/synapse" to "http://synapse.apache.org/ns/2010/04/configuration" with its version 2.0 release. So when you are going to create a synapse artifact you need to decide which namespace you are going to use and how to specify it. This short KB tell you how to get it done in easy steps.
Date: Thu, 21st Oct, 2010
Level: Introductory
Reads: 1036 Comments: 0 | Login or register to post comments
Saminda Wijeratne
Senior Software Engineer
WSO2 Inc
samindaw's picture

Applies To

Projects: ESB, Carbon Studio
Note: The Synapse artifact which I have referred here can be a synapse configuration file, an endpoint, a sequence, a proxy server or a local entry


Determining which namespace to use is easy if you know which carbon server version you are going to deploy the synapse artifacts.
  • If you are going to deploy the synapse artifacts in to a carbon server version 3.0.1 or before (also ESB server version 3.0.1 or before), then you need to use the old synapse namespace version which is "http://ws.apache.org/ns/synapse". 
  • From carbon version 3.1 onwards (i.e. ESB server version 4.0 onwards) you are required to use the namespace "http://synapse.apache.org/ns/2010/04/configuration" in all your synapse configurations. 

Now that you know which namespace to use lets see how you can specify it.
When you create a new synapse configuration through Carbon Studio ESB tools there is a namespace applied to them by default. You can specify this default namespace through the Carbon Studio preferences.
  1. From the main menu select
    • Window -> Preferences
  2. In left handside tree, you will find the preference page "ESB" under the category "Carbon Studio"
  3. Select the "ESB" preference page 
  4. At the right hand side the preference page will show settings related to ESB.
  5. Change the setting "Default namepsace" by selecting the namespace you want from the drop down list (which contains the namespaces available)
  6. Click "Apply"
  7. Click "OK"
  8. Now when you create new synapse artifacts the namespace specified in them by default will be the namespace you've just selected.
Once you have created a synapse artifact inside Carbon Studio or have imported to Carbon Studio, if you need to change the namespace, you will have to use the source view.
  1. Double click to open the synapse artifact file
    • Note that you may use either the ESB editor or the standard XML editor in Eclipse for this
  2. Select the "Source" tab in the multi-page editor which just opened
  3. On the document element (the root element) of the synapse artifact there will be an attribute called "xmlns" and it is this attribute which corresponds to the namespace of the main synapse artifact
  4. Specify the required namespace as the value of the "xmlns" attribute
  5. Note that there could be other namespaces defined in the root element with different namespace prefixes. Their namespaces should not be altered unless the context requires you to do so 
Author : Saminda Wijeratne, Product Manager WSO2 Tools, WSO2 Inc, samindaw@wso2.co

No comments:

Post a Comment