Q:
Hello All,
I am facing problem in mapping an element from source to destination.
I am polling data from a database which will trigger my process. In the receved message i have a field which has XML content. Based on the XML content i have to call a WCF service. I have a map that transforms the input message to the WCF request (simply by extracting the content of the XML element). But it seems it is not working. My sample message is:
<Input><Id>1</Id><Type>Add</Type><Xml><Add><A>10</A><B>10</B></Add></Xml></Input>
Here i need to extract the Xml element content in a map and assign that to destination. (Note the XML Content is the complete message for my destination). I have a scripting functoid which replaces the "<" with "<" and ">" with ">" and the output is connected to a another scripting functoid that maps the replaced content to the root node of the destination. But when i test the map in design time, the values are not getting replaced. I am not sure why this happens. Below is the code i used in the maps:
First scripting functoid:
public string GetXml(string param)
{
param = param.Replace("<","<");
param = param.Replace(">",">");
return param;
}
{
param = param.Replace("<","<");
param = param.Replace(">",">");
return param;
}
Output of this is given to an XSLT Template of a scripting functoid:
<xsl:template name="TypedPollingResultSet0">
<xsl:param name="param1" />
<xsl:value-of select="$param1" />
</xsl:template>
Below is my map:
Sol:
If you use any Orchestration then Just do this in an expression shape.
Create a variable xmlDoc of type System.Xml.XmlDocument.
varString = xpath(msgPollingResult,"string(/*[local-name()='Input' and namespace-uri()='']/*[local-name()='Xml' and namespace-uri()=''])");
//loads this to the string variable. "<Add><A>10</A><B>10</B></Add>";
varString = varString .Replace("<", "<");
varString = varString .Replace(">", ">");
xmlDoc.LoadXml(varString);
msgAdd = xmlDoc; //msgAdd is your output.
If there are some namespaces that you have to change, use this msg as input to the map and modify it.
Else If you are Using a Messaging solution
How about creating a custom C# library and then using tat in the scripting functoid. For this you would need to GAC the assembly and use it in the map.
Note: use the above code in a C# Library Gac it and call the method in Biztalk Mapper
Thanks.
No comments:
Post a Comment
Post Your Comment...