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

  • Home
  • SEARCH
  • 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 1928714
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T07:00:47+00:00 2026-05-17T07:00:47+00:00

I am looking for a way to have the generated proxy class for a

  • 0

I am looking for a way to have the generated proxy class for a Web Reference (not WCF) implement a common interface in order to easily switch between web service access and “direct” access to our business layer in the client application, something like:

public IBusiness GetBusinessObject()
{
  if (_mode = "remote")
    return new BusinessWebService.Business(); // access through web service proxy class
  else
    return new Business(); // direct access
}

However, custom types (e.g. the CustomSerializableType in the examples below) aren’t referenced in the generated proxy class. Instead new, identical types are generated, which makes it impossible for the proxy class to implement the interface.

Is there some way to make the generated proxy class reference these types, or am I going about this all wrong? Should I consider converting the web service to a WCF service instead?


Details

Our solution consists of these four projects:

  • A business library (contains business logic, accesses data store)
  • A common library (contains common functionality, including the CustomSerializableType)
  • A web service (acts as a proxy between remote clients and the business layer)
  • A windows application

Our client wants the windows application to be able to run in two different modes:

  • Local mode, where the application simply uses the business library directly to access data
  • Remote mode, where the application communicates with the web service to access data

In order to do this, we have created an interface, IBusiness, which is located in the common library and contains all business methods.

Interface

public interface IBusiness
{
  CustomSerializableType DoSomeWork();
}

Business layer

public class Business : IBusiness
{
  public CustomSerializableType DoSomeWork()
  {
    // access data store
  }
}

Web service

public class WebServiceBusiness : IBusiness
{
  private Business _business = new Business();

  [WebMethod]
  public CustomSerializableType DoSomeWork()
  {
    return _business.DoSomeWork();
  }
}

Generated proxy class (a ton of code left out for readability)

public partial class Business
  : System.Web.Services.Protocols.SoapHttpClientProtocol
{

  public CustomSerializableType DoSomeWork()
  {
    // ...
  }

  public partial class CustomSerializableType {
    // PROBLEM: this new type is referenced, instead of the
    // type in the common library
  }
}
  • 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-17T07:00:48+00:00Added an answer on May 17, 2026 at 7:00 am

    Assuming that the default namespace for your client is “Client”, and that your web reference is named “Proxy”, then do the following;

    1. In the root of your client project, create a folder named “Proxy”.
    2. In that folder, create a class named “Business”.
    3. Make that class public and partial, and have it implement your IBusiness interface

    This way, you do not need to modify the Reference.cs. You should never modify Reference.cs, or any other file produced through code generation.

    Note that this violates the principals of SOA by tightly binding your client to your service. At the very least, you should define those interfaces in a separate project, so that you are only sharing the “interface” project between the client and service.

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

Sidebar

Related Questions

No related questions found

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.