Windows Mobile Client for TFS WebService


I am so curious to write some windows mobile application for my HTC mobile. Recently i attended the TFS server 2008 training conducted by Microsoft at NTUC building. Once i finish the training i was eager to know whether any Mobile Application to update my task easily. I was searching for Internet but could not find any Mobile application which does that. So it had initiated me to try my own Windows Mobile application for TFS.

Once i decided to write the Mobile Application i need to decide either to use TFS SDK or the webservice. Of course WebService is the light weight approach for a Mobile application because i don’t have to add any reference to any assembly. Only web reference needs to be created which creates only the Proxy classes.

TFS Server has several webservice to manage the WorkItem tracking. Below are the services

http://localhost:8080/WorkItemTracking/v1.0/ClientService.asmx

http://localhost:8080/WorkItemTracking/v1.0/ConfigurationSettingsService.asmx

http://localhost:8080/WorkItemTracking/v1.0/ExternalServices.asmx

http://localhost:8080/WorkItemTracking/v1.0/Integration.asmx

http://localhost:8080/WorkItemTracking/v1.0/SyncEventsListener.asmx

Before starting the Windows Mobile Application we need to identify the platform to develop the application. So i read the below documentation to install the Development tools. http://msdn.microsoft.com/en-us/library/bb158496.aspx. My HTC mobile has Windows Mobile 6.5 professional edition. So i had to download the WM 6.0 emulator for VS 2008. http://www.microsoft.com/downloads/details.aspx?FamilyID=06111a3a-a651-4745-88ef-3d48091a390b&DisplayLang=en. I downloaded the SDK for WM 6.0 for VS 2008.

I installed the SDK and started creating the WM application.

image

image

I added a webservice reference to the http://localhost:8080/WorkItemTracking/v1.0/ClientService.asmx through VS 2008.

image

I designed the form for my mobile to connect to the TFS server.

image

I manage to write a code to consume the webservice for the TFS server. I added the below code to consume the service.

            Dim myTfsClient As TFS.ClientService = New TFS.ClientService()
            myTfsClient.Url = txtURL.Text
            Dim mySortOrderEntry As TFS.QuerySortOrderEntry = New TFS.QuerySortOrderEntry()
            mySortOrderEntry.Ascending = True
            mySortOrderEntry.ColumnName = "WorkItem"
            Dim sort(1) As TFS.QuerySortOrderEntry
            sort(0) = mySortOrderEntry
            Dim metaTableEntry As TFS.MetadataTableHaveEntry = New TFS.MetadataTableHaveEntry
            Dim metaDataHave(1) As TFS.MetadataTableHaveEntry
            metaDataHave(0) = metaTableEntry
            Dim asOfDate As DateTime = DateTime.Now
            Dim dbStamp As String = ""
            Dim metaData As DataSet = New DataSet("metadata")
            Dim myQuery As Xml.XmlDocument = New Xml.XmlDocument()
            myQuery.LoadXml("<?xml version=’1.0′ encoding=’utf-8′?><WorkItemQuery Version=’1′><TeamFoundationServer>http://senwin2003:8080/</TeamFoundationServer><TeamProject>Sample</TeamProject><Wiql>SELECT [System.Id], [System.WorkItemType], [System.State], [System.AssignedTo], [System.Title] FROM WorkItems WHERE [System.TeamProject] = @project ORDER BY [System.WorkItemType], [System.Id]</Wiql></WorkItemQuery>")
            Dim xmlNode As Xml.XmlElement
            xmlNode = myQuery.SelectSingleNode("WorkItemQuery/Wiql")

            Dim workItemsXml As Xml.XmlElement = myTfsClient.QueryWorkitems(xmlNode, sort, True, metaDataHave, asOfDate, dbStamp, metaData)
            Dim nodeReader As Xml.XmlNodeReader = New Xml.XmlNodeReader(workItemsXml)
            Dim returnXML As SqlXml = New SqlXml(nodeReader)
            MessageBox.Show(returnXML.Value)

But unfortunately the code didnt work it gave the security exception. Its correct i was running the code outside of my TFS server so it requires domain, username and pwd authentication. So i added the below code to supply the credential

            ”””” credential
            Dim cache As CredentialCache = New CredentialCache()
            cache.Add(New Uri(myTfsClient.Url), "Negotiate", New NetworkCredential(txtUser.Text, txtPwd.Text, txtDomain.Text))
            myTfsClient.Credentials = cache
            ”””
Now the security error is gone. But guess what i got following error “TF51313: The request ID is incorrect or not recognized”. I tried the other TFS Service http://localhost:8080/WorkItemTracking/v1.0/ExternalServices.asmx. It works without any error.

When i checked the SOAP message, the ClientService requires a RequestHeader in the SOAP header. The request header requires a valid id to be passed to call the clientservice methods. But the externalservices methods dont have such header info in the SOAP header so only this service works.

I posted in the forums hoping to get some clue http://social.expression.microsoft.com/Forums/en-US/tfsgeneral/thread/8d2b9618-1e83-4eee-ad87-e882977b7ec7?prof=required&wa=wsignin1.0 but no reply yet.

Hoping to crack down the issue soon…..

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 )

Facebook photo

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

Connecting to %s