简体   繁体   中英

Why does WCF service create its own type?

In my WCF project, I have a type that comes from a different library:

LibraryB.SomeClass

In the svc.cs file for the service, I use the above type in a parameter:

GetEmployees(LibraryB.SomeClass someClass)

In the web app that is hosting the service, a type is created for the service:

MyWebApp.ServiceAReference.ServiceAClient serviceClient = new MyWebApp.ServiceAReference.ServiceAClient();

But when I reference the method:

serviceClient.GetEmployees(someClass);

The intellisense for the parameter is of type:

MyWebApp.ServiceA.SomeClass

In the web app, someClass is of type LibraryB.SomeClass and not MyWebApp.ServiceA.SomeClass.

Is there some way to tell the web service to send the type LibraryB.SomeClass across the wire? Or is there something different I should be doing?

The client does not always have access to the server's types. The server might not even be your code! For that reason proxy objects are created on the client side to represent the server's objects.

If the server and client side share the asemblies that contain the type that is sent over the wire, you can tell your application to re-use it when you add your service reference.

添加服务参考

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM