Announcement

Collapse
No announcement yet.

Handling namespaces in JavaScript XML constructor

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?

  • #2
    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()

    Comment


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

      Comment


      • #4
        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?

        Comment


        • #5
          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.

          Comment


          • #6
            Stuck on TypeError: The prefix &quot;soap&quot; for element &quot;soap:Envelope&quot; is not bound.

            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

            Comment

            Working...
            X