Showing posts with label HowTo. Show all posts
Showing posts with label HowTo. Show all posts

Sunday, August 9, 2015

How to do a URL encode in WSO2 ESB

I have recently came across a requirement to send an XML paylod in URL encoded format to the backend. I was able to get it done with WSO2 ESB script mediator

Request to ESB is as follows:
<request><user>Sajith</user></request>


Backend expects the request as follows
http://localhost:8001/myservice?RequestXML=%3CRequest%3E%3CUser%3ESajith%3C%2FUser%3E%3C%2FRequest%3E


This was achieved by the following code. (Using javascript method encodeURL)
     <script language="js" description="">
         mc.setProperty("uri.var.encodedBody", encodeURI(mc.getPayloadXML()));
     </script>

     <send>
         <endpoint>
             <http method="post" uri-template="http://localhost:8001/myservice?RequestXML={uri.var.encodedBody}"/>
         </endpoint>
     </send>

Wednesday, March 25, 2015

Convert request parameter to an HTTP header in WSO2 ESB



Say, you have a requirement to pass a request parameter (named key) which comes to an ESB proxy service, and that need to be passed to the backend service as an HTTP header (named APIKEY).

Request to ESB proxy service would be as follows.
      curl -X GET "http://localhost:8280/services/MyPTProxy?key=67876gGXjjsskIISL

In that case you can make use of xpath expression $url:[param_name]

In your in-sequence you can add a header mediator as follows to set the HTTP header with key request parameter



Thursday, December 18, 2014

Puppet configs

Puppet master
    server name in /etc/puppet/puppet.conf is not needed
    set autosign=true in /etc/puppet/puppet.conf

Obtain the puppet master hostname by executing  "hostname -f"

Puppet agent
    Set the proper puppet hostname in /etc/puppet/puppet.conf which is obtained in the previous command, if that is resolvable. Otherwise need to add that hostname into /etc/hosts file
    agent's hostname can be any value. No need to have master's hostnames init. puppet agents hostname need to be resolvable. for eg, to 127.0.0.1


   

Thursday, November 8, 2012

SSH: Agent admitted failure to sign using the key.

When you are trying to ssh to a remote server using passwordless login, you might get an exception
   "Agent admitted failure to sign using the key."

Issue may be the private key is not properly added (default location : ~/.ssh/id_rsa )

To fix the issue, (preferably in a separate terminal) issue the following command
    $ ssh-add

This will add the private key giving the output "Identity added: /home/wso2/.ssh/id_rsa (/home/sajith/.ssh/id_rsa)"

Now you can ssh to the remote server as expected...
     $ ssh user@remoteserver


Friday, June 15, 2012

HowTo.. ?

A collection of some important "HowTo"s that I have come across..

Hope to periodically update the list as I get to know of a new "HowTo" ..



Mount a remote samba server shared directory in Linux (Ubuntu)

      $  mount -t cifs //10.2.5.5/shared -o username=un,password=pw /test


Extract a "tar.gz" file in Linux
    
     $ tar -xzf tar-file-name.tar.gz
  • tar - the tar command.
  • x - extract the archive.
  • z - uncompress the archive using gzip.
  • f - use archive file.
  • tar-file-name.tar.gz - the name of the tar.gz to create.
The tar command will extract all the files/folders in the archive to the current directory. 

Create a "tar.gz" file in Linux
    
     $ tar -czf new-tar-file-name.tar.gz file1 file2 folder1 folder2
  • tar - the tar command.
  • c - create new archive.
  • z - compress the archive using gzip.
  • f - use archive file.
  • new-tar-file-name.tar.gz - the name of the tar.gz to create.
  • file-or-folder-to-archive - the name of the folder we want to archive.

Mounting and un-mounting Qemu image


nbddevice="/dev/nbd2"
nbdmount="/dev/nbd2p1"


modprobe nbd max_part=8
qemu-nbd -c /dev/nbd2 image_path
mount /dev/nbd2p1 $work_dir/$image_template


umount $work_dir/$image_template
qemu-nbd -d /dev/nbd2



wget java
-------------
wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com"  http://download.oracle.com/otn-pub/java/jdk/6u39-b04/jdk-6u39-linux-x64.bin