1

I was wondering whether you thought this or something similiar would be possible with unity? I want to inject the username and password credentials for the the WCF Service reference OrderServiceClientClient() i am using in my curent project..

container.RegisterType<IOrderServiceClient, OrderServiceClientClient>(
   new InjectionConstructor(
      new InjectionProperty("ClientCredentials.UserName.UserName", "test"), 
      new InjectionProperty("ClientCredentials.UserName.Password", "password")));

is something like this possible?

EDIT:

looking into the service reference the defination looks like this for the class:

class ProductMasterServiceClientClient : System.ServiceModel.ClientBase<com.luzern.co40.web.pm.wsProductMasterService.IProductMasterServiceClient>, com.luzern.co40.web.pm.wsProductMasterService.IProductMasterServiceClient

And the parent class ClientBase class contains the definition for the ClientCredential member..

I dont want to replace the Whole ClientCredential member, i just want to set the 2 propertys username and password on it!

EDIT 2!!

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class OrderServiceClientClient : System.ServiceModel.ClientBase<com.luzern.co40.web.pm.wsOrderService.IOrderServiceClient>, com.luzern.co40.web.pm.wsOrderService.IOrderServiceClient {

    public OrderServiceClientClient() {
    }

    public OrderServiceClientClient(string endpointConfigurationName) : 
            base(endpointConfigurationName) {
    }

    public OrderServiceClientClient(string endpointConfigurationName, string remoteAddress) : 
            base(endpointConfigurationName, remoteAddress) {
    }

    public OrderServiceClientClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
            base(endpointConfigurationName, remoteAddress) {
    }

    public OrderServiceClientClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
            base(binding, remoteAddress) {
    }

    public bool GenerateInvoice(int orderId, string email) {
        return base.Channel.GenerateInvoice(orderId, email);
    }

    public System.Threading.Tasks.Task<bool> GenerateInvoiceAsync(int orderId, string email) {
        return base.Channel.GenerateInvoiceAsync(orderId, email);
    }
}
5
  • Can you shows us the code for class OrderServiceClientClient and related objects? Commented Jun 20, 2013 at 13:19
  • its a generated service reference from a WCF service Commented Jun 20, 2013 at 13:43
  • ive made an edit above! thanks!! Commented Jun 20, 2013 at 13:45
  • You're still not showing the code for OrderServiceClientClient.... Commented Jun 20, 2013 at 13:49
  • Sorry Rui, ive added it there Commented Jun 20, 2013 at 14:01

1 Answer 1

1

Ok I have a fix.. Im going to create a partial class of my service reference and add a new constructor which takes login credentials of the ClientCredential as a parameter, and then i can just inject as normal string parameters!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.