Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6729719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:19:26+00:00 2026-05-26T10:19:26+00:00

I have a service reference to a .NET 2.0 web service. I have a

  • 0

I have a service reference to a .NET 2.0 web service. I have a reference to this service in my repository and I want to move to Ninject. I’ve been using DI for some time now, but haven’t tried it with a web service like this.

So, in my code, the repository constructor creates two objects: the client proxy for the service, and an AuthHeader object that is the first parameter of every method in the proxy.

The AuthHeader is where I’m having friction. Because the concrete type is required as the first parameter on every call in the proxy, I believe I need to take a dependency on AuthHeader in my repository. Is this true?

I extracted an interface for AuthHeader from my reference.cs. I wanted to move to the following for my repository constructor:

[Inject]
public PackageRepository(IWebService service, IAuthHeader authHeader)
{
    _service = service;
    _authHeader = authHeader;
}

…but then I can’t make calls to my service proxy like

_service.MakeSomeCall(_authheader, "some value").

…because because MakeSomeCall is expecting an AuthHeader, not an IAuthHeader.

Am I square-pegging a round hole here? Is this just an area where there isn’t a natural fit (because of web service “awesomeness”)? Am I missing an approach?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:19:27+00:00Added an answer on May 26, 2026 at 10:19 am

    It’s difficult to understand exactly what the question is here, but some general advice might be relevant to this situation:

    1. Dependency injection does not mean that everything has to be an interface. I’m not sure why you would try to extract an interface from a web service proxy generated from WSDL; the types in the WSDL are contracts which you must follow. This is especially silly if the IAuthHeader doesn’t have any behaviour (it doesn’t seem to) and you’ll never have alternate implementations.

    2. The reason why this looks all wrong is because it is wrong; this web service is poorly-designed. Information that’s common to all messages (like an authentication token) should never go in the body where it translates to a method parameter; instead it should go in the message header, wherethe ironically-named AuthHeader clearly isn’t. Headers can be intercepted by the proxy and inspected prior to executing any operation, either on the client or service side. In WCF that’s part of the behavior (generally ClientCredentials for authentication) and in legacy WSE it’s done as an extension. Although it’s theoretically possible to do this with information in the message body, it’s far more difficult to pull off reliably.

    3. In any event, what’s really important here isn’t so much what your repository depends on but where that dependency comes from. If your AuthHeader is injected by the kernel as a dependency then you’re still getting all the benefits of DI – in particular the ability to have this all registered in one place or substitute a different implementation (i.e. a derived class).

    So design issues aside, I don’t think you have a real problem in your DI implementation. If the class needs to take an AuthHeader then inject an AuthHeader. Don’t worry about the exact syntax and type, as long as it takes that dependency as a constructor argument or property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some types which are generated by a web service reference. I want
I have a .net web service reference and I want to pass it to
Am using VS2008 ASP.Net Web Forms have a detailsview, databound to web service reference
I have a .net web application which has a reference to a web service.
I have a class library (.NET) with a reference to a web service (in
This is my first time consuming a SOAP web service in ASP.Net and I
I have added a service reference to my asp.net web application (originally it was
I have a webservice - called MyCompany.WebService1 I reference this using a web reference
I've added a WCF service reference to a .NET project using this WSDL: https://interop.cmiservices.org/axis/services/CAP1_1?wsdl
We have a service reference that points at a WCF service, this acts as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.