Announcement

Collapse
No announcement yet.

How to process SOAP response from Destination

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

  • How to process SOAP response from Destination

    Hello,

    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

    Code:
    default xml namespace = new Namespace("soap","[url]http://schemas.xmlsoap.org/soap/envelope/"«»[/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
    Code:
    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 :-(

    Alessandro

    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 :

    Code:
    var responseVal = responseMap.get('Destination1').getMessage();
    result = new XML(responseVal);
    result.setnamespace(new Namespace("soap", "[url]http://schemas.xmlsoap.org/soap/envelope/"«»[/url]));
    channelMap.put('PID',result['soap:Body']['LoginSessionResponse']['LoginSessionResult']);
    unfortunally I stil have the error : Use of undefined namespace prefix: soap

    even tried to put in the preprocessor : (found in the forum)
    Code:
    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

    Alessandro

    Edit
    here is even a better example : http://cwiki.apache.org/CXF20DOC/javascript.html
    But still struggeling with Use of undefined namespace prefix: soap

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

    Comment


    • #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
      Code:
      <soap:Envelope xmlns:«»soap="[url]http://schemas.xmlsoap.org/soap/envelope/"[/url] xmlns:«»xsi="[url]http://www.w3.org/2001/XMLSchema-instance"[/url] xmlns:«»xsd="[url]http://www.w3.org/2001/XMLSchema"><soap:Body><DinetQueryResponse[/url] xmlns="[url]http://www.vumc.nl"><DinetQueryResult><XMLData><NewDataSet>[/url]
        <Table>
          <RECORD>1005989</RECORD>
          <PATIENTNUMMER_IN>9005989</PATIENTNUMMER_IN>
          <PATIENTNUMMER>0005991</PATIENTNUMMER>
          <GEBOORTEDATUM>09-06-1921</GEBOORTEDATUM>
          <GEBOORTEDATUM_VAAGHEID>0</GEBOORTEDATUM_VAAGHEID>
          <NAAM_MAN>SANDELOWSKY</NAAM_MAN>
          <NAAM_VROUW>GOLDBERGER</NAAM_VROUW>
          <EERSTE_VOORLETTER_OF_VOORNAAM>EVA</EERSTE_VOORLETTER_OF_VOORNAAM>
          <GESLACHT>V</GESLACHT>
          <GESLACHT_UK>F</GESLACHT_UK>
          <SYNONIEMNUMMER_AANWEZIG_IND>+</SYNONIEMNUMMER_AANWEZIG_IND>
        </Table>
      </NewDataSet></XMLData><XMLSchema><?xml version="1.0" encoding="utf-16"?>
      <xs:«»schema id="NewDataSet" xmlns="" xmlns:«»xs="[url]http://www.w3.org/2001/XMLSchema"[/url] xmlns:msdata="urn:«»schemas-microsoft-com:«»xml-msdata">
        <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:Locale="nl-NL">
          <xs:complexType>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:element name="Table">
                <xs:complexType>
                  <xs:«»sequence>
                    <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" />
                  </xs:«»sequence>
                </xs:complexType>
              </xs:element>
            </xs:choice>
          </xs:complexType>
        </xs:element>
      </xs:«»schema></XMLSchema><Message>Succes</Message></DinetQueryResult></DinetQueryResponse></soap:Body></soap:Envelope>
      I don't where the CDATA has gone from the response ?? but it still works.

      Code:
      logger.info("Transforming SOAP Response"«»);
      // Get the SOAP response value from destination DinetSOAP
      // and turn it in a XML object
      var responseVal = responseMap.get('DinetSOAP').getMessage();
      logger.info('ResponseVal:'+responseVal);
      msg = new XML(responseVal);
      // declare two new XML namespace objects
      var soap  = new Namespace("[url]http://schemas.xmlsoap.org/soap/envelope/"«»[/url]);
      var vumc  = new Namespace("[url]http://www.vumc.nl"«»[/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();
      logger.info(strXMLData);
      msg2 = new XML(strXMLData);
      channelMap.put('SoapResponseXML', strXMLData);
      Post edited by: huubvandemortel, at: 01/22/2008 05:03

      Comment


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

        Hi,

        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.

        Thanks,

        Comment


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

          Code:
          var responseVal = responseMap.get('Destination 1').getMessage();
          
          msg = new XML(responseVal);
          
          channelMap.put('PIDResponse',msg..*::«»PatientSearchResult.toString());
          huubvandemortel's code works, but this does the same thing in fewer lines.

          Comment


          • #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:
            Code:
            channelMap.put('MyXmlResponse',msg..*::«»MySoapResult.toString());
            When I remove the «» characters, the err disappears.

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

            Thank you!

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

            Comment


            • #7
              Thank you

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

              Comment

              Working...
              X