Using Custom Behaviors with the BizTalk WCF Adapters, Part 2
· How a WCF custom behavior intercepts an incoming WCF message before it gets to the WCF-Custom adapter. Custom processing in that behavior decides whether the message is rejected or passed on to BizTalk Server.
· How the functionality of a BizTalk send port and its associated maps and schemas can appear as a WCF service to a WCF client.
static void Main(string[] args)
{
ConcatServiceClient client = new ConcatServiceClient();
Root docObj = new Root();
docObj.InputParam1 = "stringequaltest";
docObj.InputParam2 = "stringequaltest";
Console.WriteLine("Calling into WCF service with values of: {0} and {1}", docObj.InputParam1, docObj.InputParam2);
Console.WriteLine("Hit any key to allow the WCF client to call the exposed WCF service:");
Console.ReadLine();
// Use the 'client' variable to call operations on the service.
client.ConcatParamsOperation(docObj);
// Always close the client.
client.Close();
}
XmlDictionaryReader x = operationContext.RequestContext.RequestMessage.GetReaderAtBodyContents();
string strClientInputParam1 = x.ReadElementString();
string strClientInputParam2 = x.ReadElementString();
return (strClientInputParam1 == strClientInputParam2);
return (this.strBindingProperty1String == this.strBindingProperty2String);
· The name displayed on the WCF-Custom adapter’s Behavior tab is determined in this line of code. “BindingProperty1String” is what will be shown in the dialog box. A similar section of code exists for BindingProperty2String.
[ConfigurationProperty("BindingProperty1String", DefaultValue = "", IsRequired = true)]
· BizTalkArtifacts is a pure BizTalk Server project containing maps and orchestrations used by the send port to concatenate two strings into one string.
· WCFClient is a simple WCF client application that uses the exposed WCF service’s proxy to access its functionality. The WCF service itself exists solely in the functionality of the BizTalk send port as a concatenation service. This is exposed as a metadata-only endpoint through IIS.
· The WCFCustomBehavior project is a WCF custom behavior that is configured into the total application architecture using the WCF-Custom adapter. The behavior receives the WCF message before the adapter sees it, and controls access by its custom method and its Boolean return value from the CheckAccess operation. If True is returned, security access is granted. The message is sent to the WCF-Custom adapter, which then submits it to BizTalk Server for processing. If False is returned, access for the incoming message is denied, and the message never gets to the adapter. An exception is thrown and BizTalk Server has no record of the incoming message.
The WCF adapters are a gateway into the robust and flexible world of WCF. They allow a BizTalk application to integrate specialized WCF processing into a send port or receive location using a WCF adapter. Using a custom behavior is one way to accomplish this.
Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.
Maheshkumar S Tiwari edited Revision 1. Comment: Added See Also and Tag