thomasbau65
asked on
Overwrite InfoProperty of generic wcf client
Hi all
following question:
How do I overwrite a property of a instance of a wcf client which is instantiated as follow:
Now the Manager code is run as user@domain but the wcfClient must authenticate on the server side with otherUser@otherDomain which forces me to do some thing like:
check this: Impersonate a totally different Windows User in a client
Now I wanted to keep the Manager and add something like
How do I instantiate the outerProp to correctly use the SetValue method on the specific InfoProperty of the wcfClient.
Or is there a way to get the wcfClient instance knowing the type?
Any better way to reset/overwrite the wcfClient credential could also be a solution to my problem...
Thanks for your support
th*
following question:
How do I overwrite a property of a instance of a wcf client which is instantiated as follow:
public abstaract class Manager<T> : IDisposable where T : class, ICommunicationObject, new()
{
protected T wcfClient;
public ConnectionManager()
{
wcfClient = new T();
}
}
The reason I'm using the Manager is because I have several services which I use and wanted to centralize dispose and create method...Now the Manager code is run as user@domain but the wcfClient must authenticate on the server side with otherUser@otherDomain which forces me to do some thing like:
check this: Impersonate a totally different Windows User in a client
Now I wanted to keep the Manager and add something like
Type cType = wcfClient.GetType().getBaseType;
PropertyInfo[] props = cType.GetProperty("ClientCredentials")
.PropertyType.GetProperty("Windows")
.PropertyType.GetProperty("ClientCredential")
.PropertyType.GetProperties();
foreach (PropertyInfo p in props)
{
if (p.Name.Equals("Domain"))
{
/*
* How do I instantiate the the outerprop ?? */
object outerProp = p.PropertyType.GetConstructor(new Type[] { }).Invoke(new object[] { });
if (p.CanWrite)
{
p.SetValue(outerProp, "otherDomain", null);
}
}
if (p.Name.Equals("UserName"))
{
/*
* How do I instantiate the the outerprop ?? */
object outerProp = p.PropertyType.GetConstructor(new Type[] { }).Invoke(new object[] { });
if (p.CanWrite)
{
p.SetValue(outerProp, "username", null);
}
}
if (p.Name.Equals("Password"))
{
/*
* How do I instantiate the the outerprop ?? */
object outerProp = p.PropertyType.GetConstructor(new Type[] { }).Invoke(new object[] { });
if (p.CanWrite)
{
p.SetValue(outerProp, "xxxxxx", null);
}
}
}
to add/overwrite the client credential but got stuck.How do I instantiate the outerProp to correctly use the SetValue method on the specific InfoProperty of the wcfClient.
Or is there a way to get the wcfClient instance knowing the type?
Any better way to reset/overwrite the wcfClient credential could also be a solution to my problem...
Thanks for your support
th*
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.