I’m looking at implementing a WCF Service which will in turn call one (or perhaps more) external WCF Services (or at least, web services which I will call from code using WCF Service reference(s))
My solution is broken down into ServiceLayer, BusinessLogicLayer, DomainLayer, DtoObjects etc.
My Question is:
The logic around the client will all be in the BusinessLogicLayer – but if I put the ServiceReferences in there then I will also need to put the service configuration in the ServiceLayer – since this is where the originating call will be made.
Is that the correct thing to do?
Or:
Create the client in the ServiceLayer and pass it into the BLL.
Not sure I like this idea…but it DOES mean only one config.
Or:
Is there another way?
You can look at it as any code that calls a WCF service is a WCF client, even if that happens to be another bit of code that is itself hosted as a WCF service. Because of this, you will need the client side configuration to be present and available wherever the call is being made. I don’t know if there is a good way to share configuration, or if it’s even advisable… instead, I would opt for separate configuration files in each place. There won’t really be much duplication in that you’ve got service-side configuration in one place, and client side configuration in the other.
If you can use WCF Discovery (http://msdn.microsoft.com/en-us/library/dd456782.aspx), it can reduce the amount of configuration you’ll have to create. Also, using interfaces and
ChannelFactory<T>instead of ServiceReferences will give you a cleaner setup.Hope this helps.