Contract First SOA and WCF Contracts

299 views Asked by At

I have a simple question. I am using WCF to create web services. I have created all the services without filling the operation bodies. Now I have the wsdl files auto-generated from the service contracts. Is this approach "Contract First", if I am coding the operation implementations later?

2

There are 2 answers

3
Jim Simon On BEST ANSWER

Yes, because you're defining the contract between you and anyone consuming your API first. Usually (but not always) the contract/API is defined via an interface.

Edit: As Namphibian said in the comments, if you're building web services contract first, then you would want to define your WSDL first and generate the code from there. My answer assumed you wanted to develop a .NET API contract first and that you were going to expose it as a web service after the fact.

Second edit: I wanted to add that SOA principles themselves have nothing to do with web services. You can build services that are only exposed via their codified API.

2
Namphibian On

This is not quite correct. You are simulating contract first but you are still relying on the .Net framework to generate the WSDL. In contract first/WSDL first coding(top down) approach you author a WSDL file with a tool such as XML Spy etc. Then you generate the code from the WSDL. In your approach you are creating a WSDL from interfaces.

Using interfaces is the most successful way of doing this type of development however you are still doing the code first. Let me clarify that with an example. Typically in a SOA architecture developers follow the WSDL first approach. In the WSDL first approach you would typically submit your WSDL file for review by a SOA governance body in your company. This WSDL will then be measured against SOA governance policies to see if it fits. Once approved only then would code artifacts get generated.

What you are doing is not wrong but it is NOT contract first approach.