سؤال

For an integration with a 3th party webservice, I am receiving my "actual" data in a CDATA section.

<getDocumentsReqResponse xmlns="http://tempuri.org/">
    <getDocumentsReqResult>
        <![CDATA[<?xml version="1.0"?>
<wsResult>
<rsCode>00</rsCode>
<rsMessage>...</rsMessage>
</wsResult>]]></getDocumentsReqResult>
</getDocumentsReqResponse>

So I was trying to use the Inbound path option on the send port. But When I try to do this, I get an empty message. Does this option work with CDATA? I just entered the xpath (/[local-name()='getDocumentsReqResponse' and namespace-uri()='http://tempuri.org/']/[local-name()='getDocumentsReqResult' and namespace-uri()='http://tempuri.org/']) and put the Node encoding to string. Or am I doing something wrong. I have used it in the past when I receive an HTML encoded string, but never with CDATA.

I will need an orchestration in the process anyway, so if that is the only option I will have to go for that.

Thanks for the help

هل كانت مفيدة؟

المحلول 2

I fixed it with a simple xslt

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var s0" version="1.0" xmlns:s0="http://tempuri.org/">
  <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
  <xsl:template match="/">
    <xsl:apply-templates select="/s0:getDocumentsReqResponse" />
  </xsl:template>
  <xsl:template match="/s0:getDocumentsReqResponse">
    <xsl:value-of select="normalize-space(s0:getDocumentsReqResult)" disable-output-escaping="yes" />
  </xsl:template>
</xsl:stylesheet>

That also does the trick. :-)

نصائح أخرى

Try:

/[local-name()='getDocumentsReqResponse']/[local-name()='getDocumentsReqResult']/text()

Technically in xPath, text() should return the CDATA content. You can test it in any .Net app since it will behave the same.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top