0

I have a number of WCF Services which are called for a certain function from an ASP.NET MVC application.

  1. The MVC app calls Contract-Service (WCF Service)
  2. Contract-Service during its processing calls Contract-Buy-Service (WCF Service)
  3. Contract-Buy-Service calls SAM-Utility-Service (WCF Service)

When I run my TDD test cases from Contract-Buy-Service, it works perfectly fine. Because the call goes from Contract-Buy-Service to SAM-Utility-Service. But when the call goes from Contract-Service => Contract-Buy-Service => SAM-Utility-Service I always get the error that the endpoint for SAM-Utility-Service is not found in the config.

There is a service reference for SAM-Utility-Service in both the contract-buy-service and contract-service. I have checked that the service is hosted and is up and running. I can get the WSDL when I try to view through browser.

Can someone tell me why the service call does not go through multiple layers or am I doing something wrong here?

Thanks!

  • In general, unit tests should not call any services at all. Take advantage of the fact that service contracts are used (they are interfaces) to mock out the services. – John Saunders Sep 13 '11 at 23:23
  • Yes, that's how I implement the unit tests. I use the test project type in Visual Studio 2010 which has DLL references to the the contracts and not service references. I am using Service Factory to develop WCF Services. thanks – Khawar Yunus Sep 14 '11 at 03:36
  • 1
    Then you should update your question. When you run your TDD tests, you are not calling the services at all. – John Saunders Sep 14 '11 at 03:40

1 Answers1

0

To begin with, I don't believe the Contract-Service should need a service reference or any knowledge of the SAM-Utility-Service. Unless it needs to directly communicate with that service for some other operation - in which case I'd suggest another service endpoint anyway - it shouldn't know about what the Contract-Buy-Service is doing. This is leading to tighter coupling of your services which removes one of the major benefits of service-orientation.

The cause of your problem could be a number of things (as is always the way with WCF). However I've had similar problems to this caused by bad choice, incorrect use or misalignment of transactions.

Consider that, for example, Contract-Service and Contract-Buy-Service participate in a transaction. SAM-Utility-Service may also require a transaction, but requires a new transaction. If this second transaction doesn't participate in the first transaction correctly, then the first transaction may not allow it to commit or may not commit itself.

One first step could be to get all three working in concert without any transactions.

Kirk Broadhurst
  • 27,836
  • 16
  • 104
  • 169
  • Kirk, Thanks for your answer. Contract-Service needs to communicate with SAM-Utility-Service for other Contract-Service service operations too without involvement of the Contract-Buy Service. What I am going to do now is create another endpoint for SAM-Utility Service and use separate endpoints from Contract and Contract-Buy Service. I hope that resolves the issue. – Khawar Yunus Sep 14 '11 at 03:40