R – Consuming a WCF service in BizTalk 2006 R2

biztalkbiztalk2006r2wcf

I'm trying to figure out how to consume a WCF service in BizTalk 2006 R2 (sending a request and receiving a response).

I've gotten as far as going through the "Add Generated Items" wizard. Now I am trying to find out how to use the items it generated in an orchestration.

How should the request be made?

Best Answer

Below is a description of how to do this - I'm going to presume at least basic knowledge of things like BizTalk mapping, please let me know if you need any more detail and I'll update.

After generating the items in BizTalk you should have (at the least):

  • An orchestration file with Messages and Port Types created
  • A schema that describes the messages you send and receive from and to your WCF service
  • A .Binding.xml file that describes the service contract exposed by the WCF service and allows easy configuration in BizTalk

    1. Open the orchestration file. This should be empty.
  • Drag a Port from the toolbox onto the orchestration designer surface.

  • Name the port appropriately.
  • Select "Use an existing Port Type" - one of the existing port types will be your WCF service (created by the Add Generated Items wizard)
  • Specify that you will be sending and receiving messages
  • Specify Bind Later

This port should have Request and Response operation messages and they should have been automatically configured to use the messages for your WCF service. If your service exposes multiple operations, you will see that reflected here.

  1. Using standard BizTalk mapping methods, map the data you want to send to the WCF service into the request message for the WCf port. (you may want the change the message names in the orchestration designer to be something better than the default message_1, message_2...)

  2. Drag Receive and Send shapes onto the orchestration designer and connect them to the right Port messages.

  3. Wire up the rest of the BizTalk orchestration to take data from appropriate source systems (this is just basic BizTalk, not WCF)

  4. Deploy the BizTalk application.

    The application is now ready to go, you can deploy it to BizTalk.

  5. Configure the BizTalk application

    • Open the BizTalk Server 2006 Administration Console and find the application containing the orchestration you just deployed.
    • The orchestraion will be unenlisted, you need to bind all of its ports
      For most of the ports this is just like any other BizTalk application - only the ports that deal with the WCF service differ.

For the WCF ports you have (at least to begin with) two main options:

  1. Import the bindings file made by the BizTalk Generate Items wizard (right click on the applicaiton and import - navigate to the .xml binding file) - Perhaps advisable until you have an idea of how Biztalk represents all the WCF binding options.
  2. Configure your own WCF send port.

    • For this the port needs to be Solicit-Response to match the WCF service.
    • Choose one of the WCF Send Port types to match the binding type of your WCF service.
      To begin with (for a basic Webservice) this will often be WCF-BasicHttp.
      Once you have the basics working you might want to return here and experiment with the options available in the Custom binding - there is a LOT there!
    • Configure the send port.

With your WCF port now created you can bind the orchestration ports to it.

Once all this is done, you should be able to start the BizTalk application and things should work.

One thing that may help - errors will be written to the event log, they may not be helpful, but you should also be able to see any soap fault messages returned from the service in the suspended message view.

Good luck!

Related Topic