[IronPython] Newbie: IronPython and WSE 3.0 (translation from C# example)?

Srivatsn Narayanan srivatsn at microsoft.com
Sun Mar 9 23:27:09 PDT 2008

Looks like Webservice.Load is not returning a WebServicesClientProtocol. In the C# world you are instantiating a UserServiceWse. You could do the same in python so:
userService = UserServiceWse()

I assume the definition of that class would look like this:
def UserServiceWse(WebServicesClientProtocol):
        def __init__(self): #The constructor.
                self.blah = foo

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Ramon M. Felciano @ Yahoo
Sent: Sunday, March 09, 2008 11:09 PM
To: users at lists.ironpython.com
Cc: Ramon Felciano
Subject: [IronPython] Newbie: IronPython and WSE 3.0 (translation from C# example)?

Hi --

I'm trying to hook up IronPython to web services secured by Web Services
Enhancements (WSE) 3.0. I have some C# sample code that I'm trying to
convert to Python and am running into some trouble. I'm a C# and Windows
..NET newbie (using IronPython from the commmandline), so the libraries
in question are foreign to me, so I was hoping someone could help me
resolve this. The sample code shows:

using Microsoft.Web.Services3;
using Microsoft.Web.Services3.Design;
using Microsoft.Web.Services3.Security;
using Microsoft.Web.Services3.Security.Tokens;
namespace TpIntegration
public class TpPolicy : Policy {
  public TpPolicy() {
    Assertions.Add(new UsernameOverTransportAssertion());
  public static UsernameToken GetUsernameToken(string username, string
password, PasswordOption passwordOption) {
    UsernameToken token = new UsernameToken(username, password,
    ISecurityTokenManager securityTokenManager =

    return token;
  public static void ApplyAutheticationTicket(WebServicesClientProtocol
protocol, string userName, string password) {
    UsernameToken token = GetUsernameToken(userName, password,
    protocol.SetPolicy(new TpPolicy());

This is then called using something like this:

UserServiceWse userService = new UserServiceWse();
TpPolicy.ApplyAutheticationTicket(userService, "admin", "admin");

I've taken a swing at converting it:

import Microsoft.Web.Services3
import Microsoft.Web.Services3.Design
import Microsoft.Web.Services3.Security
import Microsoft.Web.Services3.Security.Tokens

def getUsernameToken(username, password, passwordOption):
    token =
password, passwordOption)
    securityTokenManager =
    return token

def applyAutheticationTicket(protocol, userName, password):
    token = getUsernameToken(userName, password,

but when calling it:

userService =
username = "test"
password = "test"
applyAutheticationTicket(userService, username, password)

I get the following error:

AttributeError: 'UserService' object has no attribute 'SetClientCredential'

Any suggestions on how to debug this further? In case it matters, this
is code from



Users mailing list
Users at lists.ironpython.com

More information about the Users mailing list