IMPORTANT: TargetProcess Web Services use Web Services Enhancement 3.0, so it is required to have them installed.
Authentication
TargetProcess web services based on WSE 3.0 (Microsoft Web Service Enhancements). It limits interoperability and support of WS-Security 1.0 or 1.1 required to use TargetProcess web services. Also note that UsernameOverTransport security assertion is used.
Check Web Services API Authentication to become familar with basic authentication example.
Installing Web Services Enhancements 3.0
Download Web Services Enhancement 3.0 and Run Microsoft WSE 3.0.msi. Select "Visual Studio Developer" option in setup wizard.

Creating Project
We will create sample console application that will retrieve all users from TargetProcess.
Open Visual Studio, click New Project and select Console Application.

Next step is to add reference to WSE 3.0. Right click on project References and find Microsoft.Web.Services3.

Then you need to add Web Reference to UserService web service. Right click on References and select Add Web Reference option. Type path to web service http://[your_tp_path]/Services/UserService.asmx and click Add Reference button. Visual Studio will generate proxy classes and from that moment you may access UserService.

Now we are ready to investigate power of TargetProcess web services API.
using
System;
using TpIntegration.UserService;
namespace TpIntegration
{
internal
class Program
{
private
static void
Main(string[] args)
{
//
Create web service and path authentication.
//
"admin" / "admin" is login/password of user
//
that has access to TargetProcess
UserServiceWse
userService = new UserServiceWse();
TpPolicy.ApplyAutheticationTicket(userService,
"admin", "admin");
//
Retrieve all users in TargetProcess
UserDTO[]
users = userService.RetrieveAll();
//
Make something interesting with users list.
//
For example, just show users
foreach
(UserDTO user in
users)
{
Console.WriteLine(user.FirstName
+ " " + user.LastName);
}
}
}
}
Examples
Using HQL to retrieve all assigned user stories
string userName = "admin";
string userPassword = "admin";
UserStoryServiceWse userStoryService = new UserStoryServiceWse();
TpPolicy.ApplyAutheticationTicket(userStoryService, userName, userPassword);
string hqlAssignedUserStoryQuery =
@"from UserStory as us where us.UserStoryID in
(select team.Assignable.AssignableID from Team as team
where team.User.UserID = ?
and team.Actor = us.EntityState.Actor
and team.Assignable.AssignableID = us.UserStoryID)";
UserStoryDTO[] stories = userStoryService.Retrieve(hqlAssignedUserStoryQuery, new object[] {users[0].UserID});
Add comment to user story
UserStoryServiceWse service = new UserStoryServiceWse();
TpPolicy.ApplyAutheticationTicket(service, "admin", "admin");
CommentDTO comment = new CommentDTO();
comment.Description = "New Comment";
int commId = service.AddCommentToUserStory(EntityId, comment);