message assignment

I have a scope block as part of the orchestration which gets called from another orchestration.

That scope block has got an expression shape which calls the c# method. I would need to capture the return value from the method and then send that to a local folder.

so

1) I have created a local variable and captured the return value from the method

2) Then I have create a schema, and I have assigned the return value from the method to the xpath of the element of the schema

3) with in the scope, I have added a message assignment shape with message as the schema

4) then added a send port.

All the message assigment and port is in the scope. but it doesnto seem to be working.

does scope cannot have message assignment and send port?> 


  • Edited by ragavalli Wednesday, May 21, 2014 7:46 PM
May 21st, 2014 8:51pm


2) Then I have create a schema, and I have assigned the return value from the method to the xpath of the element of the schema


in which shape did you assign this value to schema message variable?

Also it needs to be initialized in message assignment shapte.

so you have to do all assignments in message assignment shape only.

you better create a xmldocument variable mesage, initialize something like below

xmldocument temp=new xmldocument()

temp.loadXML(your actual schema xml message here with the return value inside it)


assign this temp variable to your schema message variable.

anyway if possible let us know the code you already wrote in your message assignment

Free Windows Admin Tool Kit Click here and download it now
May 22nd, 2014 5:23am

I see an issue with point number 2. Before you use XPATH to assign values during message construction, the element should exist or it would fail. Example below:

So take a simple message as described below:

<root xmlns='http://tempuri.org'>
    <element_a></element_a>
    <variable_b></variable_b>
</root>

So let us assume that variable_b has to contain the value that you wish to populate in the message construct shape. Then your construct shape should have an assignment shape with the following bits. You are likely to have missed initializing the message and because you capture General Exception as part of your scope handling, you're not seeing the errors.

//
// a xml variable to hold the message
xmlMessage = new System.Xml.XmlDocument();
xmlMessage.LoadXml("<root xmlns='http://tempuri.org'><element_a></element_a><variable_b></variable_b></root>");
//
// now assign to the Message
MessageX = xmlMessage;
//
// Now we can use the XPATH to assign the value
xpath(MessageX, "//*[local-name()='variable_b']") = orch_variable_b;
May 22nd, 2014 8:39am

Dear Ragavalli,

Yes the scope can have a message assignment and send port.

1)About using xpath...if this schema node of yours is not repeating, you can use the distinguished property. You then need not provide the xpath of the schema node.

2) In case of message creation you have to construct the mesage first and then initialize it.(just like any variable in normal c# code). The message can be intialized in two ways

a) using a transform shape (where in you can map the the necessary nodes in the destination schema.)

b) using system.xml.xmldocument variable in the message assignment shape.

it can be done as

//Construct a xmldocument variable

xDoc= new Sysytem.Xml.XmlDocument();

myMessage=xDoc.LoadXml("Give your xml here"); // you can use the generated instance of your schema here.

// Now set the desired schema tag with the value you got from the c# method(either use the distinguished field or xpath).

Now about the possible errors

1)Now at runtime, The schema of yours might not contain the tag to which you have used the xpath expression so it will raise an exception.

2)Another possiblity is that message has not been created and you are trying to send it before intializing.This will throw an error at the build time.

If you want to go deeper into the details of the exception, I suggest you use the Exception handling block with the scope and you can trap the stack strace and inner exceptions.

Regards,

Mandar Dharmadhikari

Free Windows Admin Tool Kit Click here and download it now
May 22nd, 2014 11:35am

The simplest way to accomplish this:

  1. Capture the return value.
  2. Build a valid Xml string with the return value in place: MyXmlString = "<MyXml>" + MyReturnValue + "</MyXml>";
  3. Create an XmlDocument: MyXmlDocument.LoadXml(MyXmlString);
  4. Assign the XmlDocument to a BizTalk Message in a Message Assignment Shape: MyMessage = MyXmlDocument;
  5. Send MyMessage.

However, I'll ask why you're doing this.  Is it an app requirement or for debugging?  If debug, there are better ways.


May 22nd, 2014 8:08pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics