Topic
  • 23 replies
  • Latest Post - ‏2013-07-02T20:52:59Z by SudhakarChellam
SystemAdmin
SystemAdmin
255 Posts

Pinned topic Parsing/Using data returned from Webservice call

‏2012-10-13T01:03:41Z |
So, I've gone through the wizard and created a web service call to a 3rd party webservice. I get the return xml data back. I can write it to a log like all the examples show. But, how can I actually parse the data to do something with it? Does Impact create some secret DSA that I can use some methods on? Do I use XML functions? I cannot find one single example of using data returned from a webservice in impact other than writing the results to a log file. Any help is appreciated. Impact 6.1 btw.
Updated on 2012-10-16T09:19:38Z at 2012-10-16T09:19:38Z by R@J
  • SystemAdmin
    SystemAdmin
    255 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2012-10-13T05:09:59Z  
    Hi,

    I hope u r getting response in XML format and you can use parsing logic to obtain the results

    For Example :
    log("About to invoke Web Service call CreateInterfaceRequest ......");
    WSInvokeDLResult = WSInvokeDL(WSService, WSEndPoint, WSMethod, WSParams);
    log("About to invoke Web Service call CreateInterfaceRequest ...: " +WSInvokeDLResult);
    // Printing the Response

    Assume you are getting response in xml like this
    <WSInvokeDLResult>
    <CreateInterfaceRequestResponse>
    <DestObjectID> 12345 </DestObject>
    </CreateInterfaceRequestResponse>
    </WsInvokeDLResult>

    DEST_OBJ_ID = WSInvokeDLResult.CreateInterfaceRequestResponse.DestObjectID;
    Thanks and RegardsSatya
  • SystemAdmin
    SystemAdmin
    255 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2012-10-13T13:42:25Z  
    Ah ok. So you basically just provide the full path to the element in dot format?

    Can IPL handle multiple elements with the same name, like as an array to loop over?

    Thanks.
  • SystemAdmin
    SystemAdmin
    255 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2012-10-13T20:13:24Z  
    Ok, still having problems.

    Here's the XML returned:
    <GetAlertHistoryResponse xmlns="http://www.xxxxxxx.com/webservices/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <alertHistoryResponse>
    <status>SUCCESS</status>
    </alertHistoryResponse>
    </GetAlertHistoryResponse>

    I'm trying to get the 'status'. If I do this:
    status = GetAlertHistoryResponse.alertHistoryResponse.status;
    Log("The status is: " +status);

    I get: Parser log: The status is: NULL
  • R@J
    R@J
    39 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2012-10-15T12:05:04Z  
    Ok, still having problems.

    Here's the XML returned:
    <GetAlertHistoryResponse xmlns="http://www.xxxxxxx.com/webservices/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <alertHistoryResponse>
    <status>SUCCESS</status>
    </alertHistoryResponse>
    </GetAlertHistoryResponse>

    I'm trying to get the 'status'. If I do this:
    status = GetAlertHistoryResponse.alertHistoryResponse.status;
    Log("The status is: " +status);

    I get: Parser log: The status is: NULL
    Hi silver8ack,

    pls test the following

    outPut = RExtract(WSInvokeDLResult,"<status\\b^>*>(.*?)</status>");
    log("Output --------------->" +outPut );
  • SystemAdmin
    SystemAdmin
    255 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2012-10-15T13:39:40Z  
    Parser log: Output --------------->
    I don't understand. It seems I can't actually do anything with the results.
    Here's the code(Certain parts replaced to protect privacy):
    
    log(
    "About to invoke Web Service call GetAlertHistory ......");   WSInvokeDLResult = WSInvokeDL(WSService, WSEndPoint, WSMethod, WSParams); log(
    "Web Service call GetAlertHistory return result: " +WSInvokeDLResult); outPut = RExtract(WSInvokeDLResult,
    "<status\\b^>*>(.*?)</status>"); log(
    "Output --------------->" +outPut );
    


    Here's the output:
    
    October 15, 2012 9:36:45 AM EDT[PolicyLogger][XXXX_Alert_History][pool-1-thread-15]Parser log: About to invoke Web Service call GetAlertHistory ...... October 15, 2012 9:36:45 AM EDT[PolicyLogger][XXXX_Alert_History][pool-1-thread-15]Parser log: Web Service call GetAlertHistory 
    
    return result: <GetAlertHistoryResponse xmlns=
    "http://www.url.com/webservices/" xmlns:xsd=
    "http://www.w3.org/2001/XMLSchema" xmlns:soap=
    "http://www.w3.org/2003/05/soap-envelope" xmlns:xsi=
    "http://www.w3.org/2001/XMLSchema-instance"> <alertHistoryResponse> <status>SUCCESS</status> </alertHistoryResponse> </GetAlertHistoryResponse> October 15, 2012 9:36:45 AM EDT[PolicyLogger][XXXX_Alert_History][pool-1-thread-15]Parser log: Output --------------->
    
  • R@J
    R@J
    39 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2012-10-15T15:44:51Z  
    Parser log: Output --------------->
    I don't understand. It seems I can't actually do anything with the results.
    Here's the code(Certain parts replaced to protect privacy):
    <pre class="jive-pre"> log( "About to invoke Web Service call GetAlertHistory ......"); WSInvokeDLResult = WSInvokeDL(WSService, WSEndPoint, WSMethod, WSParams); log( "Web Service call GetAlertHistory return result: " +WSInvokeDLResult); outPut = RExtract(WSInvokeDLResult, "<status\\b^>*>(.*?)</status>"); log( "Output --------------->" +outPut ); </pre>

    Here's the output:
    <pre class="jive-pre"> October 15, 2012 9:36:45 AM EDT[PolicyLogger][XXXX_Alert_History][pool-1-thread-15]Parser log: About to invoke Web Service call GetAlertHistory ...... October 15, 2012 9:36:45 AM EDT[PolicyLogger][XXXX_Alert_History][pool-1-thread-15]Parser log: Web Service call GetAlertHistory return result: <GetAlertHistoryResponse xmlns= "http://www.url.com/webservices/" xmlns:xsd= "http://www.w3.org/2001/XMLSchema" xmlns:soap= "http://www.w3.org/2003/05/soap-envelope" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"> <alertHistoryResponse> <status>SUCCESS</status> </alertHistoryResponse> </GetAlertHistoryResponse> October 15, 2012 9:36:45 AM EDT[PolicyLogger][XXXX_Alert_History][pool-1-thread-15]Parser log: Output ---------------> </pre>
    sorry,missed some braces in the previous post.
    pls try with this---
    output=RExtract(WSInvokeDLResult,"<status\\b^>*>(.*?)</status>");
    log("o/p -------> "+output);

    now this should work.
    let me know if it does not.
  • R@J
    R@J
    39 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2012-10-15T15:51:29Z  
    • R@J
    • ‏2012-10-15T15:44:51Z
    sorry,missed some braces in the previous post.
    pls try with this---
    output=RExtract(WSInvokeDLResult,"<status\\b^>*>(.*?)</status>");
    log("o/p -------> "+output);

    now this should work.
    let me know if it does not.
    having problem with characters....
    it was not taking "[" in post.

    put a opening '' before "*>(.*?)</status>"
    output=RExtract(WSInvokeDLResult,"<status\\b ^> *>(.*?)</status>");
    //without any spaces before and after ''.
    log("o/p------->>>>" +output);
  • R@J
    R@J
    39 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2012-10-15T16:00:11Z  
    • R@J
    • ‏2012-10-15T15:51:29Z
    having problem with characters....
    it was not taking "[" in post.

    put a opening '' before "*>(.*?)</status>"
    output=RExtract(WSInvokeDLResult,"<status\\b ^> *>(.*?)</status>");
    //without any spaces before and after ''.
    log("o/p------->>>>" +output);
    It's frustrating that I cant delete my own post.
    after 3 consecutive post I hope I 'll be able to end the problem.

    it is not taking third bracket "" without double quotation... :(

    whatever, put one opening third bracket i.e. "" before "*>(.*?)</status>"
    don't put any spaces before or after "" .

    it should not be a problem any more.

    enjoy,
    Raj
  • SystemAdmin
    SystemAdmin
    255 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2012-10-15T16:14:35Z  
    • R@J
    • ‏2012-10-15T16:00:11Z
    It's frustrating that I cant delete my own post.
    after 3 consecutive post I hope I 'll be able to end the problem.

    it is not taking third bracket "" without double quotation... :(

    whatever, put one opening third bracket i.e. "" before "*>(.*?)</status>"
    don't put any spaces before or after "" .

    it should not be a problem any more.

    enjoy,
    Raj
    Raj, can you try putting a beginning and ending {code} markup around your code because I'm not sure what it should look like.
  • SystemAdmin
    SystemAdmin
    255 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2012-10-15T16:17:43Z  
    Raj, can you try putting a beginning and ending {code} markup around your code because I'm not sure what it should look like.
    Raj, cancel that I was able to get it with the following:

    
    output = RExtract(WSInvokeDLResult,
    "<status>(.*?)</status>");
    


    I just don't understand why Impact doesn't work like it's supposed to. What's the selling point of Web Services DSA if I still have to parse all the data? I can do that in Python or anything else much easier.
  • R@J
    R@J
    39 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2012-10-15T16:42:06Z  
    Raj, can you try putting a beginning and ending {code} markup around your code because I'm not sure what it should look like.
    sorry, dont know how to use
    
    markup. :P
    

    output=RExtract(WSInvokeDLResult,"<status\\b^>*>(.*?)</status>");
    log("o/p ----> " +output);
    {code}

    donno whether this time it 'll take the correct value or not.

    whatever,
    opening third bracket after the following sub-string "<status\\b"
    closing third bracket before the sub-string "*>(.*?)</status>");"

    which means,
    <status\\b OpeningThirdBracket ^> ClosingThirdBracket *>(.*?)</status>

    without any spaces.

    if it messes up this time too,
    then I would like to suggest you to go through the policy reference guide of netcool/impact 5.1
    u can find function RExtractAll in the guide.
    read and try the example 2 (both IPL and Java Script).
    in your case,
    u ll have to replace RExtractAll(expression with RExtract(WSInvokeDLResult
    and
    replace plantId with status
    hope it 'll help.

    regards,
    Raj
  • R@J
    R@J
    39 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2012-10-15T16:45:36Z  
    • R@J
    • ‏2012-10-15T16:42:06Z
    sorry, dont know how to use <pre class="jive-pre"> markup. :P </pre>
    output=RExtract(WSInvokeDLResult,"<status\\b^>*>(.*?)</status>");
    log("o/p ----> " +output);
    {code}

    donno whether this time it 'll take the correct value or not.

    whatever,
    opening third bracket after the following sub-string "<status\\b"
    closing third bracket before the sub-string "*>(.*?)</status>");"

    which means,
    <status\\b OpeningThirdBracket ^> ClosingThirdBracket *>(.*?)</status>

    without any spaces.

    if it messes up this time too,
    then I would like to suggest you to go through the policy reference guide of netcool/impact 5.1
    u can find function RExtractAll in the guide.
    read and try the example 2 (both IPL and Java Script).
    in your case,
    u ll have to replace RExtractAll(expression with RExtract(WSInvokeDLResult
    and
    replace plantId with status
    hope it 'll help.

    regards,
    Raj
    o ho
    finally got it. lol lol :P

    
    output = RExtract(WSInvokeDLResult,
    "<status\\b[^>]*>(.*?)</status>"); log(
    "o/p---"+output);
    
  • SystemAdmin
    SystemAdmin
    255 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2012-10-15T20:10:16Z  
    So this is ok if I have one single element that I need to get.

    However, in real life, we usually need much more. This doesn't help me at all really. I need to be able to iterate of the contents of an XML response. The 'status' element actually occurs several times and with this method, it will only pick up the last one.

    Any other ideas of how to parse the data and take action on it? Otherwise I'm going to management and recommending we DO NOT buy any additional licenses for Impact. It seems to be a roadblock to actually getting things done.
  • SystemAdmin
    SystemAdmin
    255 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2012-10-15T20:56:00Z  
    So this is ok if I have one single element that I need to get.

    However, in real life, we usually need much more. This doesn't help me at all really. I need to be able to iterate of the contents of an XML response. The 'status' element actually occurs several times and with this method, it will only pick up the last one.

    Any other ideas of how to parse the data and take action on it? Otherwise I'm going to management and recommending we DO NOT buy any additional licenses for Impact. It seems to be a roadblock to actually getting things done.
    Ugh, I think I figured out what I have to do... I'll report back tomorrow. I have to create the Objects first using WSNewObject it seems. I tried quickly, but didn't have any luck... gonna look into a but more.
  • R@J
    R@J
    39 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2012-10-16T09:19:38Z  
    Ugh, I think I figured out what I have to do... I'll report back tomorrow. I have to create the Objects first using WSNewObject it seems. I tried quickly, but didn't have any luck... gonna look into a but more.
    Hi silver8ack ,
    try to use RExtractAll to fetch multiple data at a time.

    You can have the reference in the below link ---

    http://publib.boulder.ibm.com/infocenter/tivihelp/v8r1/index.jsp?topic=%2Fcom.ibm.netcoolimpact.doc6.1%2Fpolicy%2Fimpr_parser_rextractall_c.html
  • RayPatil
    RayPatil
    4 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2013-06-05T05:40:54Z  
    Ugh, I think I figured out what I have to do... I'll report back tomorrow. I have to create the Objects first using WSNewObject it seems. I tried quickly, but didn't have any luck... gonna look into a but more.

    Hi

    It would be great if you let us know how you finally managed to handle the webservice data in IMPACT!

    How to use "WSNewObject" to fetch xml data in impact policy or How to use RExtract/RExtractAll ???

    Please reply ASAP, this is roadblock to my release!

     

    Regards,

    Ray

  • OskarZinger
    OskarZinger
    57 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2013-06-06T17:51:10Z  
    • RayPatil
    • ‏2013-06-05T05:40:54Z

    Hi

    It would be great if you let us know how you finally managed to handle the webservice data in IMPACT!

    How to use "WSNewObject" to fetch xml data in impact policy or How to use RExtract/RExtractAll ???

    Please reply ASAP, this is roadblock to my release!

     

    Regards,

    Ray

    Hi Ray,

     

    WSNewObject is documented here.

    RExtract is documented here.

    RExtractAll is documented here.

    You can also look at using GetByXPath which is documented here. It can help you deal with XML.

     

    Hope this helps,

    Oskar

  • RayPatil
    RayPatil
    4 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2013-06-07T07:59:20Z  

    Hi Ray,

     

    WSNewObject is documented here.

    RExtract is documented here.

    RExtractAll is documented here.

    You can also look at using GetByXPath which is documented here. It can help you deal with XML.

     

    Hope this helps,

    Oskar

    Thank u Oskar for your quick response.

    I am looking to parse and use the XML response coming from webservice. Few lines of my IPL code looks as below and using webservice method.

    CalculateServiceImpactDocument=WSNewObject("<***>.CalculateServiceImpactDocument");
    WSInvokeDLResult = WSInvokeDL(WSService, WSEndPoint, WSMethod, WSParams);
    output = RExtractAll(WSInvokeDLResult,"<regular expression>");

    Instead of RExtract/RExtractall function can I use any other way like making the response as an context/object and fetch the data with . notation? Please share some examples...

     

    please help asap.

    Regards,

    Ray

     


     

  • SudhakarChellam
    SudhakarChellam
    19 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2013-06-09T18:56:56Z  
    • RayPatil
    • ‏2013-06-07T07:59:20Z

    Thank u Oskar for your quick response.

    I am looking to parse and use the XML response coming from webservice. Few lines of my IPL code looks as below and using webservice method.

    CalculateServiceImpactDocument=WSNewObject("<***>.CalculateServiceImpactDocument");
    WSInvokeDLResult = WSInvokeDL(WSService, WSEndPoint, WSMethod, WSParams);
    output = RExtractAll(WSInvokeDLResult,"<regular expression>");

    Instead of RExtract/RExtractall function can I use any other way like making the response as an context/object and fetch the data with . notation? Please share some examples...

     

    please help asap.

    Regards,

    Ray

     


     

    Hello,

    You have couple o options

    1.  GetByXPath

    2.  Processing the data as is..

    Here is how you will handle the results...

    WSInvokeDLResult.CalculateServiceImpactDocumentResponse.<VariableName>.  

    You could access it directly like that.

     

    If you are using Impact 6.1.1 , we do have a helper tool that will show you the policy format on how to process the request.

     

    Here is the link ..

     

    https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Tivoli%20Netcool%20Impact/page/Netcool%20Impact%206.1.1

    Please read the following pacakge.

    Helper functionality to identify Netcool/Impact policy syntax for retrieving web service response data

    Thanks and Regards

    Sudhakar

     

  • RayPatil
    RayPatil
    4 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2013-06-26T16:01:43Z  

    Hello,

    You have couple o options

    1.  GetByXPath

    2.  Processing the data as is..

    Here is how you will handle the results...

    WSInvokeDLResult.CalculateServiceImpactDocumentResponse.<VariableName>.  

    You could access it directly like that.

     

    If you are using Impact 6.1.1 , we do have a helper tool that will show you the policy format on how to process the request.

     

    Here is the link ..

     

    https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Tivoli%20Netcool%20Impact/page/Netcool%20Impact%206.1.1

    Please read the following pacakge.

    Helper functionality to identify Netcool/Impact policy syntax for retrieving web service response data

    Thanks and Regards

    Sudhakar

     

    Hi Sudhakar/Oscar,

    I code looks like this:

    WSInvokeDLResult = WSInvokeDL(WSService, WSEndPoint, WSMethod, WSParams);

    log(WSInvokeDLResult); >> will print the xml as attached.

    log(WSInvokeDLResult.CalculateServiceImpactResponse); >> will also print the next level output.

    log(WSInvokeDLResult.CalculateServiceImpactResponse.RESPONSE); >> NULL !!!!!
     

    I am handling the XML response in impact policy to fetch the individual item values, But result is NULL!! I want to drill down to last item to fetch the value in it.

    Please find attached soapui-XML response format and help me. Please do the needful

    Attachments

  • SudhakarChellam
    SudhakarChellam
    19 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2013-06-26T18:11:43Z  
    • RayPatil
    • ‏2013-06-26T16:01:43Z

    Hi Sudhakar/Oscar,

    I code looks like this:

    WSInvokeDLResult = WSInvokeDL(WSService, WSEndPoint, WSMethod, WSParams);

    log(WSInvokeDLResult); >> will print the xml as attached.

    log(WSInvokeDLResult.CalculateServiceImpactResponse); >> will also print the next level output.

    log(WSInvokeDLResult.CalculateServiceImpactResponse.RESPONSE); >> NULL !!!!!
     

    I am handling the XML response in impact policy to fetch the individual item values, But result is NULL!! I want to drill down to last item to fetch the value in it.

    Please find attached soapui-XML response format and help me. Please do the needful

    Can you please try Response ? instead of RESPONSE.

    We may have to look at the jar file , do not post the jar file here..

     

    Thanks and Regards

    Sudhakar

  • RayPatil
    RayPatil
    4 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2013-06-27T06:03:54Z  

    Can you please try Response ? instead of RESPONSE.

    We may have to look at the jar file , do not post the jar file here..

     

    Thanks and Regards

    Sudhakar

    Hi Sudhakar,

    Thank you verymuch for your quick response. I tried with Response instead of RESPONSE: No method error!

    Caused by: com.micromuse.common.parser.PolicyException: Unhandled Exception: java.lang.NoSuchMethodException in policy: Ray_WS_Test1 at line: 41 .com.micromuse.common.parser.internal.core.DefaultExceptionHandler.handle(DefaultExceptionHandler.java:77)

     

    please find the log which shows the response coming from webservice (stored in return variable WSInvokeDLResult).

    RESPONSE doesn't reply any value!

    log(WSInvokeDLResult); >> will print the xml as attached.

    log(WSInvokeDLResult.CalculateServiceImpactResponse); >> will also print the next level output.

    log(WSInvokeDLResult.CalculateServiceImpactResponse.RESPONSE); >> NULL !!!!!

     

    Regards,

    Ray

     

     

     

     

     

     

    Attachments

  • SudhakarChellam
    SudhakarChellam
    19 Posts

    Re: Parsing/Using data returned from Webservice call

    ‏2013-07-02T20:52:59Z  
    • RayPatil
    • ‏2013-06-27T06:03:54Z

    Hi Sudhakar,

    Thank you verymuch for your quick response. I tried with Response instead of RESPONSE: No method error!

    Caused by: com.micromuse.common.parser.PolicyException: Unhandled Exception: java.lang.NoSuchMethodException in policy: Ray_WS_Test1 at line: 41 .com.micromuse.common.parser.internal.core.DefaultExceptionHandler.handle(DefaultExceptionHandler.java:77)

     

    please find the log which shows the response coming from webservice (stored in return variable WSInvokeDLResult).

    RESPONSE doesn't reply any value!

    log(WSInvokeDLResult); >> will print the xml as attached.

    log(WSInvokeDLResult.CalculateServiceImpactResponse); >> will also print the next level output.

    log(WSInvokeDLResult.CalculateServiceImpactResponse.RESPONSE); >> NULL !!!!!

     

    Regards,

    Ray

     

     

     

     

     

     

    Hi,

    Does the WSDL contains the Response as one of the output element ? If its defined as xsd:any then you will not find the Response or RESPONSE object.

    In that scenario you have the option of using GetByXPath if you are using 6.1 Impact.

     

    Thanks and Regards

    Sudhakar