Powered By Blogger

Dec 29, 2014

Get a JSON response with WSO2 DSS


WSO2 Data Services Server supports for both XML and JSON outputs and in order to receive the message as JSON you need to change following configurations.
You can achieve this by enabling the 'content negotiation' property in the axis2.xml file and axis2_client.xml file. Also you should send the requests to the server by adding the "Accept:Application/json" to the request header, and as a result, DSS will return the response in JSON format. Please follow the below steps 

1. In axis2.xml file at <DSS_HOME>/repository/conf/axis2, include the following property 

<parameter name="httpContentNegotiation>true</parameter> 

2. In axis2_client.xml file at <DSS_HOME>/repository/conf/axis2 enable the following property 

<parameter name="httpContentNegotiation>true</parameter> 

3. When sending the request please make sure to add the "Accept:Application/json" to the request header 

Note that if you are using tenant, then the above parameter need to be set in 'tenant-axis2.xml' as well.
Now you can use the ResourceSample, which is a sample available in your DSS distribution to test the result. Send a request to the server using  CURL by adding “Accept:Application/json” to the request header as shown below.

curl -X GET -H "Accept:application/json" http://localhost:9763/services/samples/ResourcesSample.HTTPEndpoint/product/S10_1678

XML to JSON conversion using a proxy in WSO2 ESB

This post describes about the way to convert an XML payload into JSON. Basically this can be achieved by using the property "messageType" in synapse configuration.

The property is as follows.

<property name="messageType" value="application/json" scope="axis2"/>

I have created a proxy called TestProxy with the  SimpleStockQuote endpoint as follows.

 <?xml version="1.0" encoding="UTF-8"?>  

 <proxy xmlns="http://ws.apache.org/ns/synapse"  

 name="TestProxy"  

 transports="https,http"  

 statistics="disable"  

 trace="disable"  

 startOnLoad="true">  

 <target>  

 <inSequence>  

 <property name="messageType" value="application/json" scope="axis2"/>  

 <log level="full"/>  

 <send>

 <endpoint>  

 <address uri="http://localhost:9000/services/SimpleStockQuoteService/"/>  

 </endpoint>  

</send>
 </inSequence>  

 <outSequence>  

 <send/>  

 </outSequence> 

 </target>  

 <description/>  

 </proxy>   



In order to invoke this proxy you can follow below steps.

1. Build the SimpleStockQuote Service at <ESB_HOME>/samples/axis2Server/src/SimpleStockQuoteService by running "ant" command

2. Then start sample backend to recover the response which is provided with WSO2 ESB by navigating to <ESB_HOME>/samples/axis2Server and enter the command "sh axis2Server.sh"

3. Send the below SOAP request to proxy service using SOAP UI.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m0="http://services.samples" xmlns:xsd="http://services.samples/xsd">  

 <soapenv:Header/>  

 <soapenv:Body>  

 <m0:getQuote xmlns:m0="http://services.samples" id="12345">  

 <person>Anvar</person>  

 <person>Porter</person>  

 <person>Raj</person>  

 <m0:request>  

 <m0:symbol>A</m0:symbol>  

 </m0:request>  

 </m0:getQuote>  

 </soapenv:Body>  

 </soapenv:Envelope>  

Response should be as follows:

 HTTP/1.1 200 OK  

 Host: sohani-ThinkPad-T530:8280  

 SOAPAction: "urn:getQuote"  

 Accept-Encoding: gzip,deflate  

 Content-Type: application/json  

 Date: Fri, 29 Dec 2014 09:00:00 GMT  

 Server: WSO2-PassThrough-HTTP  

 Transfer-Encoding: chunked  

 Connection: Keep-Alive  

 {"getQuote":{"@id":"12345","person":{"@id":"12345","@sex":"female","@target":"urn:getQuote","firstname":"Anna","lastname":{"@id":"12345678","$":"Smith"}},"request":{"symbol":"A"}}}  

Dec 1, 2014

OAuth 2.0 Implicit Grant with WSO2 API Manager

