Question

My service call isn't working and its because the type hinting isn't being sent along in the message.

Here's what is being sent.

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <createLocalUser xmlns="http://adobe.com/idp/services">
            <localUser xmlns:i="http://www.w3.org/2001/XMLSchema-instance">

And this is what it should be

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <createLocalUser xmlns="http://adobe.com/idp/services">
            <localUser i:type="UserImpl">

Notice the change on the localUser element. I know this is the problem because if I modify the request in fiddler, it works. I just don't know what to change in my C# code.

Here are my C# classes.

[DataContract(Name = "UserImpl", Namespace = NameSpace.Root)]
public partial class UserImpl : User { }

[DataContract(Name = "User", Namespace = NameSpace.Root)]
public partial class User : Principal { ... }

[DataContract(Name = "Principal", Namespace = NameSpace.Root)]
public partial class Principal { ... }

And the interface

[ServiceContract(Namespace = NameSpace.Root)]
public interface IDirectoryManagementService
{
    [OperationContract(Name = "createLocalUser")]
    string CreateLocalUser(DataContracts.UserImpl localUser, string password);

I think it's a problem with ServiceKnownType or KnownType, but I'm not sure.

Was it helpful?

Solution

Got it figured out. For anyone having the same issue, here is what made the difference.

My service interface was set to take a UserImpl object

string CreateLocalUser(DataContracts.UserImpl localUser, string password);

And I passed it a UserImpl instance. However, what I needed to do is change it to a User instead. Since UserImpl inherits from User, there isn't any issue for C#, but WCF notices the difference and adds the i:type attribute. So here is what I changed it too.

[ServiceContract(Namespace = NameSpace.Root)]
    public interface IDirectoryManagementService
    {
        [OperationContract(Name = "createLocalUser")]
        string CreateLocalUser(DataContracts.User localUser, string password);

Notice how localUser parameter is now a User type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top