다음을 통해 공유


Exposing BizTalk Web Services That Accept Generic Content

So what if I want to open up a BizTalk web services channel that accepts *any* XML message and then lets BizTalk Server figure out what do with that data?

In considering ESB functionality, you often have the concept of generic ways to get messages "on the bus." Given that BizTalk can be a perfectly good bus, with a robust publish-subscribe engine, it's logical that BizTalk could support such a broad requirement. So what I need is a one-way "BizTalk web service" that accepts untyped content. There are a few viable options for doing this, but let's go with the simplest. I've created a really basic orchestration with a single receive shape, and it accepts a message of type System.Xml.XmlDocument.

Now I have no intentions of using this orchestration, but, I can use it to generate the service I want. I walked through the Web Services Publishing Wizard and "exposed" this orchestration as a service. What that gave me, was a SOAP service that looks like this ...

Given that nothing in the web service says I have to actually *use* the orchestration, I can use this process to create general on-ramp services. Now, I created a couple of send ports that have subscriptions on the BTS.MessageType property. I could easily do the same thing with Direct Bound orchestrations. These send ports (or orchestrations) are subscribers on message types, and aren't concerned with the source of the message.

Next I set up a Receive Port and Receive Location to accept the web service input. The key step is to use the XML Receive pipeline. This forces BizTalk to inspect the message, and promote the MessageType value.

Finally, I built a simple application that uses this on-ramp service and publishes messages to the bus. You can see below that my web service method PostGenericDoc accepts a single parameter of type XmlNode. In my case, I send one of two different XML documents.

This is a fairly powerful concept. Naturally I lose the ability to have a service contract, and run the risk of accepting content that has no subscribers, but, I also gain the ability to have a single service that be used by countless applications to simply and easily push messages onto the BizTalk bus.

Technorati Tags: BizTalk, Web Services

Comments