My client's API requires variable data to be delivered to them via HTTP POST. Some of this data is mapped to the URL and some of the data is in the message body form variables:
Url: http://myclientapi.com/poNumber/111222/complete
Message body variables: carrier=FEDEX&trackingNumber=4XXXXXX&shipDate=2018-12-17
WCF-WebHttp port seems to be the ticket. It is easy enough to define a flat file schema for the message body variables (carrier, trackingNumber and shipDate).
My problem is the URL variable mapping for poNumber in the send port configuration. I want to do something like this:
<BtsHttpUrlMapping>
<Operation Name = "POSHIPPED" Method="POST" Url="/poNumber/{poNumber}/complete"/>
</BtsHttpUrlMapping>
Given that only single occurrence nodes can be promoted via property schema I can't map the poNumber data to the same nodes that I map the message body variables, nor do I want the poNumber name/value included in the message body.
Have I reached the limitations of this particular adapter?
Assuming that the repeating node you are talking about is in the destination schema going to the WCF-WebHttp adatper, and that the poNumber is in a non-repeating node on a schema that you are mapping from.
What you need to do is to create a Property Schema where you define the poNumber as MessageContextPropertyBase
Property Schema
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Scratch.SO53891801propertyschema" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Scratch.SO53891801propertyschema" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<b:schemaInfo schema_type="property" />
</xs:appinfo>
</xs:annotation>
<xs:element name="poNumber" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo propertyGuid="3acc0f2f-64b0-4057-bc59-b8c76ab220a1" propSchFieldBase="MessageContextPropertyBase" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:schema>
You add this property schema your input schema. From your input where your orderNumber is in a non-repeating node, you link the poNumber to the property.
Sample input schema
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Scratch.SO53891801_input" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:ns0="http://Scratch.SO53891801propertyschema" targetNamespace="http://Scratch.SO53891801_input" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<b:imports>
<b:namespace prefix="ns0" uri="http://Scratch.SO53891801propertyschema" location=".\SO53891801propertyschema.xsd" />
</b:imports>
</xs:appinfo>
</xs:annotation>
<xs:element name="Root">
<xs:annotation>
<xs:appinfo>
<b:properties>
<b:property name="ns0:poNumber" xpath="/*[local-name()='Root' and namespace-uri()='http://Scratch.SO53891801_input']/*[local-name()='poNumber' and namespace-uri()='']" />
</b:properties>
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="poNumber" type="xs:string" />
<xs:element name="carrier" type="xs:string" />
<xs:element name="trackingNumber" type="xs:string" />
<xs:element name="shipDate" type="xs:date" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Sample input file
<ns0:Root xmlns:ns0="http://Scratch.SO53891801_input">
<poNumber>poNumber_0</poNumber>
<carrier>carrier_0</carrier>
<trackingNumber>trackingNumber_0</trackingNumber>
<shipDate>1999-05-31</shipDate>
</ns0:Root>
Sample output schema
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Scratch.SO53891801" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Scratch.SO53891801" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="HttpRequestBody">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="FromValue">
<xs:complexType>
<xs:sequence>
<xs:element name="Id" type="xs:string" />
<xs:element name="Value" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Create a map between the two.
Map
<?xml version="1.0" encoding="utf-16"?>
<mapsource Name="BizTalk Map" Version="2" BizTalkServerMapperTool_Version="3.0" XRange="100" YRange="420" OmitXmlDeclaration="Yes" UseXSLTransform="Undefined" TreatElementsAsRecords="No" OptimizeValueMapping="Yes" GenerateDefaultFixedNodes="Yes" PreserveSequenceOrder="No" IgnoreNamespacesForLinks="Yes" method="xml" CopyPIs="No" xmlVersion="1.0">
<SrcTree RootNode_Name="Root">
<Reference Location=".\SO53891801-input.xsd" />
</SrcTree>
<TrgTree RootNode_Name="HttpRequestBody">
<Reference Location=".\SO53891801.xsd" />
</TrgTree>
<ScriptTypePrecedence>
<CSharp Enabled="Yes" />
<ExternalAssembly Enabled="Yes" />
<VbNet Enabled="Yes" />
<JScript Enabled="Yes" />
<XsltCallTemplate Enabled="Yes" />
<Xslt Enabled="Yes" />
</ScriptTypePrecedence>
<TreeValues>
<TestValues />
<ConstantValues />
</TreeValues>
<Pages>
<Page Name="Page 1">
<Links>
<Link LinkID="1" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='carrier']" LinkTo="1" />
<Link LinkID="2" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='trackingNumber']" LinkTo="1" />
<Link LinkID="3" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='shipDate']" LinkTo="1" />
<Link LinkID="4" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='carrier']" LinkTo="/*[local-name()='<Schema>']/*[local-name()='HttpRequestBody']/*[local-name()='FromValue']/*[local-name()='Value']" />
<Link LinkID="5" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='trackingNumber']" LinkTo="/*[local-name()='<Schema>']/*[local-name()='HttpRequestBody']/*[local-name()='FromValue']/*[local-name()='Value']" />
<Link LinkID="6" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='shipDate']" LinkTo="/*[local-name()='<Schema>']/*[local-name()='HttpRequestBody']/*[local-name()='FromValue']/*[local-name()='Value']" />
<Link LinkID="7" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='carrier']" LinkTo="/*[local-name()='<Schema>']/*[local-name()='HttpRequestBody']/*[local-name()='FromValue']/*[local-name()='Id']" Compiler-Copy-Directive="CopyName" />
<Link LinkID="8" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='trackingNumber']" LinkTo="/*[local-name()='<Schema>']/*[local-name()='HttpRequestBody']/*[local-name()='FromValue']/*[local-name()='Id']" Compiler-Copy-Directive="CopyName" />
<Link LinkID="9" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='shipDate']" LinkTo="/*[local-name()='<Schema>']/*[local-name()='HttpRequestBody']/*[local-name()='FromValue']/*[local-name()='Id']" Compiler-Copy-Directive="CopyName" />
<Link LinkID="10" LinkFrom="1" LinkTo="/*[local-name()='<Schema>']/*[local-name()='HttpRequestBody']/*[local-name()='FromValue']" />
</Links>
<Functoids>
<Functoid FunctoidID="1" Functoid-FID="424" X-Cell="53" Y-Cell="173">
<Input-Parameters>
<Parameter Type="link" Value="1" linkIndex="0" Guid="7932e28c-0c98-4f47-aea8-f9a3a709eef0" />
<Parameter Type="link" Value="2" linkIndex="1" Guid="44112afb-3729-4d14-ba00-9053c96964a4" />
<Parameter Type="link" Value="3" linkIndex="2" Guid="eaecaba3-61c0-4cea-ae1b-16316322cea6" />
</Input-Parameters>
</Functoid>
</Functoids>
</Page>
</Pages>
</mapsource>
Context property in message
From the input schema it will promote the property, and it will still exist after the map has executed.
Showing the Context Property still exists after the map on the send port
Related
I have defined a schema with several promoted properties.
I have a two way send port that calls a rest service.
The rest service returns a response matching the message schema. The receive pipeline for the two way send port has an xml disassembler component in it.
I also have a two way receive port.
The receive pipeline of the receive port has a component that publishes multiple messages into the queue so they are available using the GetNext() function. One of the messages matches the schema I published. The next component in the pipeline is an xml disassembler component.
I would have thought that in both ports, because my receive port has an xml disassembler, it would publish the promoted properties of the message so that I can subscribe to them in send ports, The values are not being promoted and I don't know why that is.
Here is my message schema:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://MyMessage" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:ns0="https://MyMessageProperties.PropertySchema" targetNamespace="http://MyMessage" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<b:imports xmlns:b="http://schemas.microsoft.com/BizTalk/2003">
<b:namespace prefix="ns0" uri="https://MyMessageProperties.PropertySchema" location=".\PropertySchema.xsd" />
</b:imports>
</xs:appinfo>
</xs:annotation>
<xs:element name="MessageProcessingResult">
<xs:annotation>
<xs:appinfo>
<b:properties>
<b:property name="ns0:Category" xpath="/*[local-name()='MessageProcessingResult' and namespace-uri()='http://MyMessage']/*[local-name()='Category' and namespace-uri()='']" />
<b:property name="ns0:Code" xpath="/*[local-name()='MessageProcessingResult' and namespace-uri()='http://MyMessage']/*[local-name()='Code' and namespace-uri()='']" />
<b:property name="ns0:ComponentOfOrigin" xpath="/*[local-name()='MessageProcessingResult' and namespace-uri()='http://MyMessage']/*[local-name()='ComponentOfOrigin' and namespace-uri()='']" />
<b:property name="ns0:OriginalMessageTypeValue" xpath="/*[local-name()='MessageProcessingResult' and namespace-uri()='http://MyMessage']/*[local-name()='OriginalMessageType' and namespace-uri()='']/*[local-name()='Value' and namespace-uri()='']" />
<b:property name="ns0:OriginalMessageID" xpath="/*[local-name()='MessageProcessingResult' and namespace-uri()='http://MyMessage']/*[local-name()='OriginalMessageID' and namespace-uri()='']" />
</b:properties>
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="Category">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Success" />
<xs:enumeration value="Problem" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Code" type="xs:string" />
<xs:element name="ComponentOfOrigin" type="xs:string" />
<xs:element name="OriginalMessageID" type="xs:string" />
<xs:element name="OriginalMessageType" type="Type" />
</xs:all>
</xs:complexType>
</xs:element>
<xs:complexType name="Type">
<xs:all>
<xs:element minOccurs="1" maxOccurs="1" name="Value" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="Name" type="xs:string" />
</xs:all>
</xs:complexType>
</xs:schema>
Here is my property schema:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://MyMessageProperties.PropertySchema" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="https://MyMessageProperties.PropertySchema" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<b:schemaInfo schema_type="property" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:element default="Problem" name="Category" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo propertyGuid="676ad92f-16de-42df-8758-6b92dc4816a6" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element default="Unkown" name="Code" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo propertyGuid="74bf0ac9-fe44-4ef1-a27c-64afe0e334bb" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element default="Unknown" name="ComponentOfOrigin" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo propertyGuid="860e8876-8a0e-4fbd-aebe-84ee12bfb041" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element default="00000000-0000-0000-0000-000000000000" name="OriginalMessageTypeValue" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo propertyGuid="4d329f1d-4944-46e0-9ec9-4b87eb8d7a71" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element default="00000000-0000-0000-0000-000000000000" name="OriginalMessageID" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo propertyGuid="5bc4a75a-8fb3-4b54-becc-89e5415d216d" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:schema>
The issue is that only ONE dissembler will execute.
Notice the graphics in the Disassemble stage vs the Decode stage.
The Decode components will fire in sequence, but the Disassemble stage will probe which component matches the message, and the first one that matches will fire, and only that one.
Pipelines (Microsoft)
As an example of execution modes, the Disassemble stage of a receive pipeline is a First Match stage, thus each component in the stage is called to see if it recognizes the message and can process it. If the component responds in the affirmative, then no other components in that stage are queried to see if they can also handle the message. However, the Decode stage of a receive pipeline has an execution mode of All, meaning that each component in this stage is called to process the message in the order in which they were configured. The first decoder might be to decrypt the message, while the second might be to decompress the message from a zipped format.
So if you want to promote properties and also de-batch, you need to do in both your custom Disassembler.
e.g.
outMsg.Context.Promote(Name, Namespace, PropertyValue);
I have a multipart message with this schema (edited for brevity):
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://MyCompany/Schemas/Canonical/Property/1.0" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://MyCompany/Schemas/Canonical/Property/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Property">
<xs:annotation>
<xs:appinfo>
<b:properties>
<b:property distinguished="true" xpath="/*[local-name()='Property' and namespace-uri()='http://MyCompany/Schemas/Canonical/Property/1.0']/*[local-name()='UPRN' and namespace-uri()='']" />
</b:properties>
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="Addresses">
<xs:complexType />
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="UPRN" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Given that the message name in an Orchestration is MyMessage, how would I access the value of the distinguished field 'UPRN' in a BizTalk Expression Editor.
When I try dot notation all I get from IntilliSense is MyMessage.Property
It's supposed to be:
MessageName.PartName.RootNode.ElememtName[...].FieldName
I want to change an image in about 110 CR 2008 Reports.
I've seen answer about mass changing fields, but I need to change image.
Is their any script or method I could use ?
if you are saving the image in the database you can create schema xml file to reade from the image from DB and call this schema as subreport in the report itself.
the schema will be like this:
You have to make some modification on the id, target, element(table Name) and source as your requirements.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="rptAppSettings" targetNamespace="http://tempuri.org/AppSettings.xsd" xmlns:mstns="http://tempuri.org/AppSettings.xsd" xmlns="http://tempuri.org /AppSettings.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas- microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:annotation>
<xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
<DataSource DefaultConnectionIndex="0" FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout, AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema" xmlns="urn:schemas-microsoft- com:xml-msdatasource">
<Connections>
<Connection AppSettingsObjectName="Web.config" AppSettingsPropertyName="ConnectionString" IsAppSettingsProperty="true" Modifier="Assembly" Name="ConnectionString (Web.config)" ParameterPrefix="#" PropertyReference="AppConfig.System.Configuration.ConfigurationManager.0.ConnectionStrings.ConnectionString.ConnectionString" Provider="System.Data.SqlClient" />
</Connections>
<Tables />
<Sources />
</DataSource>
</xs:appinfo>
</xs:annotation>
<xs:element name="rptAppSettings" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:Generator_DataSetName="rptAppSettings" msprop:Generator_UserDSName="rptAppSettings">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="App_Settings" msprop:Generator_UserTableName="App_Settings" msprop:Generator_RowEvArgName="App_SettingsRowChangeEvent" msprop:Generator_TableVarName="tableApp_Settings" msprop:Generator_TablePropName="App_Settings" msprop:Generator_RowDeletingName="App_SettingsRowDeleting" msprop:Generator_RowChangingName="App_SettingsRowChanging" msprop:Generator_RowDeletedName="App_SettingsRowDeleted" msprop:Generator_TableClassName="App_SettingsDataTable" msprop:Generator_RowChangedName="App_SettingsRowChanged" msprop:Generator_RowEvHandlerName="App_SettingsRowChangeEventHandler" msprop:Generator_RowClassName="App_SettingsRow">
<xs:complexType>
<xs:sequence>
<xs:element name="LogoImage" msprop:Generator_ColumnVarNameInTable="columnLogoImage" msprop:Generator_ColumnPropNameInRow="LogoImage" msprop:Generator_ColumnPropNameInTable="LogoImageColumn" msprop:Generator_UserColumnName="LogoImage" type="xs:base64Binary" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
I've built an assembly with the BTAHL7V2X schemas (MSH_25_GLO_DEF, etc).
In another assembly, I need to create a schema, where one of the elements is of type MSH_25_GLO_DEF.
In my BTAHL7V2XCommon assembly I have:
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://microsoft.com/HealthCare/HL7/2X" targetNamespace="http://microsoft.com/HealthCare/HL7/2X" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<b:schemaInfo root_reference="MSH_25_GLO_DEF" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:element name="MSH_25_GLO_DEF">
...
In my other assembly, I have a schema that look like:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://mycompany.com/Custom/HL7/2X" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:ns0="http://microsoft.com/HealthCare/HL7/2X" targetNamespace="http://mycompany.com/Custom/HL7/2X" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import schemaLocation="BTAHL7Schemas.MSH_25_GLO_DEF" namespace="http://mycompany.com/Custom/HL7/2X"/>
<xs:include schemaLocation="ORU_R01_23_GLO_DEF.xsd" />
<xs:annotation>
<xs:appinfo>
<b:schemaInfo standards_version="HL7.DBVersion.1_5" document_type="HL7 2X Schema" version="2.0.0104.0.2.0" root_reference="ORU_R01_23_GLO_DEF" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" />
<b:references>
<b:reference targetNamespace="http://mycompany.com/Custom/HL7/2X/2.3/ORU/DataTypes" />
<b:reference targetNamespace="http://microsoft.com/HealthCare/HL7/2X" />
<b:reference targetNamespace="http://mycompany.com/Custom/HL7/2X/2.3/ORU/Segments" />
<b:reference targetNamespace="http://mycompany.com/Custom/HL7/2X/2.3/ORU/Tables" />
</b:references>
</xs:appinfo>
</xs:annotation>
<xs:element name="ORU_R01_23_ALL">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="MSH_25_GLO_DEF" type="ns0:MSH_25_GLO_DEF" />
<xs:element minOccurs="1" maxOccurs="1" ref="ORU_R01_23_GLO_DEF" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I've added a reference to the BTAHL7V2X assembly which contains the MSH header and I can see the MSH_25_GLO_DEF if I view the referenced assembly in the object browser, but I always get an error stating "http://microsoft.com/HealthCare/HL7/2X:MSH_25_GLO_DEF is not declared, when I view my schema.
I've also tried changing the imports reference to an include:
<xs:include schemaLocation="BTAHL7Schemas.MSH_25_GLO_DEF" />
but get a different error when vieweing the schema:
The targetNamespace 'http://microsoft.com/HealthCare/HL7/2X' of included/redefined schema should be the same as the targetNamespace 'http://mycompany.com/Custom/HL7/2X' of the including schema.
Is there a proper way to reference BizTalk schema in another assembly?
Check this out:
http://social.msdn.microsoft.com/Forums/en-US/biztalkgeneral/thread/d40d2c15-5c91-45c9-877d-2559802d1b1e
hope that helps
<xs:schema ... targetNamespace="http://mycompany.com/Custom/HL7/2X">
<xs:import schemaLocation="BTAHL7Schemas.MSH_25_GLO_DEF" namespace="http://microsoft.com/HealthCare/HL7/2X"/>
<b:schemaInfo ... root_reference="ORU_R01_23_ALL" ... />
I am using biztalk 2009 and need help with mapping. I have input like:
<root>
<shop>
<product>
<type>1</type>
<code>ab</code>
<desc></desc>
</product>
<product>
<type>2</type>
<code>cd</code>
<desc></desc>
</product>
</shop>
<address />
<names />
</root>
I want to map the collection of products to a target element as a string of xml that looks like this:
<products><product type="1" code="ab" /><product type="2" code="cd" /></products>
I have found a solution using custom xslt but I dont want to use it as we have found it to be very fickle. Is there any functoids that could do this for me with some custom scripting? I am also a c sharp dev thanks!
This is completely doable out of the box with a simple map.
Here is the soure XML file:
<root>
<shop>
<product>
<type>1</type>
<code>ab</code>
<desc></desc>
</product>
<product>
<type>2</type>
<code>cd</code>
<desc></desc>
</product>
</shop>
<address />
<names />
</root>
Here is the source schema:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="shop">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="unbounded" name="product">
<xs:complexType>
<xs:sequence>
<xs:element name="type" type="xs:string" />
<xs:element name="code" type="xs:string" />
<xs:element name="desc" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="address">
<xs:complexType />
</xs:element>
<xs:element name="names">
<xs:complexType />
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Here is the target schema:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="products">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="unbounded" name="product">
<xs:complexType mixed="true">
<xs:attribute name="type" type="xs:string" />
<xs:attribute name="code" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
And here is the map:
And here is the output:
<products>
<product type="1" code="ab" />
<product type="2" code="cd" />
</products>
Armed witht his result, you can follow one of two suggestions outlined by Mark Brimble in his blog.
How to copy the entire node to element of string type in a map
I am sorry to say this but when mapping gets too involved and there is no obvious way to do this in the mapper I just fall back on a .net helper method inside assign message which will build the output message.
The helper method can take a biztalk message as an argument of type XLANGMessage and return a type of XMLDocument which will be converted to your target message type, providing the xml inside renders the type correctly.
For example:
public static XmlDocument HelperMethod (XLANGMessage message)
{
var sourceType = (SourceType)message[0].RetrieveAs(typeof(SourceType));
var targetType = new TargetType();
// ... Do target type population and serialization to XmlDocument here
return targetAsXmlDoc;
}
It would be trivial to do this inside .net so just take it into .net and do it. Sorry to all the mapping gurus out there!