Showing posts with label Orchestration. Show all posts
Showing posts with label Orchestration. Show all posts

Wednesday, May 14, 2008

Distinguished fields of type xs:dateTime not Working on Orchestrations

Writing a spyke for a simple program, I came out with this odd behavior when I try to compile my BizTalk project.

image

I have created a simple schema, and in one of the fields I have field of type xs:dateTime. Well, when I have tried to use this field on an expression shape, I get this build compiler error:

'System.Xml.XmlDocument' does not contain a definition for 'XXXX'

where XXXX is the field name of the element that I have declared as a xs:dateTime type. I then went and set it up as a distinguished field. Here is a sample generated xml from my test schema:

  1. <ns0:Customer xmlns:ns0="http://DistingProperty.Test.Customer.v1">
    <FName>FName_0</FName>
    <DOB_datetime>1999-05-31T13:20:00.000-05:00</DOB_datetime>
    <DOB_date>1999-05-31</DOB_date>
    </ns0:Customer>

and this is the schema that I have used


image

When I am trying to use the distinguished field inside an expression shape, noticed that I get the Visual Studio IntelliSense:

image

When you try to read this value, it will always complain about the XmlDocument not being able to find the definition for the field that is defined as DateTime.

To get around this, you should use the System.Convert.ToString() instead of the .ToString() function;


1 Trace.WriteLine(" bad:[" + msgIN.DOB_datetime.ToString() + "]");

2 Trace.WriteLine("good:[" + System.Convert.ToString(msgIN.DOB_datetime) + "]");



Another lengthy way to get around this issue is to assign the distinguish field to an xmlNode and then use the xml Namespace Manager to get to the node value instead.

The code on my expression shape looks like this:


1 System.Diagnostics.Trace.WriteLine("bts- In here");

2

3 //assign values to person

4 xDoc = msgIN;

5

6 xmlnsMgr = new System.Xml.XmlNamespaceManager(xDoc.NameTable);

7 xmlnsMgr.AddNamespace("ns0", "http://DistingProperty.Test.Customer.v1");

8

9 xNode = xDoc.SelectSingleNode("/ns0:Customer/DOB_datetime", xmlnsMgr);

10 System.Diagnostics.Trace.WriteLine("bts-[" + xNode.OuterXml + "]");

11

12 xNode = xDoc.SelectSingleNode("/ns0:Customer/DOB_date", xmlnsMgr);

13 System.Diagnostics.Trace.WriteLine("bts-[" + xNode.OuterXml + "]");

14

15 //this works as expected

16 System.Diagnostics.Trace.WriteLine("bts- " + msgIN.FName);

17


Which ever way you choose, this looks like a limitation on the way the XLANG/s in the Expression shape interprets the command code.

Tuesday, August 07, 2007

HAT Debugging on demmand

In my quest to optimize the resources being used in my laptop, I have been very picky about what services are needed to get my task done. I have a script to turn on/off all of the services that I need. Today I try debugging an orchestration, and I was not getting any information at all on the Health and Activity Tracking (HAT). As it turn out, I had not started this service: BizTalk Server Application Service.

All of my Orchestrations were working fine without this service. Hummm... I know now if I need to run the HAT, then I can turn this feature on/off. And the best thing, is that it when you start up this service, it will pickup all of the instances that have been ran. NICE... ;)

FYI, the service name is BTSSvc$BizTalkServerApplication. I have set its startup type to be manual, and then I have this batch script to turn it on/off:

net start BTSSvc$BizTalkServerApplication
net stop BTSSvc$BizTalkServerApplication

BTW, don't forget to add your login account to the Biztalk Server Administrators group, or you won't be able to attach to the Orchestration in Debugging mode.


Friday, February 09, 2007

Exposing Orchestration as Web Service

Created a very simple orchestration and then deploy it as a web service. Inside the orchestration, on the message assignment calculate the age of the customer based on a distinguished property (BirthYear). Then place this calculated field back into the message for the Age element.

