jk.
jk.

Reputation: 83

Business Logic Layer expose in WCF Service

We have already Business logic layer available in our application. It has lots of classes. and this is in separate library(.Dll). Now we want to use this in to our WCF Service. For that We create new project and gave reference to that .Dll. But we are not able to see our class .. I verify that class is public..

Could you please let me know what should I do?

Here I am attaching my code what I need to do

My Business Layer class

namespace BusinessLayer
{
    public class MessageContext : Dictionary<string, object>
        { ....}
}

Now I am reference this Project to my WCF project and tried to expose this class into WCF client. So I Create one MessageContextHelper class which inherit from MessageContext the code is following

namespace WCFService
{ 
    public class MessageContextHelper : MessageContext
      { ...... }
}

On client I am not able to get MessageContextHelper class.

Thanks JK

Upvotes: 0

Views: 1944

Answers (2)

DQ Ninh
DQ Ninh

Reputation: 11

You absolutely cannot (and should not) use your business layer from your client code. As the previous reply message, WCF does not send your business class to the client. Think about how long it will take to send. The business layer (your dll) should be used on the server only. Your WCF should only accept modified/new data from the client, pass the data to the business layer, and then return the results to the client.

Upvotes: 1

Tridus
Tridus

Reputation: 5081

WCF doesn't send business logic classes to the client. If you're using the SOAP version of WCF (BasicHttpBinding for example) then what WCF will expose is methods that are in your service contract. Your client can call those.

So if you have methods in a business logic class that you want exposed, create methods in your WCF service that will in turn call the business layer methods.

A very rudimentary (and not complete) version would look something like this:

namespace WCFService {

public class MyService: IMyService

[OperationContract]
public String DoSomeStuff() {
      return MessageContext.DoSomething();
}

}

Upvotes: 2

Related Questions