Implicit Grant type is the recommended practice if the client is a browser based application such as a JavaScript client. Mainly client receives access token as the result of the authorization request. Also this doesn't include client authentication because it does not make use of client secret. 

You can find the sample web application at http://sourceforge.net/projects/charithablogsam/files/.

Setting up Client

Download playground2.0.war from the above link and copy it to TOMCAT_HOME/webapps directory. Make sure to update the following parameters in WEB-INF/web.xml 

<servlet>
        <servlet-name>oAuth2ClientServlet</servlet-name>
        <servlet-class>com.wso2.identity.oauth.sample.OAuth2ClientServlet</servlet-class>
        <init-param>
             <description>serverUrl</description>
             <param-name>serverUrl</param-name>
             <param-value>https://localhost:9443/services/</param-value>

<servlet>
        <servlet-name>oAuth2AccessResourcePage</servlet-name>
        <jsp-file>/oauth2-access-resource.jsp</jsp-file>
        <init-param>
            <description>setup</description>
            <param-name>setup</param-name>
            <param-value>AM</param-value>
        </init-param>


Now you can follow the below steps:

1. After setting up the client you can login to http://localhost:8080/playground2.0/ and click on  "Import Photos" icon

2. Then from the page you are getting Select Implicit as the Authorization Grant Type. Copy the consumer key value from the application you have subscribed in WSO2 API Manager and include it in Client Id text box.

3. Then include a value for scope.

4. Then include the Callback URL as  http://localhost:8080/playground2.0/oauth2client

5. After that include Authorize endpoint. This should be the endpoint of authorization server where it accepts the authorization requests. In WSO2 API Manager, there is an API to handle all authorization requests and it can be accessed through http://localhost:8280/authorize.

6. Next click on  Authorize.

Then you have to provide user name and password (username and password of the resource owner/end user).

Type admin/admin as user name and password respectively and click on login

Now you will receive the Access Token





Nov 20, 2014

Accessing an API without using access token

You can do this by changing the authentication level to 'None' as shown in the attached image. By default it is set to 'Application and Application User' and you can change the authentication level before Save and Publish the created API.


Invoking an API using WSO2 API manager

You can create an API to invoke the echo service in WSO2 ESB as follows

1. Start WSO2 ESB
2. Then login to WSO2 AM publisher
3. Create an API stating the production endpoint as  http://sohani-ThinkPad-T530:8280/services/echo
4. Then login to the WSO2 AM store and subscribe the API and generate the token
5. Get the prduction URL from the store to send the request
6. You can refer https://docs.wso2.com/display/AM170/Token+API about the token generation in AM
7. Now you can use the Rest client tool in AM or curl command to send the request as follows

<productionURL>/echo/echoInt?in=2




Writing a data service to execute stored procedure in WSO2 DSS

This blog post basically describes about the way to execute a stored procedure in WSO2 DSS. You can refer below steps

1. Create a sample database

CREATE DATABASE ESB_SAMPLE;

2. Create a table using below command

USE ESB_SAMPLE;
CREATE TABLE company(name VARCHAR(10), id VARCHAR(10), price DOUBLE, location VARCHAR(10));

3. Create the stored procedure as follows

CREATE PROCEDURE InsertData(compName VARCHAR(10), compId VARCHAR(10), compPrice DOUBLE, compLocation VARCHAR(10)) INSERT INTO company VALUES(compName,compId,compPrice,compLocation) ;

Now you can configure the DSS as follows

1. Download mysql connector and copy it to <DSS_HOME>/repository/components/lib

2. Create a data service as follows 