Here is the schema being used:

This is the simple orchestration to test this




On the construct shape, this is the code inside the assignment shape:
outMsg = InMsg;
iAge = System.DateTime.Now.Year - InMsg.BirthYear ;
outMsg.Age = iAge;


Configuration basic:

The port is setup as a One-Way port with Public - no limit for the access restrictions.




On the IIS manager, removed all of the restrictions



when publishing the orchestration, select the following settings:




the Namespace in here is the same namespace than the schema used inside the orchestration. However this is not a requirement for the Orchestration to work.



Once this orchestration is published. Trying to call it from a GUI client (web studio, Windows forms, etc...) you might get several distinct errors on the Application Event Log.

a. Isolated Host
When trying to call it, if you get this error in the Event Log:

The Messaging Engine failed to register the adapter for "SOAP" for the receive location "/SimpleWeb_Proxy/SimpleWeb_Main_IncomingPort.asmx". Please verify that the receive location exists, and that the isolated adapter runs under an account that has access to the BizTalk databases.

This error, tells you that you have not configure the isolated host correctly. The account used, is not part of the Isolated Host User Group.

b. Routing Failure
Event Type: Error
Event Source: BizTalk Server 2006
Event Category: BizTalk Server 2006
Event ID: 5778
Date: 2/11/2007
Time: 1:04:37 PM
User: N/A
Computer: QSI_TEST
Description:
The Messaging engine failed to process a message submitted by adapter:SOAP Source URL:/SimpleWeb_Proxy/SimpleWeb_Main_IncomingPort.asmx. Details:The published message could not be routed because no subscribers were found. This error occurs if the subscribing orchestration or send port has not been enlisted, or if some of the message properties necessary for subscription evaluation have not been promoted. Please use the Biztalk Administration console to troubleshoot this failure.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.


The message will be suspended. Looking at the Hub Group you can see why this message is being suspended: 0xC0C01B4e(Routing Failure Report).

Right click on the Routing Failure Entry, and then select Troubleshoot Routing Failure, then select Find failed service instance.



If you look at the service details of the message, you can see that the Message Type is empty.



When the message type is empty or not defined, it might be because the pipeline define in the receive location was not set to be an XML pipeline. Change the pipeline and it should work.

Thursday, January 25, 2007

How to: Pass message to an external assembly



I am trying to write a re-sequencer. I want to be able to pass the message I receive and have an external assembly sort it for me.

The code for the External assembly:

using System;
using System.Diagnostics;
using System.IO;
using System.Xml;
using Microsoft.XLANGs.BaseTypes;

namespace HelperDecompose
{
[Serializable]
public class Class1
{
public void PrintMessage(XmlDocument inputXML)
{
Trace.WriteLine("bts- --------------------");
Trace.WriteLine("bts- xml:[" + inputXML.OuterXml + "]");
}

public void PrintBTSMessage(XLANGMessage btsMessage)
{
StreamReader reader = new
StreamReader((Stream)btsMessage[0].RetrieveAs(typeof(Stream)));
string sXML = reader.ReadToEnd();
Trace.WriteLine("bts- in the new [" + sXML + "]");
}
}
}



On my expression shape this is the code I have to send the message to the assembly, the xmlDocVariable is of type System.Xml.XmlDocument.


xmlDocVariable = msgOrder;

System.Diagnostics.Trace.WriteLine("bts- before calling Helper assembly");
System.Diagnostics.Trace.WriteLine("bts- [" + xmlDocVariable.OuterXml + "]");

//init the object
oHelper = new HelperDecompose.Class1();

//send the xmlDocument
oHelper.PrintMessage(xmlDocVariable);

//send the actual message
oHelper.PrintBTSMessage(msgOrder);

System.Diagnostics.Trace.WriteLine("bts- after calling Helper assembly");

Here is my sample code to implement this:

file:///C:/vsProjects/Spykes/Biztalk/ConvertMsgToXMLDoc.zip