web stats
Handling namespaces in JavaScript XML constructor - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-05-2015, 03:41 PM
ahart ahart is offline
OBX.2 Kenobi
 
Join Date: Oct 2014
Posts: 56
ahart is on a distinguished road
Question Handling namespaces in JavaScript XML constructor

I have some javascript code in a channel scoped code template function that was running in Mirth 2.3 where I create an XMl object from a String containing XML.

e.g., var resultXml = new XML(responseMap.get('Call DIS').getMessage());

I'm converting to Mirth 3.2. Now, I'm getting an error because it's encountering some elements with a namespace prefix:

LINE NUMBER: 198
DETAILS: TypeError: The prefix "S" for element "S:Envelope" is not bound.

I've spent a few hours now fruitlessly looking for the correct way to declare the namespace.

I tried preceding this with:
var soap = new Namespace("S","http://schemas.xmlsoap.org/soap/envelope/");
default xml namespace=soap;

and also...

XML.addNamespace(soap);
XML.setNamespace(soap);

What is the correct way to do this?
Reply With Quote
  #2  
Old 03-05-2015, 04:14 PM
Anirudh Anirudh is offline
OBX.3 Kenobi
 
Join Date: Sep 2012
Posts: 135
Anirudh is on a distinguished road
Default

for soap name space:

var soapenv = new Namespace('http://schemas.xmlsoap.org/soap/envelope/');

set default name space as

default xml namespace = '<URL>'

you can get response from destination as

var resp = responseMap.get('destination 1 name').getMessage();

var respXML = new XML(resp);

to check an element

var element = respXML.soapenv::Body:elementname.elementname.toSt ring()
Reply With Quote
  #3  
Old 03-05-2015, 07:08 PM
ahart ahart is offline
OBX.2 Kenobi
 
Join Date: Oct 2014
Posts: 56
ahart is on a distinguished road
Default

I don't see how that's much different than what I've tried. Am I missing something?
Reply With Quote
  #4  
Old 03-05-2015, 07:26 PM
Anirudh Anirudh is offline
OBX.3 Kenobi
 
Join Date: Sep 2012
Posts: 135
Anirudh is on a distinguished road
Default

Quote:
Originally Posted by ahart View Post
I don't see how that's much different than what I've tried. Am I missing something?
Did you unchecked the strip name space from both inbound and outbound message template?
Reply With Quote
  #5  
Old 03-06-2015, 12:26 PM
ahart ahart is offline
OBX.2 Kenobi
 
Join Date: Oct 2014
Posts: 56
ahart is on a distinguished road
Default

In a channel I have a destination that makes a call out to some Java code. That java code returns a response which I place into a channelMap variable. In a subsequent destination I then pass this response into a code template function with channel scope. That's where I am encountering the problem. So, I don't see how the message templates would come into play. (I did see the other forum postings regarding this...) This worked in 2.x, started having problems in 3.2.
Reply With Quote
  #6  
Old 03-05-2018, 01:28 AM
mxaos mxaos is offline
Mirth Newb
 
Join Date: Jun 2011
Location: Padua, Italy
Posts: 6
mxaos is on a distinguished road
Default Stuck on TypeError: The prefix "soap" for element "soap:Envelope" is not bound.

Quote:
Originally Posted by ahart View Post
In a channel I have a destination that makes a call out to some Java code. That java code returns a response which I place into a channelMap variable. In a subsequent destination I then pass this response into a code template function with channel scope. That's where I am encountering the problem. So, I don't see how the message templates would come into play. (I did see the other forum postings regarding this...) This worked in 2.x, started having problems in 3.2.
I'm in your exact situation right now. Have you found some solution to this problem?

Thank you
Reply With Quote
Reply

Tags
e4x, javascript, namespaces, xml

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 11:17 AM.


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