Ayman’s BizTalk Lab

November 22, 2007

Creating a New MOSS 2007 Task Using Web Services Exposed by MOSS

Filed under: Uncategorized — Admin @ 12:56 pm
Tags: ,


In my last post a shows how we can create a new MOSS Task using BizTalk WSS Adapter and we discussed the problem with the provided solution.

Here I’ll try to propose a new solution. The basic idea is based on that MOSS 2007 exposes some web services to manage any application remotely. the two main web services we will use are the List web service and UserGroup web service. so let’s start digging 🙂

The idea is to create a simple class library to call those web services for us and then use this library from our BizTalk solution. so let’s create the class library.

Creating The Class Library

we will create a new class library project and make two web references to the List (Windows SharePoint Services List Web Service) and the UserGroup (Windows SharePoint Services UserGroup Web Service) web services which are located in _vti_bin directory in the default SharePoint application for example:

I named the web references ListServiceProxy and UserGroupServiceProxy.

WSSTask Class

Next I created a class named WSSTask to hold the task data as follows:

WSSTask Class

we must make the class Serializable so that BizTalk can deal with it.

WSSTaskCreator Class

Next we will make the class which will do the actual task creation.

WSSTaskCreator Class

as usual we will make the class Serializable. in the constructor we accept four string parameter:

UserName The username used to connect to the SharePoint site
Password The password used to connect to the SharePoint site
UserGroupServiceURL The URL to actual UserGroup service on the site we want to create the Task in.
ListServiceURL The URL to actual List service on the site we want to create the Task in.

The constructor also calls a function SetSiteCredential to set the network Credentials used to authenticate in the SharePoint site.

GetFullUserName Function

Then we will write the function GetFullUserName to call the UserGroup web service to get the username with the format required to create the task (ID;#User_Display_Name)

GetFullUserName Function

This function accepts two string parameters UserGroupServiceURL we mentioned earlier and UserLoginName which is a string in the format “domain\username”. we simply create an object of the web service and calls the GetUserInfo method passing the UserLoginName to it and we store the return in a XmlNode object. basically the return will be something like this:

GetUserInfo Method Return

we just want the value of the ID and Name attributes, so we get them and create the FullUserName in the required format.

CreateNewTask Function

CreateNewTask Function

this function is the core of our class library. it calls the GetFullUserName function then creates a new instance of the List web service and then creates the Query that will be used to create the new task, then executes it (UpdateListItems) against the Tasks list. the output of the UpdateListItems method is a XmlNode which will be something like this:

UpdateListItems Method Return

then we check that there is no error occurred and return true or false.

the last step is signing our assembly to make strongly named so we can install it in the Global Assembly Cache (GAC). Then we build our assembly, GAC it and we are now ready to play some music :).

BizTalk Solution

Our BizTalk solution consists of a simple schema (TaskSchema) and Orchestration (CreateTaskProcess).

First we need to make a reference to our class library we created earlier.

then we need to create the schema which is a very simple one with three string fields as shown:


we will distinguish the fields so we can use then from the orchestration.

the orchestration will be a very simple one like in the figure:

CreateTaskProcess Orchestration

before we talk about the orchestration, we will need to create the message

MsgTask of the schema type we created earlier and we will create three variables:



varWssTask WSSTaskLib.WSSTask
varWssTaskCreator WSSTaskLib.WSSTaskCreator
varWssTaskReturn Boolean

The orchestration consists of a receives shape (Receive_1) then an expression shape (CreateTaskExp) which our code to create the Task will reside in:

CreateTaskExp Shape

this code is self describing.

then in the orchestration we have a decide shape based on the value of varWssTaskReturn will send the task to a send port.

Build and Deploy

we need then to build and deploy our application and create the physical ports, which for simplicity can use the File Adapter. and this the time to test our application by simply making an instance of our schema and fill it with correct data, the sample test file may look like this:


drop the file simply in the directory the receive port listens to and voila .. the task created successfully.

see you in the next post.



  1. Hi, I have a query..
    The GetUSerInfo web service will return users from all site users list. If a user is not in that list then it then get Full user name function will not be able to return a value and assignment will not work.

    Say you are assigning a task to a user who is member of an AD group. The AD group is added to all users list but the individual user entry is not there in All Site User’s list

    Can you please give this a thought. I am stuck with this.

    Comment by Atul Nisar — March 17, 2008 @ 3:31 pm | Reply

  2. Hi Atul,

    The first thing I thought of in your case is if the GetUserInfo method couldn’t find the user cause it’s not listed directly in the All Site Users list, you can get a list of all AD groups that this user belongs to then pass them one by one to the GetUserInfo method until you get a value.

    you can check here http://www.netomatix.com/UserGroupMembership.aspx for how you can get the list of AD groups user is member of.

    Hope this helps.

    Comment by Ayman Abdel-Salam — March 19, 2008 @ 11:57 am | Reply

  3. I follow your posts for a long time and should tell that your posts always prove to be of a high value and quality for readers.

    Comment by Random T. — April 24, 2009 @ 12:57 pm | Reply

RSS feed for comments on this post. TrackBack URI

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

Blog at WordPress.com.

%d bloggers like this: