tags:

views:

234

answers:

2

I have a seperate assembly ( reference by WebService) in which I have created a class ( Let's say ABC ) and a collection of that class ( ABCCollection : IList where T:ABC ). Now when I build the proxy files (output.config and Service1.cs) then the defienation of these two classes are not exposed. Instead the ABCCollection is exposed in Servic1.cs is like ABCCollection4IP3 .

Please let me know the possible cause for this issues..

A: 

They are not meant to be the same type. This is by design. Consider how it would work if your service were in .NET and your client in Java. They would clearly be two different types.

John Saunders
A: 

A best practice when designing a WCF service is to split up your project into seperate assemblies:

Assembly SomeProject.ServiceContract

This assembly contains your service contract (just the interfaces).

Example:

[ServiceContract (...)]
public interface ICan {

   [ServiceOperation (...)]
   void EatCandies (MyListOfCandies candies);

}

Assembly SomeProject.DataObjects

This assembly contains all your data objects which is used by your service contract.

Example:

[DataObject]
public class MyListOfCandies : List<Candy> {
    ...
}

In your project, which is consuming your web service reference the assembly "SomeProject.DataObjects" and then add your web service. You'll see that Visual Studio will no longer generate any stub objects but will use your implementation.

You can do the same with the ServiceContract assembly. This way you still can use web services, but you will get compile errors when you change your interface.

Christian Birkl