<data enableBatchRequests="true" name="SampleDataService">
  <description>Sample Data Service</description>
  <config id="Demo">
     <property name="driverClassName">com.mysql.jdbc.Driver</property>
     <property name="url">jdbc:mysql://localhost:3306/ESB_SAMPLE</property>
     <property name="username">root</property>
     <property name="password">root</property>
  </config>
  <query id="insertData" useConfig="Demo">
     <sql>Call ESB_SAMPLE.InsertData(?,?,?,?)</sql>
     <properties>
        <property name="org.wso2.ws.dataservice.query_timeout">100</property>
        <property name="org.wso2.ws.dataservice.force_jdbc_batch_requests">true</property>
     </properties>
     <param name="name" ordinal="1" sqlType="STRING"/>
     <param name="id" ordinal="2" sqlType="STRING"/>
     <param name="price" ordinal="3" sqlType="DOUBLE"/>
     <param name="location" ordinal="4" sqlType="STRING"/>
  </query>   
  <operation name="insertData" returnRequestStatus="false">
     <call-query href="insertData">
   <with-param name="name" query-param="name"/>
        <with-param name="id" query-param="id"/>
        <with-param name="price" query-param="price"/>
        <with-param name="location" query-param="location"/>        
     </call-query>
  </operation>  
</data>

3. Include the data service in <DSS_HOME>/repository/deployment/dataservices.
4. Use TryIt tool to access the data service




Setting up message tracing for WSO2 ESB


Message Tracing is basically used to trace, track and visualize a message's body of its transmission. We can use the Activity Dashboard of WSO2 BAM to trace messages going through WSO2 ESB.

First of all you need to install the message tracer feature to WSO2 ESB by following the below steps


1. Login to WSO2 ESB and select Features

