.NET 3.5 ASMX Web Service - Invoked via .NET 3.5 Service Reference - Common Class Reuse


I have a .NET 3.5 web service with a single web method that looks something like this:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ using System; using System.Collections.Generic; using System.Web.Services; namespace Webservice1 { [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] public class WebService1 : WebService { [WebMethod] public List<Model.Person> HelloWorld() { var person1 = new Model.Person { FirstName = "Champa", LastName = "Chameli", TimeSpan = new TimeSpan(12,10,9,8)}; var person2 = new Model.Person { FirstName = "Shamu", LastName = "Ramu", TimeSpan = new TimeSpan(12,10,9,8) }; var persons = new List<Model.Person> { person1, person2 }; return persons; } } } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ using System.Runtime.Serialization; namespace Model { [DataContract] public class Person { [DataMember] public string FirstName{ get; set; } [DataMember] public string LastName { get; set; } [DataMember] public System.TimeSpan TimeSpan { get; set; } } } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The Person class is defined in a common .NET 3.5 assembly that is also available (as a project reference) to a .NET 3.5 application that calls the webservice via a Service Reference (not a .NET compatibility web reference).

The issue is that the service reference namespace contains its own, auto generated, implementation of Person. So the auto generated Service Reference method, available on the proxy SOAP client, has the following signature:

public WebApplication1.WebServiceReference1.Person[] HelloWorld()

I also tried using the svcutil command with the dataContractOnly option but I get the error


"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\svcutil" http:///CrossfirePortalServices/Leasing/WebService1.asmx /o:"C:\temp\WebApplication1\WebApplication1\WebService1.cs" /s /tcv:Version35 /r:"c:\temp\WebApplication1\Model\bin\Debug\Model.dll" /language:C# /n:*,RPCommonClasses.Services.WebService1 /dataContractOnly

Error: The input read from 'http:///CrossfirePortalServices/Leasing/WebService1.asmx' is inconsistent with other options. If you would like more help, type "svcutil /?"


I am keen to find a solution where I can use Model domain throughout the entire framework rather than having to translate the different types in the Model domain to the different types in the ServiceReference domain for requests and vice versa for responses.

Also we cannot change asmx webservices to WCF since our IT department is against it. Any suggestions on how I can accomplish this task?


There is good news and bad news. Good news is that it is possible and officialy supported. The bad news is that it is rather complicated.

Please refer to this MSDN article for example of sharing class library between web references. The same applies to your scenario.

<a href="http://msdn.microsoft.com/en-us/library/Aa480505.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/Aa480505.aspx</a>


  • Display database item with DataSet to Datagridview from separated class to winform
  • 'Object.ReferenceEquals' is always false because it is called with a value type
  • DataContract surrogate for amplified value type
  • ObservableCollection and CollectionChanged event as WCF datacontract
  • How to parse multiple single xml elements in .Net C#
  • How do I make a SKSpriteNode that does not respond to touch if it's pixels are transparent?
  • SerialForms.pas(17): W1010 Method 'Create' hides virtual method of base type 'TCompon
  • ExtensionDataObject not marked as serializable
  • How to update the UI immediately when a new record is added? Related to ember-cli-pagination
  • Find record, that has ALL associated records
  • How to make a post call to a Web Api Action?
  • Complex Object won't return when using 'include' syntax in WCF with Entity Version 6
  • How can I compose a WCF contract out of multiple interfaces?
  • Streamed transfer restrictions with WCF
  • Storing WCF rest request data with SQL Server stored procedure
  • Jackson Java 8 DateTime serialisation
  • runtime error when linking ffmpeg libraries in qt creator
  • Ruby on Rails App deployed to heroku showing “We're sorry, but something went wrong”
  • Detecting null parameter in preprocessor macro
  • C# program and C++ DLL compiled for 32-bit system crash on 64-bit system
  • Why Encoding.ASCII != ASCIIEncoding.Default in C#?
  • one Local Olampyad Questions on Informatic in 2011
  • Counter field in MS Access, how to generate?
  • Possible to stop flickering java tooltip in heavyweight mode?
  • sending/ receiving email in Java
  • How to set my toolbar fixed while scrolling android
  • AT Commands to Send SMS not working in Windows 8.1
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • KeystoneJS: Relationships in Admin UI not updating
  • How to set the response of a form post action to a iframe source?
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • apache spark aggregate function using min value
  • Django query for large number of relationships
  • Sorting a 2D array using the second column C++
  • reshape alternating columns in less time and using less memory
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can I use `wmic` in a Windows PE script?
  • Net Present Value in Excel for Grouped Recurring CF
  • How to push additional view controllers onto NavigationController but keep the TabBar?