This is the fifth post in this series, you can find the landing page here.
The code for this step of the series can be downloaded here.
So, in the previous posts we created both the data, service and fault models.
In fact, all we've done is created abstract definitions of how we want our code to look like.
So the next thing to do is to choose the implementation technology to use for these services.
For the purposes of this series I'm going with WCF implementation.
Add a project
Right click the solution and choose Add\WCF implementation project
When clicking OK in this dialog, visual studio adds a number of projects to the solution, giving you a solution explorer like:
Configure the modelsNext step in the generation of code is to configure the models you've created to use WCF and to set the generation target projects. Open the three diagrams, set the properties of each diagram as per the image below and save all. Afterwards, right click and select validate all.
Validation errors
So, after validation you should have 32 errors!
While this may seem a bit wtf, it's quite normal and I've hinted at the source of these errors before (see data model).
My point was to address these points only after making the choice between WCF and ASMX implementation
First off, let's go and fix the errors:
Data model
- error: All the datamembers in the datacontract class '...' must have a Unique 'Order' property.
right click inside the Model diagram and choose "Order all DataMembers", afterwards right click and select validate all
Service model
- error: you must use the DataContractSerializer on the service contract model...
in the properties of the service model, set the serializer to Data contract serializer - error: The message '...' cannot have the property 'IsWrapped' set to false and contain more than one message part
select the appropriate message and set IsWrapped to true
After these corrections, you should have no more errors and you can continue to generate the code (right click the model and select generate code).
Generated code
Now, take a moment to bask in the light of generated code ;)
0 comments:
Post a Comment