LCJ
LCJ

Reputation: 22662

Project structure for Schema First Service Development using WCF

I have WSDL and XSD as starting point. (WSDL is generated from XSD using WCSF Blue tool). From the WSDL, using a tool, the service code is generated. The project name is “Autogenerated_Service_Project”. Inside this project it will have [ServiceContract] and [DataContract] classes. It has a data contract named “EmployeeDataContract”. In the GetEmployee() service operation, this datacontract is returned to the client.

I have a business layer project named “Business_Project”. It has a method that returns “Employee” entity object.

At present, I am referring the “Business_Project” inside “Autogenerated_Service_Project”.

Business_Project.MyClass b = new Business_Project.MyClass();
EmployeeDataContract d = b.GetAssociate();
return EmployeeDataContract;

The challenge comes when there happens a change in WSDl. When the WSDL is the changed the “Autogenerated_Service_Project” will be recreated and the code mentioned above will be lost.

What is the solution to overcome this code lose?

Note: The “Autogenerated_Service_Project” is the top most project. Ideally, it cannot be referred by any other projects.

Upvotes: 1

Views: 144

Answers (2)

LCJ
LCJ

Reputation: 22662

This can be resolved by using Partial Classes in a different file. The code given in the question can be moved to this new partial class file. This file will persist even if the auto generated file is re-created.

Upvotes: 1

Mohsen Heydari
Mohsen Heydari

Reputation: 7284

You may change the way calling Business layer(may your solution needs additional layer)
But in simple way, you can generate the proxy once, when changes happen to WSDL handle the changes manually,Or use the tool only for new services.
If the services on WSDL are finely grained, the solution may be applicable.

Upvotes: 2

Related Questions