Say you have a web-service with a simple return type (such as an integer) and you want to consume that in an orchestration. For example your web-service might look like this:
<WebMethod> function callme(mystring as string) as integer.
When you add a web-reference to this web-service BizTalk Server will create a multi-part message. Now sometime later in the orchestraiton you want to assign the return value of the callme function to a field (a promoted property) in a schema-typed. Ever been there? The basic issue is getting data from simple-typed to schema-typed messages. You probably thought you could use a Message Assignment shape to construct the schema-typed message like this:
SchemaMessageInstance.PromotedProperty = MultiPartMessageFromWebServce.ReturnValue
That doesn’t work because you are trying to assign a property to a message that isn’t constructed yet. Instead you need to create a temporary XMLDocument typed variable, load it up with the data and then assign your target message to the temporary variable value. That second step works because the schema message inherits off System.XML.XMLDocument.
1. Create a variable of System.XML.XMLDocument in the OD
2. Inside the construct message shape instantiate the variable.
3. Examine the XML schema for the target message and use LoadXML to create the schema and insert the simple type from the web service (converted to a string if necessary) like this:
XDoc.LoadXml(“<ns0:OutboundInt xmlns:ns0=\”http://AdderWSTest.AddinsResponce\”><adderResult>” + System.Convert.ToString(MultiPartMessageFromWebServce.ReturnValue) + “</adderResult></ns0:OutboundInt>”);
4. Assign the schematype message the value of the XDoc message.
OWSResMessage = XDoc;
Now your simple-type has been copied into your schema-type and you are good to go.