cancel
Showing results for 
Search instead for 
Did you mean: 

WebService Response capture

Former Member
0 Kudos

Dear Friends,

Could you please let meknow how to capture the WebService response at runtime.

My Sceanrio: File to File through WS. i am triggering a web service at runtime by using UDF in message mapping. So my input will sent to Web service as Request and then WS returns Response. if the response has the details (ex: customer ID), i need to capture those details and insert in to my sorce data and sent to target as file.

here the problem is how to capture the response of web service in runtime and read the details of customer ID and insert those details to source. please let me know Java code how to capture Response details of web service.

Thanks in Advanace...SARAN

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

UDF

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>> here the problem is how to capture the response of web service in runtime and read the details of customer ID and insert those details to source. please let me know Java code how to capture Response details of web service.

You are basically doing webservice lookup during mapping. It is easy. We do the same in our projects... Follow the blog

/people/bhavesh.kantilal/blog/2006/11/20/webservice-calls-from-a-user-defined-function

This coding gives idea about how to read the response too.

Former Member
0 Kudos

Hi Baskar,

Thanks for the quick response...i had implemented teh same URL ...but the problem is once i got response from WebService, i need to read that data in runtime and in that response there is filed "customer ID". i need to capture the value of that filed and insert that values in to source file...

means source file we have 10 records...in that one records will miss the customer ID(empty). so that value i will fectch from webservice response and need to insert in souce file and then send that file to target.

So please let me know how can i achive that ....what elase i need to add with the code given in the above URL. what stpes i need to do in mapping...

if you need an y clarification about the flow, please let me know.

Best Regards,SARAN

baskar_gopalakrishnan2
Active Contributor
0 Kudos

I can help certainly if I know your response structure. I dont know whether customer Id comes multiple times or single time only... if it is single time do as below...

// create customerID field of the type String before try block instead of conversionRate

String customerID = "";

try{

// Parsing the response

NodeList list = document.getElementsByTagName("customer ID");

Node node = list.item(0);

if (node != null) {

node = node.getFirstChild();

if(node!= null){

customerID = node.getNodeValue();

}

}

}

Former Member
0 Kudos

Hello Baskar,

Thanks for the Code lines.

In m y interface WebService will return multiple responses as given below

1. Success

2. Error

--> If it is Success response, it will check the input data for Customer ID filed. if any of customer ID filed is EMPTY, then it will return all the missing Customer IDs...it may be 1 or MULTIPLE CUSTOMER ID's...in my case it is multiple customer ID's

So Success response will have multiple Customer IDs...i need to insert these ID's to the input file at runtime..and then send that file to target system

-->If it is Error response, it will return all the error records...and i will insert those records to DB Error table.

Now If teh response is error, i am able to capture teh response records and then able to insert to DB table by JDBC receiver. but if the response is success, i am not able to capture the response....

Thanks a lot for your responses.....and please help us further to solve the issue.

Best Reagrds..>SARAN

Former Member
0 Kudos

>

> Hello Baskar,

>

> Thanks for the Code lines.

>

> In m y interface WebService will return multiple responses as given below

> 1. Success

> 2. Error

>

> --> If it is Success response, it will check the input data for Customer ID filed. if any of customer ID filed is EMPTY, then it will return all the missing Customer IDs...it may be 1 or MULTIPLE CUSTOMER ID's...in my case it is multiple customer ID's

> So Success response will have multiple Customer IDs...i need to insert these ID's to the input file at runtime..and then send that file to target system

>

> -->If it is Error response, it will return all the error records...and i will insert those records to DB Error table.

>

> Now If teh response is error, i am able to capture teh response records and then able to insert to DB table by JDBC receiver. but if the response is success, i am not able to capture the response....

>

> Thanks a lot for your responses.....and please help us further to solve the issue.

>

> Best Reagrds..>SARAN

Then... if i understand.... Your problem is that the response message in WSLookup is a tableValues with CustomerID, and you have to map them in multiple rows... right??

The Baskar's example, expects a single value response and return a single value. You have to put the message response in a HashTable or similar, and map the multiple value to the destination structure.

baskar_gopalakrishnan2
Active Contributor
0 Kudos

code snippet... Follow my first link for the entire coding...

//create Execution type all values of a context in UDF... You will find resultset result on the argument. This result will be

// used to add multiple values of the customerID.

try{

NodeList nodelist = document.getElementsByTagName("customer ID");

Node node;

for (int i=0; i<nodelist.getLength(); i++) {

node = nodelist.item(i);

result.addValue(node.getNodeName() );

}

}catch(Exception ex){

}

Former Member
0 Kudos

Hi Baskar,

Thanks for the reply..but i am not able to capture the response for the..Success status with CustomerID=empty.. (as mentiond above responses status 1 and 2).

if i send SOAP request to WS with error recrds...it retirns response of those error details and i am able to capture that response in PI...but

when i send SOAP request to WS with Empty CustomerID...WS will return response with the missing CustomerID's...and i am not able to capture that response in PI.

AS you have the code...could you please check and let me know..what else needs to be added...

Thanks in Advance.....SARAN

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Can you provide us still more details by providing some example? provide your both response for sample....

response which has empty customerid and customerid with value. I can make code change accordingly ...

Edited by: Baskar Gopal on Feb 1, 2011 6:47 PM