Monday, 16 December 2013

What is URL Encoding?
When you pass information through a URL, you need to make sure it only uses specific allowed characters like: alphabetic characters, numerals, and a few special characters that have meaning in the URL string. Any other characters should be encoded so that they don't cause problems.
The most commonly encoded character is the <space> character. You see this character whenever you see a plus-sign (+) in a URL. This represents the space character. The plus sign acts as a special character representing a space in a URL. The most common way you'll see this is in a mailto link that includes a subject. If you want the subject to have spaces in it, you can encode them as pluses:
mailto:email?subject=this+is+my+subject
How Do You Encode a URL?
Simply replace the special characters with their encoding string. This will nearly always begin with a %. If you don't want to do it by hand, you can use a script such as is found on the JavaScript site: Encoding Web Addresses.
How URL_Decoding can be done in Message Broker?
     I.        When the HTTP client sends the Request-Type as “GET” and the Content-type as “URL-Encoded”,then our Message broker HTTPInput node by itself can decode the url-encoded input message .
To extract the decoded message ,we have to enable the “parseQueryString” property in the HTTPInput node as below.
Then the decoded message will be present in the below path.We can extract the message from this path for further use.
For eg:
SET Environment.Variables.OriginalMessage = CAST(InputLocalEnvironment.HTTP.Input.QueryString.Input AS BLOB CCSID 1208);
   II.        When the HTTP client sends the Request-Type as “POST” and the Content-type as “URL-Encoded”,then our Message broker HTTPInput node cannot by itself decode the url-encoded input message .
The following method can be used to achieve such scenarios.
Introduce a “Javacompute node” after HTTPInput node.
String result =  java.net.URLDecoder.decode("=%3cn%3aMessage+xmlns%3an%3d%22http%3a%2f%2f%3e%5d%5d%3e%3c%2fMsg%3e%3c%2fn%3aMessage%3e", "UTF-8");
Refer the message in a variable or directly as shown in the above example.
Note : No need for checking “parseQueryString” option in HTTPInput node.


HTTP URL Encoding

Encoding Vs Encryption Encoding is the process of transforming data so that it may be transmitted without danger over a communication channel or stored without danger on a storage medium. For instance, computer hardware does not manipulate text, it merely manipulates bytes, so a text encoding is a description of how text should be transformed into bytes. Similarly, HTTP does not allow all characters to be transmitted safely, so it may be necessary to encode data using base64 (uses only letters, numbers and two safe characters). When encoding or decoding, the emphasis is placed on everyone having the same algorithm, and that algorithm is usually well-documented, widely distributed and fairly easily implemented. Anyone is eventually able to decode encoded data. Encryption, on the other hand, applies a transformation to a piece of data that can only be reversed with specific (and secret) knowledge of how to decrypt it. The emphasis is on making it hard for anyone but the intended recipient to read the original data. An encoding algorithm that is kept secret is a form of encryption, but quite vulnerable (it takes skill and time to devise any kind of encryption, and by definition you can't have someone else create such an encoding algorithm for you - or you would have to kill them). Instead, the most used encryption method uses secret keys : the algorithm is well-known, but the encryption and decryption process requires having the same key for both operations, and the key is then kept secret. Decrypting encrypted data is only possible with the corresponding key. See encoding as a way to store or communicate data between different systems. For example, if you want to store text on a hard drive, you're going to have to find a way to convert your characters to bits. Alternatively, if all you have is a flash light, you might want to encode your text using Morse. The result is always "readable", provided you know how it's stored. Encryption means you want to make your data unreadable, by encrypting it using an algorithm. For example, Caesar did this by substituting each letter by another. The result here is unreadable, unless you know the secret "key" with which is was encrypted. Encoding Vs Compression Encoding is representing a piece of information in other form. Say for example, one can represent 10 as 0xA. This is hexadecimal encoding. Compression is done solely to lessen the number of symbols to represent given piece of information. It is achieved with the help of specific encoding of information. Encoding is used at various places but audio/video encoding is more known encoding to us. This leads to this confusion. As different types of encoding gives different types of compression, it combines encoding & compression. But encoding doesn't always compress the data. Those examples are in communication theory. NRZ & NRZI are example of encoding which doesn't compress data. In MQInput node,we can easily do the encoding setup by setting the below properties At HTTP node,we can do Compression (Compression is the only Encoding that can be done at HTTPInput node). What is URL Encoding? When you pass information through a URL, you need to make sure it only uses specific allowed characters like: alphabetic characters, numerals, and a few special characters that have meaning in the URL string. Any other characters should be encoded so that they don't cause problems. The most commonly encoded character is the character. You see this character whenever you see a plus-sign (+) in a URL. This represents the space character. The plus sign acts as a special character representing a space in a URL. The most common way you'll see this is in a mailto link that includes a subject. If you want the subject to have spaces in it, you can encode them as pluses: mailto:email?subject=this+is+my+subject How Do You Encode a URL? Simply replace the special characters with their encoding string. This will nearly always begin with a %. If you don't want to do it by hand, you can use a script such as is found on the JavaScript site: Encoding Web Addresses. How URL_Decoding can be done in Message Broker? I. When the HTTP client sends the Request-Type as “GET” and the Content-type as “URL-Encoded”,then our Message broker HTTPInput node by itself can decode the url-encoded input message . To extract the decoded message ,we have to enable the “parseQueryString” property in the HTTPInput node as below. Then the decoded message will be present in the below path.We can extract the message from this path for further use. For eg: SET Environment.Variables.OriginalMessage = CAST(InputLocalEnvironment.HTTP.Input.QueryString.Input AS BLOB CCSID 1208); II. When the HTTP client sends the Request-Type as “POST” and the Content-type as “URL-Encoded”,then our Message broker HTTPInput node cannot by itself decode the url-encoded input message . The following method can be used to achieve such scenarios. Introduce a “Javacompute node” after HTTPInput node. String result = java.net.URLDecoder.decode("=%3cn%3aMessage+xmlns%3an%3d%22http%3a%2f%2f %3e%5d%5d%3e%3c%2fMsg%3e%3c%2fn%3aMessage%3e", "UTF-8"); Refer the message in a variable or directly as shown in the above example. Note : No need for checking “parseQueryString” option in HTTPInput node.