1
votes

I am new to WCF and have an issue that I cannot seemto find the answer to.

I have two projects. One is a simple login application and other is a hosted IIS WCF Service (.svc) that connects to a database. Both projects are .NET 4.

The WCF service has two methods: "Administrator_Login" and "User_Login".

Whenever each of the methods are called, they execute some code respective to the method: Administrator.Login.Execute and User.Login.Execute (I am organising my code into namespaces, Administrator.Login and User.Login being the class names and Execute being the name of the method).

Both operations return a distinct "LoginOut" object that exist within the User.Login class or Administrator.Login class.

My issue is this: Although each operation is organised into namespaces on the WCF service, when I add a service reference from the client application to the service and look at the names of types of objects returned, I am seein "LoginOut and "LoginOut1".

Is there a way to reference the returned the objects in the client application returned by the WCF service by the namespace?

I am currently having to do this:

Dim loginOut As Service.LoginOut = Service.Administrator_Login().Execute() 
Dim loginOut As Service.LoginOut1 = Service.User_Login().Execute() 

But I would like to be able to do:

Dim loginOut As Service.Administrator.Login.LoginOut = Service.Administrator_Login().Execute() 
Dim loginOut As Service.User.Login.LoginOut = Service.User_Login().Execute() 

Any help would be greatly appreciated.

1

1 Answers

0
votes

If you seperate the definitions of "LoginOut" into a class library(s) and then reference that class library(s) from your client project, and update the service reference, then you should get the behavior you are looking for. If not do a configureServiceReference, click advanced and make sure "resuse types in all referenced assemblies" is selected.

Note that this is not a "pure" way to do SOA. This binds your client and webservice together in a way that may cause you trouble down the road. However I have done this myself in different small scale situations and not run into any problems.

This solution may be a bit heavy, depending on the desired behavior. It involves distributing copies of the library DLL to each client. This can be a very powerful as you are effectively distributing behavior with your data, but might be overkill for the problem at hand.