Ask a Question

How to capture multiple lines response using groovy script

dinojadhav
Occasional Contributor

How to capture multiple lines response using groovy script

Hello All,

 

I have below xml response and want to capture/store all the data from same using groovy script.

I dont know how to store it. Can anyone please help me a bit new to coding. I want to capture each element like C14, J0 and so on.

 

<Response>ADDCAN 788 C14 J0 D2 P0 Z0 I0 R0 Y0
G0 S0 X0 B0 M2 K0 L0 V3
H9 U4 Q0 T0 W0 E0 O0 N0
TTL 34</Response>

 

Below is the response : 

 

<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header>
<eb:MessageHeader eb:version="1.0" soap-env:mustUnderstand="1" xmlns:eb="http://www.ebxml.org/namespaces/messageHeader">
<eb:From>
<eb:PartyId eb:type="URI">Server</eb:PartyId>
</eb:From>
<eb:To>
<eb:PartyId eb:type="URI">Client</eb:PartyId>
</eb:To>
<eb:CPAId>IPCC</eb:CPAId>
<eb:ConversationId>9DB7_921682_1204548352874</eb:ConversationId>
<eb:Service>SabreCommandLLSRQ</eb:Service>
<eb:Action>SabreCommandLLSRS</eb:Action>
<eb:MessageData>
<eb:MessageId>362528217345300870</eb:MessageId>
<eb:Timestamp>2019-09-25T06:02:14</eb:Timestamp>
<eb:RefToMessageId>mid:1</eb:RefToMessageId>
</eb:MessageData>
</eb:MessageHeader>
<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext">
<wsse:BinarySecurityToken valueType="String" EncodingType="wsse:Base64Binary">Shared/IDL:IceSess\/SessMgr:1\.0.IDL/Common/!ICESMS\/STSB!ICESMSLB\/STS.LB!-2970499087114656116!453481!0</wsse:BinarySecurityToken>
</wsse:Security>
</soap-env:Header>
<soap-env:Body>
<SabreCommandLLSRS Version="1.0" xmlns="http://webservices.sabre.com/sabreXML/2003/07">
<Response>ADDCAN 788 C14 J0 D2 P0 Z0 I0 R0 Y0
G0 S0 X0 B0 M2 K0 L0 V3
H9 U4 Q0 T0 W0 E0 O0 N0
TTL 34</Response>
</SabreCommandLLSRS>
</soap-env:Body>
</soap-env:Envelope>

 

Thanks in advance .....

 

Dinesh

 

5 REPLIES 5
dinojadhav
Occasional Contributor

Hi All,

 

Any thoughts on my query

nmrao
Community Hero

what is your use case?


Regards,
Rao.
dinojadhav
Occasional Contributor

I am trying to capture all the values as stated in my query. Didn't understand what do you expect in as use case.

Could you please explain in detail.

dinojadhav
Occasional Contributor

Hi Rao, Thanks for your support. I tried your script and able to split the multiple lines data, but how to set a particular data.

 

Below is my actual response :

  • Mon Nov 04 12:01:57 IST 2019:INFO:AM FACTS 1.SSR GSTN AM HK1/IND/22SSSSAAA0 1.1 UHVNKSK/KGRXXZ 0A1Z5/IBM/S 2.SSR GSTN AM HK1/IND/22DDDDDDDD 1.1 UHVNKSK/KGRXXZ DD1Z5/IBM/P

and I want to capture and set below data from above response :

1.SSR GSTN AM HK1/IND/22SSSSAAA0

 

then how to capture and set that.

cancel
Showing results for 
Search instead for 
Did you mean: