Sunday, March 20, 2016

ESB 4.9.0 Call mediator, How to get the response headers when the blocking enabled.

In ESB 4.9.0, The Call mediator can invoke a service, either in a synchronous or asynchronous manner. If we use the call mediator in an asynchronous manner (blocking=false) it uses the default pass through transport implementation of the ESB. When the blocking enabled it uses the blocking message sender to send the request to the backend and will wait on the same thread until the response arrive.

If we require to preserver the response message headers we required to set the following property before the call mediator.


  <property name="BLOCKING_SENDER_PRESERVE_REQ_HEADERS" value="false"/>  

Sample proxy configuration

 <?xml version="1.0" encoding="UTF-8"?>  
 <proxy xmlns="http://ws.apache.org/ns/synapse"  
     name="first"  
     transports="https"  
     statistics="enable"  
     trace="enable"  
     startOnLoad="true">  
   <target>  
    <inSequence>  
      <property name="BLOCKING_SENDER_PRESERVE_REQ_HEADERS" value="false"/>  
      <call blocking="true">  
       <endpoint>  
         <address uri="https://localhost:8243/services/backend1"  
             trace="enable"  
             statistics="enable"/>  
       </endpoint>  
      </call>  
      <log level="full"/>  
    </inSequence>  
    <outSequence/>  
   </target>  
   <description/>  
 </proxy>  

Wednesday, March 9, 2016

Creating Simple HTTP server to share the files

Some time we required to share our files with the colleagues in the same network. Recently I found an easy way to share files using the python server.

Open a terminal and go to the directory where need to share the files.

Using "cd" command.

Then we can start the server like below.

python -m SimpleHTTPServer

This will start a server with the port 8000 which is the default one. If we need to set a separate port we can use the command like below.

python -m SimpleHTTPServer 5008

We can access the http server using the browser. Like below.

http://IP:port






Friday, March 4, 2016

Get the CarbonApplication list and Deployed artifacts using the Admin services in WSO2 ESB

WSO2 products are managed internally using SOAP Web services known as admin services. Management console uses the Admin Service to facilitate administration capabilities through the UI.
So every activity done through the Management console can be achieved using the Admin services.
Using those Admin services, we can list the installed CarbonApplications with their versions. Also, we can get the artifact list in each Carbonapplication separately.

We need to follow the below steps to enable admin service in the ESB. More details available in this document [1]

1) Set the <HideAdminServiceWSDLs> element to false in the <PRODUCT_HOME>/repository/conf/carbon.xml file.
2) Restart the server.

The adminservices related to the Carbonapplications available in following WSDL.

https://localhost:9443/services/ApplicationAdmin?wsdl

We can check this by calling the above URL in a browser. We can simply call this admin service using the SOAP UI.

Create a new SOAP project in the SOAP UI, using the above WSDL link. Then you will find the project like below [2].



Please use the serverlet port to invoke the adminservices. In our case, we used the offset value as 0. so our serverlet port is 9443.





Using the "listAllApplication" method you can get all the current installed CarbonApplicaions.
Using the "getAppData" method youcan retrieve the CarbonApplication and its artifacts separetely.
Following is sample request, I tested.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mgt="http://mgt.application.carbon.wso2.org">
   <soapenv:Header/>
   <soapenv:Body>
      <mgt:getAppData>
         <!--Optional:-->
         <mgt:appName>asdsd_1.0.0</mgt:appName>
      </mgt:getAppData>
   </soapenv:Body>
</soapenv:Envelope>

The response I received.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <ns:getAppDataResponse xmlns:ns="http://mgt.application.carbon.wso2.org">
         <ns:return xsi:type="ax23:ApplicationMetadata" xmlns:ax23="http://mgt.application.carbon.wso2.org/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <ax23:appName>asdsd</ax23:appName>
            <ax23:appVersion>1.0.0</ax23:appVersion>
            <ax23:artifactsDeploymentStatus xsi:type="ax23:ArtifactDeploymentStatus">
               <ax23:artifactName>simpleProxy</ax23:artifactName>
               <ax23:deploymentStatus>Deployed</ax23:deploymentStatus>
            </ax23:artifactsDeploymentStatus>
         </ns:return>
      </ns:getAppDataResponse>
   </soapenv:Body>
</soapenv:Envelope>


[1] https://docs.wso2.com/display/ESB481/Calling+Admin+Services+from+Apps
[2] http://charithaka.blogspot.com/2013/06/invoking-wso2-carbon-admin-services.html