Announcement

Collapse

Mirth Connect 3.12.0 Released!

Mirth Connect 3.12.0 is now available as an appliance update and on our GitHub page. This release includes database performance improvements, improves visual HL7 representation, message pruning, keystore handling, PDF generation, community contributions, and fixes several security vulnerabilities. This release also contains many improvements to commercial extensions. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

SOAP envelope namespace problem

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

  • SOAP envelope namespace problem

    Hello:

    I've read some posts about this issue, but I haven't found the solution. I have a channel with this input template:

    Code:
    <soapenv:Envelope xmlns:«»soapenv="[url]http://schemas.xmlsoap.org/soap/envelope"><soapenv:Body>[/url]
       <ns:fusionaPacientesResponse xmlns:ns="[url]http://pojo">[/url]
            <ns:return type="pojo.RespuestaWS" xmlns:ax21="[url]http://pojo/xsd">[/url]
                <ax21:messageId>00000003</ax21:messageId>
                <ax21:«»success>false</ax21:«»success>
            </ns:return>
       </ns:fusionaPacientesResponse>
    </soapenv:Body>
    </soapenv:Envelope>
    In an input transform step I'm trying to obtain the "ax21:messageId" value, but at runtime it raises the next exception:

    Code:
    TypeError: error: Use of undefined namespace prefix: soapenv (com.webreach.mirth.server.MirthJavascriptTransformerException)
    	at com.webreach.mirth.server.mule.transformers.JavaScriptTransformer.evaluateScript(JavaScriptTransformer.java:457)
    	at com.webreach.mirth.server.mule.transformers.JavaScriptTransformer.transform(JavaScriptTransformer.java:350)
    	at org.mule.transformers.AbstractEventAwareTransformer.doTransform(AbstractEventAwareTransformer.java:48)
    	at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:197)
    	at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:200)
    	at org.mule.impl.MuleEvent.getTransformedMessage(MuleEvent.java:251)
    	at org.mule.routing.inbound.SelectiveConsumer.isMatch(SelectiveConsumer.java:61)
    	... 11 moreCaused by: com.webreach.mirth.server.MirthJavascriptTransformerException:
    What's happening? The soapenv namespace is defined correctly. Isn't it?

    Please, I need a solution. Thanks in advance ;-)

    Carlos.

  • #2
    Re:SOAP envelope namespace problem

    Hello all:

    I've found a workaround. I don't like it very much but it works:

    I've included a preprocessor script in my channel:

    Code:
    // Modify the message variable below to pre process data
    var newMessage = message.replace(/xmlns:?[^=]*=[""][^""]*[""]/g, '');
    var nspaces = new Array("soapenv", "ns", "ax21"«»);
    
    var buscando;
    for (i=0; nspaces[i]; i++){
    	buscando = nspaces[i] + ":";
    	while(newMessage.indexOf(buscando)!= -1){
    		newMessage = newMessage.replace(buscando , ""«»);
    	}
    }
    return newMessage;
    With this code I drop all namespaces from the message. Later, in a transformer step, I get the xml fields without problems, using a xml template without any namespace:

    Code:
    var messageId = msg..messageId.toString();
    var success = msg..success.toString();
    channelMap.put('messageId',messageId);
    channelMap.put('success',success);

    If anybody knows a more elegant way to receive xml messages with namespaces, please post it. I'll be waiting for it. Bye:

    Carlos.

    Comment


    • #3
      Re:SOAP envelope namespace problem

      I've used this code to process the response of a WebService:

      Code:
      channelMap.put('Result',_msg..*::Result.toString());
      That you can adapt to:

      Code:
      channelMap.put('messageId',_msg..*::messageId.toString());
      channelMap.put('success',_msg..*::«»success.toString());
      This will look for all nodes called "messageId" or "success" in all namespaces.

      The other way you can try to solve your issue is processing the SOAP response with XSLT if you need more complex operations with XML.

      Hope that helps

      Comment

      Working...
      X