on 04-11-2017 12:11 PM
HI,
The requirement is that in a payload, client will send compressed data in a field which PI needs to send it to ECC. then ECC will respond back and PI will have to compress that data and send it to client. the scenario is soap sync. when we reply, we have to compress the service message again. In a payload, it is a compressed field which is zipped using Gzip and base64 encoded. Please suggest
Here is code which i tested :
For Compressing :
String encoded = "";
try{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream gzip = new GZIPOutputStream(baos);
BASE64Encoder encoder = new BASE64Encoder();
gzip.write(invoice.getBytes());
gzip.close();
encoded = encoder.encode( baos.toByteArray());
}
catch(Exception e)
{
return "";
}
return encoded;
For Decompressing :
String line="";
StringBuilder sb = new StringBuilder();
try {
BASE64Decoder decoder = new BASE64Decoder();
byte b[] = decoder.decodeBuffer(encoded);
ByteArrayInputStream bis = new ByteArrayInputStream(b);
GZIPInputStream gis = new GZIPInputStream(bis);
BufferedReader br = new BufferedReader(new InputStreamReader(gis, "UTF-8"));
while((line = br.readLine()) != null) {
sb.append(line);
}
}
catch (IOException e) {
System.out.println(e);
}
return sb.toString();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Brilliant as always. I am going to test this interface next week. I will update you once I am done. Thank you so much again.
best regards,
Sherwin
Hi,
I wanted to know that under the node "compressedData" we have other child nodes. We will be using dynamic configuration for soap actions for the same. so when they will send operation as "initjob" we will send only Initjobrequest to third party. does compression will have any affect on dynamic selection of soap action ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sherwin!
As I could see, you map result of your UDF to node having subnodes? You should map result to leaf node in order to get it filled. There is no ability to create mixed type nodes in graphical mapping.
Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sherwin,
You can see the result in Display Queue , but when you test it it wont appear in target structure as already Eve Suggested you are mapping it to a node and not a field which is capable of holding a value , so change your mapping so that target field is a field and not any parent note.
Br,
Manoj
You firstly need to Decode it via Base64decoder and then Decompress it via Gzip. Below is the code for Decompressing
String line="";
StringBuilder sb = new StringBuilder();
try {
BASE64Decoder decoder = new BASE64Decoder();
byte b[] = decoder.decodeBuffer(encoded);
ByteArrayInputStream bis = new ByteArrayInputStream(b);
GZIPInputStream gis = new GZIPInputStream(bis);
BufferedReader br = new BufferedReader(new InputStreamReader(gis, "UTF-8"));
while((line = br.readLine()) != null) {
sb.append(line);
}
}
catch (IOException e) {
System.out.println(e);
}
return sb.toString();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I have done the changes. I ran the test. It ran completily but i dont see the node compressed. Any idea why ?
I am attaching the screenshots.
Screenshot 7 for the test result.
Screenshot 8 for the UDF and classes used. I also Added the external sun.misc.BASE64Decoder.jar. added in imported archive. Also I changed the classes.
Screenshot 9 for the mapping done for the node.
What am I missing here ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sherwin,
Please add the classes you use in your UDF to the import section.
The "invoice" variable is not defined in your code. It should be var1 as I understand.
Regards,
Andrzej
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please look at the last screen: BASE64Encoder.
Regards,
Andrzej
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Manoj.
Can you tell me how can I processed in PI by using the information you provided? should we do it in PI or should I ask ECC guys to do it?
Thakns in advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sherwin,
You can write a java mapping class and use it in your OM. In your java code, you can parse your message and take that part of it which have to be decompressed or compressed. You can use, for example, standard java classes to do that:
java.util.zip.GZIPOutputStream
java.util.zip.GZIPInputStream
Then you can encode the result using Base64 class (it's a part of Java standard now) and put into the output message.
Regards,
Andrzej
Hi Sherwin,
You can send me a message.
Regards,
Andrzej
Sherwin,
As you want to Compress/Uncompress only on field in the data so ther is no standard way to do so , you need to go for java few examples are here :
http://www.avajava.com/tutorials/lessons/how-do-i-compress-and-uncompress-a-gzip-file.html
http://stackoverflow.com/questions/16351668/compression-and-decompression-of-string-data-in-java
Br,
Manoj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.