web stats
Extracting values from Web service Response - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-02-2014, 11:33 AM
HeckyBecky HeckyBecky is offline
What's HL7?
 
Join Date: Apr 2014
Posts: 5
HeckyBecky is on a distinguished road
Default Extracting values from Web service Response

I have a channel that calls a web service and receives a response as below:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header/>
<soap:Body>
<GetPDFStreamResponse xmlns="http://tempuri.org/">
<GetPDFStreamResult>Some Response</GetPDFStreamResult>
</GetPDFStreamResponse>
</soap:Body>
</soap:Envelope>


How do I extract the value from <GetPDFStreamResult> element?

thanks --
Reply With Quote
  #2  
Old 05-02-2014, 12:37 PM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,119
narupley is on a distinguished road
Default

If you wrap that string in an E4X XML object with "new XML()", then you can use standard E4X syntax to extract the node (make sure to handle namespaces appropriately. There are many many examples of that on these forums, and also this will be helpful:

http://wso2.com/project/mashup/0.2/d...uickstart.html
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #3  
Old 05-05-2014, 08:36 AM
HeckyBecky HeckyBecky is offline
What's HL7?
 
Join Date: Apr 2014
Posts: 5
HeckyBecky is on a distinguished road
Default

I tried mimicing your example on the web.

var soap = new Namespace('http://www.w3.org/2003/05/soap-envelope');
default xml namespace = 'http://tempuri.org/';
var pdfstr = msg.soap::Body.GetPDFStreamResponse.GetPDFStreamRe sult.toString();


It errors out saying "msg" is not defined.
Reply With Quote
  #4  
Old 05-05-2014, 08:38 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,119
narupley is on a distinguished road
Default

Quote:
Originally Posted by HeckyBecky View Post
I tried mimicing your example on the web.

var soap = new Namespace('http://www.w3.org/2003/05/soap-envelope');
default xml namespace = 'http://tempuri.org/';
var pdfstr = msg.soap::Body.GetPDFStreamResponse.GetPDFStreamRe sult.toString();


It errors out saying "msg" is not defined.
Where are you doing that? In the postprocessor? If so then no "msg" variable will be defined. You'll need to create it yourself in that case.

Since you did not specify, I'll assume you're working with the latest version (3.0.2). If you use a response transformer on that Web Service Sender destination, it will be much easier, because the response will already be serialized into the "msg" E4X XML object.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #5  
Old 05-05-2014, 10:44 AM
HeckyBecky HeckyBecky is offline
What's HL7?
 
Join Date: Apr 2014
Posts: 5
HeckyBecky is on a distinguished road
Default

I tried this in the Transformer:


msg['soap:Body']['GetPDFStreamResponse']['GetPDFStreamResult'].toString()

Will this work.

Yes, I'm using Mirth 3.0.2.7140 version

Thanks -
Reply With Quote
  #6  
Old 05-05-2014, 10:45 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,119
narupley is on a distinguished road
Default

Quote:
Originally Posted by HeckyBecky View Post
I tried this in the Transformer:


msg['soap:Body']['GetPDFStreamResponse']['GetPDFStreamResult'].toString()

Will this work.

Yes, I'm using Mirth 3.0.2.7140 version

Thanks -
That won't work because "soap" is a bound prefix. Instead, you need to define that as a Namespace object, and use "msg.soap::Body".
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 01:44 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation