AspAlliance.com LogoASPAlliance: Articles, reviews, and samples for .NET Developers
URL:
http://aspalliance.com/articleViewer.aspx?aId=1280&pId=-1
How to Use BizTalk 2006 with Windows SharePoint Services 3.0
page
by Arnulfo Wing
Feedback
Average Rating: 
Views (Total / Last 10 Days): 39697/ 60

Introduction

Microsoft provides adapters that allow you communicate to almost any data repository available.  Windows SharePoint Services is a free add-on to Windows Server. This new version has a lot more extensibility than the previous version. Microsoft has put a lot of effort into providing more functionality back into the hand of the developers. For instance, Windows SharePoint Services (WSS) 3.0 has 30+ namespaces that you can reference on your code, versus WSS 2.0 which only had less than 15 namespaces. SharePoint and BizTalk offer a tremendous combination of flexibility for your enterprise.

NOTE: In this article we are assuming that the environment is already setup according to the single server installation instructions guidelines from Microsoft. Please follow the Installation and Upgrade Guides for BizTalk 2006. [See References section at the end of this article.]

Scenario

For this example we will have a SharePoint library that contains book reviews from several contributors outside the publishing company.  We want all of the reviewers to be able to submit their notes to a single repository where we can index that information. We also would like to catalog the information in way that we can apply security at a granular level.

The book reviews are categorized into folders depending of the type of information stored.  We will initially have 3 types of categories: Medical, Technology, and Fiction.  As we add new categories, we can route those documents to the appropriate folder.  This will help our index server keep track of the documents more easily. 

We will use the Category field name in the xml document to route a document to the appropriate library. Then we will use the ISBN field to give it a name inside the library.

These are the steps that we are going to perform:

·         Setup a SharePoint Library.

·         Create an XML schema that we can use in InfoPath and also in BizTalk.

·         Setup an InfoPath template form to submit those documents.

·         Create a BizTalk 2006 Orchestration to route the documents.

·         Publish the Orchestration as a web service so that it can be consumed from any source.

SharePoint Library Setup

These set of steps will guide you on setting up a test SharePoint site that can be used for this demo.

a) Create a new Form Library: Open the Central Administration site, on the right hand side click on Site Actions, and select Create.

Figure 1

b) Under the Library column, select Form Library.

Figure 2

c) For Form Name, type BookReview. Keep all of the defaults.  Click on Create.

d) After creating the form library, you will be at the BookReview page. Let us add some folders to keep all of the information categorized.  First click on New, then select New Folder.

Figure 3

Give it the name Medical. Click OK. Repeat this same process to create a folder for Fiction and another for Technology.

NOTE: If you make a mistake on naming the folders, you can always click and modified by clicking anywhere in between the name and the next column. Then click Edit Properties and you should be OK.

Figure 4

Your final library should look something similar to this:

Figure 5

XML Schema Definition: In here we will define what information we are getting from the reviewers, as well as more detail information about the book.

Figure 6

 

Figure 1 BizTalk XSD Viewer

 

 

   

Figure 2 XML Spy Grid view

The Book node will contain the Category and the ISBN fields that we will use to route this document to the appropriate folder in SharePoint.

InfoPath Creation

This is the GUI interface to demonstrate the capabilities of submitting to SharePoint. Go ahead and create a new InfoPath template and specify the schema created earlier, to be the base for this InfoPath form. Drag the fields over and lay them on the form anyway you want.

Publish the template back to SharePoint library created in the first step.  Open InfoPath and design a form. Now, save it and publish it.

Figure 7

For our example, the SharePoint site is called BookReview.

Figure 8

On the next screen, select Document Library, and then click Next. Select to update the form template and select the Document library.

Figure 9

Add a couple of columns so that you can create different views later based on the data stored.

Figure 10

Finally, hit the Publish button and close the Publishing wizard.

Orchestration Creation and Setup

Since we are determining at run time the location of the document in SharePoint, we will use a dynamic port in the Orchestration. This will be determined based on the content of the message.  This type of routing is referred to as Content Based Routing in BizTalk 2006.

Add a new BizTalk project. You will need to add some shapes to the orchestration; below is a sample snapshot of all of the shapes being used for this demo.

Notice that on the orchestration, we are only routing on the Category of the document being submitted.  However, in a real world application, there might be more than one field to be used to determine where the final destination might be. 

This is what the finished orchestration looks like:

Figure 11

 

Here is a snapshot of the Orchestration tab:

Figure 12

Explanation:

Inside the Construct message we will have the following code.

Listing 1

    1 //Messages are immutable
    2 outMsg = InMsg;
    3 
    4 //if the form is found on the library, then overwrite it with this new one.
    5 outMsg(WSS.ConfigOverwrite) = "yes";
    6 
    7 //turn this off, if you are to insert the InfoPath PI's to the form.
    8 outMsg(WSS.ConfigOfficeIntegration) = "no";
    9 
   10 //set the filename in here
   11 outMsg(WSS.Filename) = InMsg.Book.ISBN + ".xml";
   12 
   13 //set the base library in here:
   14 sWSS_SiteLocation = @"wss://evo/BookReview/";

For the PI that you are dynamically creating, add the following.

Listing 2

//adjust the file attachment PI
outMsg(XMLNORM.ProcessingInstructionOption) = 1; 
outMsg(XMLNORM.ProcessingInstruction) =
 "<?mso-infoPathSolution  PIVersion=\"1.0.0.0\"
 href=\"http://evo/BookReview/Forms/template.xsn\"?><?mso-application 
 progid=\"InfoPath.Document\"?><?mso-infoPath-file-attachment-present?>"; 

Inside the medical of the Expression shape, we execute this code:

Listing 3

//add the location of the folder in here.
sWSSTargetPathLocation = sWSS_SiteLocation + "Medical";

Then on the last expression shape, labeled Dyn WSS Address, we dynamically set the address where this document is going to be sent. 

Listing 4

//set the destination of the dynamic form based on the criteria above.
WSS_BookReview(Microsoft.XLANGs.BaseTypes.Address) = sWSSTargetPathLocation;
Excluding a Web site from SharePoint manager

Excluding the bookServices web site from SharePoint manager was a mandatory step if you were using WSS 2.0. The default in WSS 3.0 is to exclude all sites by default. See the following snapshots to see this.

Figure 13

On the top tab, select application settings.

Figure 14

Now under the SharePoint Web Application Management group, select the Define managed paths option.

Figure 15

As you can see, there is no option to EXCLUDE the web site.

Figure 16

Deploying BizTalk Orchestration as a Web Service

From the Microsoft BizTalk Server 2006 group, select the BizTalk Web Services Publishing Wizard.  Then select the option to Publish BizTalk Orchestrations.

On the next screen you will be prompted for your project assembly.

Figure 17

Click Next to continue. Keep the defaults on the next screen and select Next. Once you get to the Web Service Properties screen, you will be prompted for the namespace to be used in your web service.

Figure 18

Type: http://BookReview.Demo.Sample/ at this text prompt. Do not forget to put the last "/" at the end. This namespace is NOT the one being used when your document is being submitted to BizTalk; instead, this namespace is mostly used on the WSDL definition.

Now, click Next and you will be at the Web Service Project screen. In here you will specify the name that you want to give to your web service. Select the name of the site that we excluded earlier, bookServices. This is what this screen should look like:

Figure 19

After this screen you will get the Create button, click on it and you will be done with this step. To test that the web service is up and running, you can do the small test of see if IIS will render this site.

In order to tie the WSS and BizTalk, you will need to bind the logical port of the orchestration with the physical ports. This is accomplished by opening the BizTalk 2006 Administration Console. Then open the AW.BookReview application. 

In there, open the Receive Locations and you will see that there is a new location of type SOAP. This location was generated by the Web Service Publishing Wizard we ran before. Now bind your Orchestration ports to the appropriate location. You will only be able to bind Inbound ports to receive ports and outbound ports to send ports.

Figure 20

Notice that we have bound the orchestration logical port to the Web Service receive location. Then bind the outbound logical port of the Orchestration to the Dynamic Soap that will be connected to SharePoint.

Start the Application and it is ready for BizTalk to start processing web services request.

References
Summary

We have shown on this article several advanced techniques to get BizTalk and SharePoint Services connected. As you can see, most of the bulk of the work involved properly configuring the environment and not so much on the coding side. Thanks to Microsoft, the bulk of the work is being done for us in the background. BizTalk provides a good solid foundation for an ESB architecture in which it will be the mediator between external services and internal resources. We have shown that we can use BizTalk in the middle layer to provide for some business rules.


Product Spotlight
Product Spotlight 

©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-19 10:50:21 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search