3

I have a schema I'm trying to map to. On the source side, I have a structure with a lot of fields. On the destination side, I have the following schema:

<xsd:element name="ServiceResponse">
  <xsd:sequence>
     <xsd:element ref="s:ServiceResponseHeader" />
     <xsd:element ref="s:ServiceResponseBody" />
  </xsd:sequence>
</xsd:element>
<xsd:element name="ServiceResponseHeader" type="s:HeaderType" />
<xsd:element name="ServiceResponseBody" type="xsd:anyType" />
<xsd:complexType name="HeaderType">
  <xsd:sequence>
     <xsd:element name="Timestamp" minOccurs="0" />
     .
     .
  </xsd:sequence>
</xsd:complexType>

Which yields a sample document like:

<ServiceResponse>
  <ServiceResponseHeader>
    .
    .
  </ServiceResponseHeader>
  <ServiceResponseBody>
     <!-- XML message as anytype -->
  </ServiceResponseBody>
</ServiceResponse>

I'm creating a map to transfer fields from my schema to this schema. The map transfers the fields to the ServiceResponseHeader. however, for the body, I need to pass in an XML document. The body accepts anytype because a variety of documents can be passed in.

However, from a BizTalk map, is it possible to construct an XML document and pass this in through the body field when it has no structure?

Or is there another way through the BizTalk orchestration?

Dijkgraaf
  • 9,324
  • 15
  • 34
  • 48
Brian Mains
  • 49,697
  • 35
  • 139
  • 249

3 Answers3

0

Most likely, all you need to do is use the Mass Copy Functoid linked from the Root Element of the Source to the in the output.

Johns-305
  • 10,704
  • 10
  • 21
0

You can promote the element to a distinguished field and assign it in an orchestration message assignment shape after the map. The data you assign can be a message or variable in the orchestration including the output of another map.

James Rosser
  • 404
  • 2
  • 6
  • Yes, that makes a lot of sense. However, it's not letting me make the body element a distinguished field though, either from the ServiceResponse object, or the ServiceResponseBody element.... – Brian Mains Jan 29 '15 at 15:34
  • It must be set to have MaxOccurs = 1, if this is not possible you will have to do something else like generate c# class to serialize and edit the message. – James Rosser Jan 29 '15 at 16:53
  • 1
    It won't let me do it. Primarily, because it doesn't allow the promotion of complex types. Simple types can be made distinguished fields (string, etc.) but not a complex type accepting an element. – Brian Mains Jan 30 '15 at 14:57
  • Quite right I realise when I've done this in the past the field was a string. I think you need to use custom c# or xslt to assign the data independently of Biztalk – James Rosser Jan 30 '15 at 15:37
0

If you really must do this in the map, use a Scripting Functoid with an XSLT Call Template. You can pass in whatever parameters you want to it and construct the document for the any node that way. However, that's going to become unwieldy pretty quickly.

It's true that you can't promote or distinguish it, but you should still be able to do an xpath assignment like so (using a Message Assignment shape in an Orchestration):

xpath(msg, "/ServiceResponse/ServiceResponseBody") = varXmlDoc.OuterXml;

Or if you're not using an XmlDocument

xpath(msg, "/ServiceResponse/ServiceResponseBody") = xpath(msg2, "//*")
Dan Field
  • 18,334
  • 2
  • 43
  • 63