Mirth Community

Mirth Community (http://www.mirthcorp.com/community/forums/index.php)
-   Support (http://www.mirthcorp.com/community/forums/forumdisplay.php?f=6)
-   -   Handling namespaces in JavaScript XML constructor (http://www.mirthcorp.com/community/forums/showthread.php?t=13376)

ahart 03-05-2015 03:41 PM

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?

Anirudh 03-05-2015 04:14 PM

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()

ahart 03-05-2015 07:08 PM

I don't see how that's much different than what I've tried. Am I missing something?

Anirudh 03-05-2015 07:26 PM

Quote:

Originally Posted by ahart (Post 46350)
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?

ahart 03-06-2015 12:26 PM

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.

mxaos 03-05-2018 01:28 AM

Stuck on TypeError: The prefix "soap" for element "soap:Envelope" is not bound.
 
Quote:

Originally Posted by ahart (Post 46373)
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


All times are GMT -8. The time now is 05:31 PM.

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