Is it good practice to reference my web applications domain layer class library to WCF service application.
Doing that gives me easy access to the already existing classes on my domain model so that I will not need to re-define similar classes to be used by the WCF service
On the other hand, I don't like the coupling that it creates between the application and service and i am curious if it could create difficulties for me on the long run.
I also think having dedicated classes for my WCF app would be more efficient since those classes will only contain the members that will be used by the service and nothing else. If I use the classes from my domain layer there will be many fields in the classes that will not be used by the service and it will cause unnecessary data transfer.
I will appreciate if you can give me your thoughts from your experience
Create the WCF service application Right-click on the solution you created in the procedure above and click Add new project. In the New Projectscreen, select WCF, and then select WCF Service Application in the right pane as shown in Figure 2.
Perform the following steps to publish the service. Publish the service to the web application Right-click the WCF service application project and then click on Publish. Select File Systemas the publish method. In the target location, specify the path to the directory which you created while creating the web application, as shown in Figure 4.
The impetus for this article is that cross-domain authenticated WCF calls are not possible with the default web HTTP binding. This article details the steps required to create a working end-to-end solution by using JQuery. Note You can learn more about SharePoint sandboxed solutions here: Sandboxed solutions resource center. Problem definition
After you have your JSONP binding project set up, you are ready to create your WCF service application. Create the WCF service application Right-click on the solution you created in the procedure above and click Add new project. In the New Projectscreen, select WCF, and then select WCF Service Application in the right pane as shown in Figure 2.
No it's not. Entities are all about behaviour. data contract is all about... data. Plus as you mentioned you wouldn't want to couple them together, because it will cripple you ability to react to change very soon.
For those still coming across this post, like I....
Checkout this site. Its a good explanation on the topic.
Conclusion: Go through the effort of keeping the boundaries of your architecture clear and clean. You will get some credit for it some day ;)
I personally frown on directly passing domain objects directly through WCF. As Krzysztof said, it's about a data contract not a contract about the behavior of the the thing you are passing over the wire.
I typically do this:
Putting the conceptual purity of what a "Data Contract" is aside, If you begin to pass entities around you are setting up your shared entity to pulled in different design directions by each side of the WCF boundary. Inevitably you'll end up with behaviors that only belong to one side, or even worse - have to expose methods that conceptually do the same thing but in a different way for each side of the WCF boundary. It can potentially get very messy over the long term.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With