Thoughts on Integrating Systems & IoT

BizTalk and WCF, Consuming a WCF Service, Part 2 – The BizTalk WCF Service Consuming Wizard and a Look at the Artefacts Created

This post builds on part 1 of this series looking at BizTalk and WCF.

The previous post gave an overview of the RandomPresent WCF service, discussing design considerations, hosting and testing using SOAPUI.

In this post, we will examine how to consume the web service using the BizTalk WCF Service Consuming Wizard.  The next post will delve into the detail of actually building our BizTalk solution, using (some) of the artefacts generated by the wizard.

The Scenario

Our mythical company is feeling generous and management have decided that each customer will receive a gift with their order.  The gift will be assigned by calling our newly created web service and then adding an extra order line item for the present.

The BizTalk WCF Service Consuming Wizard

To consume the RandomPresent web service, the BizTalk WCF Service Consuming Wizard could be used.  This will generate all the artefacts we need to invoke the service, into our BizTalk solution.  However, some of the artefacts generated we will discard in favour of our own (better) implementation (to be discussed in part 3).

Here are the steps below:

  1. Right click on your solution (typically an external schemas project) and select Add –> Add Generated Items
  2. Select Consume WCF Service in the Add Generated Items dialogue box.  This will fire up the BizTalk WCF Service Consuming Wizard welcome page – click on the Next button
  3. On the next screen of the wizard we have two choices:
    Image

    Choose MEX endpoint

    • Metadata Exchange (MEX) endpoint – this option enables a service description to be downloaded (WSDL file) by pointing the wizard directly to the running RandomPresent web service.  Note from part 1 of this post, that we exposed a MEX endpoint by configuring the services web.config file to allow metadata to be downloaded via a HTTP GET
    • Metadata Files (WSDL and XSD) – I always think of this as a second best option, since instead of downloading service data directly from source, this option will allow artefacts to consume the service to be created from a WSDL or XSD on the file system.  There is a risk that the WSDL and/or XSD that has been obtained is out of date, so I try and avoid using this function if possible (it’s a last resort :-))
  4. Ensure that the Metadata Exchange (MEX) endpoint option is selected and click Next – this will take you to a screen where the service WSDL can be obtained and loaded into the wizard:
    Load WSDL for service endpoint

    Load WSDL for service endpoint – enter WSDL URL and click “Get” (for HTTP GET)

    • (Note that it is common practice for a service endpoint to expose it’s service definition using the convention servicename?wsdl)
  5. Click Next and then Import.  The wizard will then process the WSDL and generate artefacts into our BizTalk solution.  Click Finish.

The Ajax.BT.Fulfilment BizTalk Solution

So the wizard has consumed our WSDL and generated various BizTalk solution artefacts into our BizTalk purchase order fulfilment solution.  Lets take a quick look at what has been created:

BizTalk solution artefacts created by the BizTalk WCF Service Consuming Wizard

BizTalk solution artefacts created by the BizTalk WCF Service Consuming Wizard

  1. 2 x bindings files for importing into our BizTalk application:  one of these files can be imported into our eventual BizTalk application to create a send port to communicate with the RandomPresent service:
    • RandomPresentService.BindingInfo.xml – from the WSDL, the wizard has detected that the WCF service implements wsHttpBinding and therefore this file will create a send port using the WCF-WSHttp adapter
    • RandomPresentService_Custom.BindingInfo.xml – this is another option for creating a send port in our BizTalk application.  This will create a send port which will use the WCF-Custom adapter.  Utilising this adapter offers greater WCF extensibility compared to the WCF-WSHttp adapter
    • An interesting conundrum is: what bindings should I use in my solution, that utilising WCF-WSHttp or WCF-Custom?  I would contend that WCF-Custom is the better option over WCF-WSHttp, to support future/evolving requirements
  2. RandomPresentService.odx – this is a “starter” orchestration to call the service and contains just the types required.  I always move this orchestration into my specific orchestrations project (or just create an orchestration from scratch)
  3. RandomPresentService_schemas_ajax_randompresentservice.xsd – this schema defines the WCF message types required to construct a request to the service and what we can expect the response to look like
  4. RandomPresentService_schemas_microsoft_com_2003_10_Serialization.xsd – this contains type details.  I suppose if you wish to serialize to a class representation, this XSD would be useful but otherwise I haven’t found a use for this

That’s it for now…  In part 3 of this post I will walk you through my BizTalk solution utilising the service.  This will build on artefacts created by the BizTalk WCF Service Consuming Wizard, which was the main topic of this post.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s