开发者

Problem with BizTalk multi-input map

开发者 https://www.devze.com 2023-02-03 02:07 出处:网络
I have a map that takes 2 input messages, like this: <ns0:Root> <InputMessagePart_0> <root>

I have a map that takes 2 input messages, like this:

<ns0:Root>
   <InputMessagePart_0>
      <root>
         <Indicator>1</Indicator>
         <NewValue>AAA</NewValue>
      </root>
   <InputMessagePart_0>
   <InputMessagePart_1>
      <root>
         <Value>BBB</Value>
      </root>
   <InputMessagePart_1>
</ns0:Root>

(Lots of the nodes are not shown for clarity) The ouput message looks like this:

<Root>
   <Value>AAA</Value>
</Root>

(It's identical to InputMessagePart_1)

If the Indicator is 1, I want Value to be replaced with NewValue. If it's 0, I want Value to stay the same. I used a scripting functoid with code like this:

public string Get_Value(string indicator, string value, string newValue)
{
   if(indicator == "1")
   {
      return newVal开发者_运维技巧ue;
   }
   else
   {
      return value;
   }
}

I'm running into problems due to the fact that Value might not actually occur in the original InputMessagePart_1 - if it doesn't, I want to create it. With the script above, even though Indicator is 1, I'm not getting a return string when Value doesn't exist.

Any suggestions?

Updated: I did some further testing by removing the if/then logic and just returned a hard-coded string from the functoid, and I get the same results... it seems that just having the empty input kills the entire functionality of the functoid...


You should want to use the Equal functoid and test whether the value is 1. You'll then feed the result to the input of two functoids:

  • First, to a Value Mapping functoid, which is connected to the <New Value> tag in the first part of the source schema.
  • Second, to a Logical Not functoid, which is then connected to another Value Mapping functoid connected to the <Value> tag in the second part of the source schema.

Problem with BizTalk multi-input map

If the <Indicator>; tag does not contain the expected value 1 or is not present in the source message, the Logical Equal functoid will return False, and the second branch of the map will execute.

It doesn't matter whether the Value tag is present in the second part of the source schema. If it is not, either one of the Value Mapping functoids will create it in the destination.

If you definitely need to depend upon the <Indicator> tag, you might want to use the Logical Existence functoid, that returns whether any specified input node appears in the source message.


If all else fails using the mapper, you might try switching to XSLT - see here how to scrape the XSLT out of your existing BTM.

The map that you are after looks straightforward:

<?xml version="1.0" encoding="utf-16"?>
<xsl:stylesheet
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > .. etc ... whatever you've scraped out
    <xsl:output ...
    <xsl:template match=...>

<ns1:Root>
<ns1:Value>
    <xsl:choose>
        <xsl:when test="/ns0:Root/ns0:InputMessagePart_0/ns0:root/ns0:Indicator/text()='1'">
            <xsl:value-of select="/ns0:Root/ns0:InputMessagePart_0/ns0:root/ns0:NewValue/text()" />
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="/ns0:Root/ns0:InputMessagePart_1/ns0:root/ns0:Value/text()" />
        </xsl:otherwise>
    </xsl:choose>
<ns1:Value>
</ns1:Root>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号