2. In the Repository Management tab click Add Repository
3. Insert a name and the URL (http://dist.wso2.org/p2/carbon/releases/turing/)
4.Go to the Available Features tab and select the added repository. Under Filter by feature name field, enter BAM Message Tracer Handler Aggregate, select Show only the latest versions checkbox and click Find Features.5. The BAM Message Tracer Handler Aggregate feature appears. Select it and click Install.6. Click Finish to complete the installation.


Now in order to configure message tracing follow below steps


1. Go to the Configure menu of ESB Management Console, click Message Tracing and then click Message Tracing Configuration.2. Select all the check boxes and enter Receiver URL ((in  tcp://[IP address of localhost]:[thrift port] format), Username and Password that is used by BAM. 3. Click update.


Please note if you change the offset, change the receiver port accordingly. if the offset is 0 port is 7611, if offset is 1 it should be 7612.


Then you can publish data to BAM


1. Invoke the service

2. Login to WSO2 BAM
3.  Go to Tools menu, click Cassandra Explorer and then click Explore ClusterEnter the default values as localhost:9160, admin and admin respectively for Connection URL, Username and Password and click Connect.  

If the port offset is 1 then this should be localhost:9161


4. 
In Keyspaces, check for the published contents in the BAM_MESSAGE_TRACE column family, which is located in the EVENT_KS keyspace.


Oct 4, 2014

How to use SimpleHTTPServer

In this post it shows how you can setup a web server to serve content with minimal effort.

The SimpleHTTPServer module comes with Python and it is a simple HTTP server that
provides standard GET and HEAD request handlers. The main advantage is you don't need to install and configure anything. The only thing you need is to have Python installed in your machine.

You can use this to turn any directory in your system into your web server directory.

To start a HTTP server on port 8000 (which is the default port), simple type:

python -m SimpleHTTPServer [port]

This will now show the files and directories which are in the current working
directory.

You can also change the port to something else:

$ python -m SimpleHTTPServer 8080

In your terminal, cd into the directory you wish to have accessible via browsers and HTTP.
and then enter, 

$ python -m SimpleHTTPServer

After you hit enter, you should see the following message:

Serving HTTP on 0.0.0.0 port 8000 ...

Open your browser and put in any of the following addresses:

http://your_ip_address:8000
 
If you don't have an index.html file in the directory, then all files and directories will be listed.

As long as the HTTP server is running, the terminal will update as data are loaded from the Python web server. 

Removing additional namespace prefixes in the SOAP Fault using a Class Mediator


In the previous post I have described how to use an xslt mediator to remove unwanted namespace prefixes in the SOAP Fault. This blog post describes how to accomplish that task using a simple Class Mediator.

You can fine more information about how to implement a class mediator at [1].

Sample implementation of the Class Mediator is as follows

package org.wso2.sample.mediator;

import java.util.Iterator;
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMNode;
import org.apache.axiom.om.OMText;
import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPFault;
import org.apache.synapse.MessageContext;
import org.apache.synapse.mediators.AbstractMediator;

/**
 * 
 * This class removes the additional axis2 namespace prefixes and creates a new
 * OMElement
 * 
 */
public class Axis2NSPrefixRemoveMediator extends AbstractMediator {

 private static final String AXIS2_NAMESPACE_PREFIX = "axis2ns";
 private static final String CLONED_ROOT = "ClonedDetail";

 public boolean mediate(MessageContext synCtx) {
 
        SOAPBody soapBody = synCtx.getEnvelope().getBody();
  
           //Check for a Fault
 if(soapBody.hasFault()){
  SOAPFault  faultNode = soapBody.getFault();
   
    // Retrieves the Detail Element
 OMElement detailNode = faultNode.getDetail();
   
 if (detailNode.getChildElements().hasNext()) {

 Iterator<?> complexElement = detailNode.getChildElements();
 OMFactory fac = OMAbstractFactory.getOMFactory();
    
 // Creates a clone from detail element
 OMElement clonedRoot = fac.createOMElement(new QName(CLONED_ROOT));
    
 //For every child creates a cloned element without axis2ns prefix
 getChildrenRecursively(fac, clonedRoot, complexElement);

  if (clonedRoot.getChildElements().hasNext()) {
     
  // Detach the fault body
  Iterator<?> children = detailNode.getChildElements();
  while (children.hasNext()) {
   ((OMNode) children.next()).detach();
    }
     
  // Attach the new fault body
  Iterator<?> clonedChildren = clonedRoot.getChildElements();
  while (clonedChildren.hasNext()) {
   detailNode.addChild((OMElement) clonedChildren.next());
    }
   }
      }
  }
 
  return true;
 }

 /**
  * 
  * @param fac OMFactory
  * @param root root element of the detail block
  * @param complexElement children of the detail block
  * @return final list of elements
  */
private OMElement getChildrenRecursively(OMFactory fac, OMElement root, Iterator<?> complexElement) {

 while (complexElement.hasNext()) {

 Object next = complexElement.next();
 if  (next instanceof OMElement) {
   
 OMElement element = (OMElement) next; 
 // Creates the new OMElement excluding additional namespace prefixes
 OMElement duplicateElement = createNewOMElement(fac, element);
 
 if (element.getChildElements().hasNext()) {
getChildrenRecursively(fac, duplicateElement, element.getChildElements());
     
 //Add to root at the end of populating the child
 root.addChild(duplicateElement);
 } else {
 // If no more children add it to root
  root.addChild(duplicateElement);
  }
      }
          }

  return root;
 }

 /**
  * 
  * @param fac OMFactory
  * @param element complex element
  * @return duplicated new OMElement
  */
 private OMElement createNewOMElement(OMFactory fac, OMElement element) {

  OMElement duplicateElement = null;
  String elementText = element.getText();

  // Set Namespace
  duplicateElement = setNameSpaces(fac, element);
  // Set Attributes
  setAttributes(element, duplicateElement);
  // Set text
  setTextValues(fac, duplicateElement, elementText);

  return duplicateElement;

 }

 /**
  * 
  * @param fac OMFactory
  * @param rootElement newly created OMElement
  * @param elementText Text of the element
  */
 private void setTextValues(OMFactory fac, OMElement rootElement, String elementText) {
  // Includes the text as a child
  if (elementText != null && !elementText.isEmpty()) {
   OMText omText = fac.createOMText(elementText);
   rootElement.addChild(omText);
  }
 }

 /**
  * 
  * @param element complex element
  * @param tempElement newly created OMElement
  */
 private void setAttributes(OMElement element, OMElement tempElement) {
  // Get the attributes
  Iterator<?> allAttributes = element.getAllAttributes();

  while (allAttributes.hasNext()) {
  tempElement.addAttribute((OMAttribute) allAttributes.next());
  }
 }

 /**
  * 
  * @param fac OMFactory
  * @param tempElement newly created OMElement
  * @return OMElement without axis2 namespace prefix
  */
 private OMElement setNameSpaces(OMFactory fac, OMElement tempElement) {

  String name = tempElement.getLocalName();
  OMNamespace namespace = tempElement.getNamespace();

  if (name != null && namespace != null) {

  String namespaceURI = namespace.getNamespaceURI();
  String namespacePrefix = namespace.getPrefix();
  if (namespacePrefix.startsWith(AXIS2_NAMESPACE_PREFIX)) {
  // Removes additional namespaces  
String emptyNamespacePrefix = namespace.getPrefix().replace(namespacePrefix, "");
OMNamespace modifiedNamespace = fac.createOMNamespace(namespaceURI, emptyNamespacePrefix);
 // Creates the final OMElement with correct namesapce
  tempElement = fac.createOMElement(name, modifiedNamespace);
   }
  }else{
   tempElement = fac.createOMElement(name, namespace);
  }
  return tempElement;
 }

}

Please refer [2] for more information about configuring the class mediator in synapse configuration

[2]  https://docs.wso2.com/display/ESB481/Class+Mediator

Sep 28, 2014

Removing additional namespace prefixes in the SOAP Fault using xslt


As some of you all know there is a limitation with AXIOM where is generates additional namespace prefixes inside the SOAP Fault. In order to get rid of the issue you can include a namespace prefix to the fault message generates from the Fault Mediator before sending back. You can easily do this by using an XSLT mediator. Please refer the proxy configuration and the xslt as a sample. 


TestProxy


<proxy xmlns="http://ws.apache.org/ns/synapse" name="TestProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> 

    <target> 
        <inSequence> 
            <makefault version="soap11" response="true"> 
                <code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:VersionMismatch"/> 
                <reason value="Test the SOAP Message"/> 
                <role/> 
                <detail expression="/*[local-name()='Envelope']/*[local-name()='Body']/*"/> 
            </makefault> 
            <xslt key="prefixSet" source="//detail/child::node()"/> 
            <send/> 
        </inSequence> 
    </target> 
    <description/> 

</proxy> 



prefixSet.xslt 


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://some.data" version="1.0"> 

        <xsl:output omit-xml-declaration="yes" indent="yes"></xsl:output> 
        <xsl:strip-space elements="*"></xsl:strip-space> 
        <xsl:template match="node()|@*"> 
            <xsl:copy> 
                <xsl:apply-templates select="node()|@*"></xsl:apply-templates> 
            </xsl:copy> 
        </xsl:template> 
        <xsl:template match="*"> 
            <xsl:element name="ns0:{name()}" namespace="http://some.data"> 
                <xsl:copy-of select="namespace::*"></xsl:copy-of> 
                <xsl:apply-templates select="node()|@*"></xsl:apply-templates> 
            </xsl:element> 
        </xsl:template> 
    </xsl:stylesheet> 

This transformation applies for the fault message and includes in the OMElement created, and provides a response with a predefined namespace prefix as follows.



<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

   <soapenv:Body>
      <soapenv:Fault>
         <faultcode xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/">soap11Env:VersionMismatch</faultcode>
         <faultstring>Test the SOAP Message</faultstring>
         <detail>
            <ns0:someData xmlns:ns0="http://some.data">
               <ns0:blaData/>
            </ns0:someData>
         </detail>
      </soapenv:Fault>
   </soapenv:Body>

</soapenv:Envelope>



Save the thread dump when server starts as a background service

When you do a normal server start up and if you kill the process using the command 
kill -3 <%PID%> then you can view the thread dump in the console. But if you start the server as a background service then it is impossible to view the thread dump in the console. In order to view it follow the below steps.

1. Start the server as a background process by using the below command 

sh ./wso2server.sh start 

2. Run the below command

jstack %PID% > threaddump.txt

Please note the PID is the process ID and you can get this by running the command ps -ax|grep wso2 )



Also if you start the server with nohup command  (nohup wso2server.sh)  then you can see the thread dump in the nohup.out



Sep 20, 2014

Validate XML messages using more than one schemas

Validate Mediator of WSO2 ESB can be used to validate requests since it is vital in order to maximize resource utilization. Validate mediator facilitates validating the request against multiple XSDs as well. 

This blog post describes a scenario where you have an one XSD which has a reference to another XSD.  

1. Create XSD files

Basically we have the main XSD (TestSchema.xsd) which has a reference to another XSD ( referenceSchema.xsd).  The two schemas are as follows.

TestSchema.xsd


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

xmlns:ns0="http://www.wso2.org/refer"
xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns2="http://www.wso2.org/test"
attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://www.wso2.org/test">
 <xs:import namespace="http://www.wso2.org/refer"
               schemaLocation="referenceSchema.xsd" />
<xs:element name="test" type="ns0:refer">
</xs:element>
</xs:schema>


If you observer the schema definition, you can see there is a reference to the schema xmlns:ns0="http://www.wso2.org/refer" which is defined in the other schema file and type 'refer' is also defined in the second schema as follows.

referenceSchema.xsd


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns0="http://www.wso2.org/refer"
attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://www.wso2.org/refer">
<xs:element name="refer" type="ns0:refer"></xs:element>
<xs:complexType name="refer">
<xs:sequence>
<xs:element minOccurs="1" name="name" >
 <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:minLength value="1" />
        </xs:restriction>
    </xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>


After you create the XSD, just upload them to the registry of WSO2 ESB at the location \_system\conf\


2. Create the Proxy Service

First let me consider about the validate mediator configuration which uses to validate the request



 <validate>

            <schema key="conf:/TestSchema.xsd"/>
            <resource location="referenceSchema.xsd" key="conf:/referenceSchema.xsd"/>
            <on-fail>
               <makefault version="soap11">
                  <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/>
                  <reason value="Request is Invalid........"/>
                  <role/>
               </makefault>
               <log level="full"/>
               <property name="RESPONSE" value="true"/>
               <header name="To" action="remove"/>
               <send/>
               <drop/>
            </on-fail>
         </validate>


Basically we are validating the request against the schema TestSchema.xsd which states as key="conf:/TestSchema.xsd" which has a reference to the referenceSchema.xsd. 

In Validate mediator there is an attribute called <resource> to indicate on where to find other schemas. The key entry specifies the current location of the schema. ( key="conf:/referenceSchema.xsd") . In order to map schemas correctly, the 'location' entry in the Validate mediator should match with the 'schemaLocation' in the xsd. 

location="referenceSchema.xsd"
schemaLocation="referenceSchema.xsd"

The proxy configuration is as follows.



<?xml version="1.0" encoding="UTF-8"?>

<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="TestProxy"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
       <validate>
            <schema key="conf:/TestSchema.xsd"/>
            <resource location="referenceSchema.xsd" key="conf:/referenceSchema.xsd"/>
            <on-fail>
               <makefault version="soap11">
                  <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/>
                  <reason value="Request is Invalid........"/>
                  <role/>
               </makefault>
               <log level="full"/>
               <property name="RESPONSE" value="true"/>
               <header name="To" action="remove"/>
               <send/>
               <drop/>
            </on-fail>
         </validate>
         <respond/>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>
                               

3. Testing the scenario

First you can send the below request


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <p:test xmlns:p="http://www.wso2.org/test" xmlns:q="http://www.wso2.org/refer">
         <q:name>sohani</q:name>
      </p:test>
   </soapenv:Body>
</soapenv:Envelope>


Then you will have a response as below.



<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

   <soapenv:Header/>
   <soapenv:Body>
      <p:test xmlns:p="http://www.wso2.org/test" xmlns:q="http://www.wso2.org/refer">
         <q:name>sohani</q:name>
      </p:test>
   </soapenv:Body>
</soapenv:Envelope>


If you send an invalid request then you will receive the response as below.



<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <p:test xmlns:p="http://www.wso2.org/test" xmlns:q="http://www.wso2.org/refer">
         <q:name></q:name>
      </p:test>
   </soapenv:Body>
</soapenv:Envelope>




<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode xmlns:tns="http://www.w3.org/2003/05/soap-envelope">tns:Receiver</faultcode>
         <faultstring>Request is Invalid........</faultstring>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>