No announcement yet.

How to process SOAP response from Destination

  • Filter
  • Time
  • Show
Clear All
new posts

  • How to process SOAP response from Destination


    I have setup a HL7 LLP listeren service, and send it to 2 soap destinations. (Destination1 & Destination2). The first SOAP destiontion is actually needed to login to the SOAP server. I get back a session ID which i need to use in the second destination.

    I search the forum how I sould get from the response message a value back and pass that in to the second destination, but i want not able to find a way.

    I have putted this code into the transformer of Destionation2

    default xml namespace = new Namespace("soap","[url]"«»[/url]);
    var responseVal = responseMap.get('Destination1');
    globalMap.put('session_id', ResponseFactory.getSuccessResponse('responseVal'));
    (the default xml namespace was found in the forum)

    I get the next error
    TypeError: error: Use of undefined namespace prefix: soap
    It is so fustrating, i know exactly what i want to do, but i don't know how :-(


    Post edited by: Alessandro, at: 01/16/2008 05:08

  • #2
    Re:How to process SOAP response from Destination

    Hello, this weekend Iplayed once again with Mirth and my Sosp Response, and I change the code (after searching the forum and googleing) to this :

    var responseVal = responseMap.get('Destination1').getMessage();
    result = new XML(responseVal);
    result.setnamespace(new Namespace("soap", "[url]"«»[/url]));
    unfortunally I stil have the error : Use of undefined namespace prefix: soap

    even tried to put in the preprocessor : (found in the forum)
    return message.replace(/<soap:/g, "<"«»).replace(/</soap:/g, "</"«»);
    Anybody knows where and how i have to put the namespace? Now i have placed the code into the Transformer of Destination2


    here is even a better example :
    But still struggeling with Use of undefined namespace prefix: soap

    Post edited by: Alessandro, at: 01/21/2008 03:44


    • #3
      Re:How to process SOAP response from Destination

      Maybe you find usefull code in this:

      it gets the essential XML structure of the SOAP response
      <soap:Envelope xmlns:«»soap="[url]"[/url] xmlns:«»xsi="[url]"[/url] xmlns:«»xsd="[url]"><soap:Body><DinetQueryResponse[/url] xmlns="[url]"><DinetQueryResult><XMLData><NewDataSet>[/url]
      </NewDataSet></XMLData><XMLSchema><?xml version="1.0" encoding="utf-16"?>
      <xs:«»schema id="NewDataSet" xmlns="" xmlns:«»xs="[url]"[/url] xmlns:msdata="urn:«»schemas-microsoft-com:«»xml-msdata">
        <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:Locale="nl-NL">
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:element name="Table">
                    <xs:element name="RECORD" type="xs:int" minOccurs="0" />
                    <xs:element name="PATIENTNUMMER_IN" type="xs:«»string" minOccurs="0" />
                    <xs:element name="PATIENTNUMMER" type="xs:«»string" minOccurs="0" />
                    <xs:element name="GEBOORTEDATUM" type="xs:«»string" minOccurs="0" />
                    <xs:element name="GEBOORTEDATUM_VAAGHEID" type="xs:int" minOccurs="0" />
                    <xs:element name="NAAM_MAN" type="xs:«»string" minOccurs="0" />
                    <xs:element name="NAAM_VROUW" type="xs:«»string" minOccurs="0" />
                    <xs:element name="EERSTE_VOORLETTER_OF_VOORNAAM" type="xs:«»string" minOccurs="0" />
                    <xs:element name="OVERIGE_VOORLETTERS" type="xs:«»string" minOccurs="0" />
                    <xs:element name="GESLACHT" type="xs:«»string" minOccurs="0" />
                    <xs:element name="GESLACHT_UK" type="xs:«»string" minOccurs="0" />
                    <xs:element name="MEERLING_IND" type="xs:«»string" minOccurs="0" />
                    <xs:element name="SYNONIEMNUMMER_AANWEZIG_IND" type="xs:«»string" minOccurs="0" />
      I don't where the CDATA has gone from the response ?? but it still works.

      Code:"Transforming SOAP Response"«»);
      // Get the SOAP response value from destination DinetSOAP
      // and turn it in a XML object
      var responseVal = responseMap.get('DinetSOAP').getMessage();'ResponseVal:'+responseVal);
      msg = new XML(responseVal);
      // declare two new XML namespace objects
      var soap  = new Namespace("[url]"«»[/url]);
      var vumc  = new Namespace("[url]"«»[/url]);
      // use a  qualified name to extract the soap message body
      //var body = msg.soap::Body;
      //var Response = msg.soap::Body.vumc::«»DinetQueryResponse;
      var Result   = msg..*::«»DinetQueryResult;
      // Get the XMLData tree. Because the data is enclosed in a CDATA
      // field it is transformed to a string an back to a XML object
      var XMLData  = Result..*::«»XMLData;
      var strXMLData = XMLData.toString();;
      msg2 = new XML(strXMLData);
      channelMap.put('SoapResponseXML', strXMLData);
      Post edited by: huubvandemortel, at: 01/22/2008 05:03


      • #4
        Re:How to process SOAP response from Destination


        I'm receiving the same error as the original poster, "TypeError: error: Use of undefined namespace prefix: soap"

        I'm getting the error without any javascript code. By just defining a Transformer, I received the namespace error. If I remove the transformer and just write the response to a FileWriter I'm ok.

        Any help would be appreciated.



        • #5
          Re:How to process SOAP response from Destination

          I was able to figure this out on my own, so I'd like to post what my solution was.

          First, I was trying to send the response from my Soap call to a new channel, with a Soap Listener Source. That was my first mistake. I have 2 destinations, Destination 1 is a SOAP Writer, which makes my soap call. I have the Send Response To parameter set to "None".

          The response is an xml data set.

          I've defined Destination 2 as a file writer (I want to write the results to a file). I've added a JavaScript Transformer using code very similar to the code huubvandemortel provided.

          var responseVal = responseMap.get('Destination 1').getMessage();
          msg = new XML(responseVal);
          huubvandemortel's code works, but this does the same thing in fewer lines.


          • #6
            Hi Pug

            I had the same problem, and thank you for your solution. I am confident it will work.

            I am encountering an err message when using the «» syntax.

            Error in connector "My Destination Connector" at step 0 ()
            Error on line 8: illegal character

            Line 8 is:
            When I remove the «» characters, the err disappears.

            Does anyone know what's happening here, or a solution?

            Thank you!

            No response required, the solution works without the «» syntax. Thanks for the fix, Pug.
            Last edited by Philoushka; 06-04-2009, 10:56 AM.


            • #7
              Thank you

              I realize this is an old topic, but this has been a huge help. Thanks!