Reputation: 467
I'm new to BizTalk, can anyone help me to work out the following scenario in BizTalk 2010?
In BizTalk orchestration, a message (xml) needs to be sent to a WCF service as a param; the service will return a message as a result. As shown in the screenshot below.
My problem and question is how to construct the 'SimRequest' message, which is an auto generated message part from WCF (when I use 'Add generated items' for consuming WCF), the another message part is 'SimResponse'.
This is my expression for Message Assignment Shape:
varIncomingMessage = msgPI;
varStringParam = varIncomingMessage.OuterXml;
varOutMessage.LoadXml("I dont know what should be put here. Hard code the data schema of the SimRequest Message?");
msgSimRequest.parameters = varOutMessage;
msgSimRequest.parameters.msg = varStringParam;
Please let me know if my question is not clear or you need more info from me. Thanks in advance.
Zalan
Upvotes: 1
Views: 5242
Reputation: 31780
In BizTalk you construct an instance of a message either:
XLANGMessage
type found in Microsoft.XLANGs.BaseTypes
library. You will first need to generate a .net representation of your message schema (using xsd.exe or svcutil.exe) so that you can deserialize the message using XLANGPart.RetrieveAs(typeOf(xxx))
. To pass your messages out then you can make your .net method return type XmlDocument and as long as the XML maps to a message schema, BizTalk will take care of the conversion for you.Hope this helps.
can you tell me more details about how to construct msg in an assignment
It's similar to what you have except you use a XmlDocument type and BizTalk will do an implicit cast for you.
Let's say you have a schema called SimRequest.xsd and you have created an orchestration message of this type called MySimRequestMessage.
You need to define a variable of type System.Xml.XmlDocument
to hold the XML, which we will call xmlDocSimRequest.
Then in your assignment shape:
xmlDocSimRequest = new System.Xml.XmlDocument();
xmlDocSimRequest.LoadXml("<SimRequest xmlns='http://blahblah'>...some data here</SimRequest>");
// Cast to your message - it's as simple as
MySimRequestMessage = xmlDocSimRequest;
To generate the XML you can right click on your schema file in visual studio and select "Generate Instance", which will generate you a basic XML file which can act as a starting point. Note: To use the above method you will need to replace all double quotes with single quotes in the XML you use.
Upvotes: 8