We have an e-commerce website that sells products and ultimately deliveries them. For this we have a PlaceOrder service which, among other parameters, expects an Address object that in this context (our website placing an order) is made of City, Street and ZipCode.
We also do business with partners that use our platform only to sell products. They take care of the delivery. For this scenario we have a PlaceOrderForPartner service that, among other objects, expects an Address object. However, in this context (partner placing an order) the Address object is made of different information that is relevant only to a order placed by partner.
In view of this situation, I have a few questions:
1) How to organize this DataContracts object in the namespace and folder in my solution? I considered providing a folder for each context (partners, customers, etc.) to store services and DataContracts.
So I will
- MySolution.sln
- Partner (folder)
- PartnetService.svc
- DataContracts (folder)
- Address
- Customer (folder)
- Customer .svc
- DataContracts (folder)
- Address
In this way, I will have a namespace to place all my context-specific data exchanges.
2) How about service design? I should create a service for everyone that may be placed, order and create a PlaceOrder method in it, as follows:
Partner.svc / PlaceOrder
Customer.svc / PlaceOrder
Or use PlaceOrderForPartner and PlaceInternalOrder to create an order service, as shown below:
Order.svc / PlaceOrderForPartner
Order.svc / PlaceOrderForCustomer
3) Suppose I am in the previous I chose the first option in the question. How should I handle the operations on the order and the joint operations between partners and customers?
4) Should I put DataContracts and Service definitions in the same assembly? Each one? Everything is implemented with the service?
5) How to name the input and output messages for the operation? Should I use the entity itself or use the OperationNameRequest and OperationNameResponse templates?
The most important thing is, my question is: How to “organize” the data exchange and services involved in service creation?
Thank you in advance for any thoughts on this!
< /p>
I like to build my WCF solution like this:
Contract (class library)
Contains all services, operations, faults and data contracts. It can be in pure .NET to .NET The solution is shared between the server and the client
Service implementation (class library)
Contains the code to implement the service, as well as any support/helper methods needed to achieve this purpose. There is nothing else.
Service host (optional-can be Winforms, Console App, NT Service)
Includes the service host for debugging/testing, or may also include the service host for production.
This basically gives me something on the server side.
On the client side:
Client proxy (class library)
I like to proxy my client Packaged into a separate class library so that they can be reused by multiple actual client applications. This can be done using svcutil or “add service reference” and manually adjusting the generated horrible app.config, or by using ClientBase
1-n actual clients (any type of application)
Usually only client proxy assemblies will be referenced, or contract assemblies may also be referenced if it is being shared. This can be ASP.NET, WPF, Winforms, console applications, other services-you can name it.
That; I have a nice and clean layout, I use it over and over again, I really think it makes my code cleaner and easier to maintain.
This is influenced by Miguel Castro’s Extreme WCF screen cast on DotNet Rocks TV and inspired by Carl Franklin – a highly recommended screen actor!
I started to design a wcf service bus that is now small, but it grows as our business grows, so I am worried about some problems and will not try too much YAGNI. This is an e-commerce platform. The problem is that I have too many ideas about where to put things. I will give a scene to show all my problems.
We have an e-commerce website that sells products and ultimately deliveries them. For this we have a PlaceOrder service which, among other parameters, expects an Address object that in this context (our website placing an order) is made of City, Street and ZipCode.
We also do business with partners that use our platform only to sell products. They take care of the delivery. For this scenario we have a PlaceOrderForPartner service that, among other objects, expects an Address object. However, in this context (partner placing an order) the Address object is made of different information that is relevant only to a order placed by partner.
In view of this situation, I have a few questions:
1) How to organize this DataContracts object in the namespace and folder in my solution ? I considered providing a folder for each context (partners, customers, etc.) to store services and DataContracts.
So I will
- MySolution.sln
- Partner (folder)
- PartnetService.svc
- DataContracts (folder)
- Address
- Customer (folder)
- Customer .svc
- DataContracts (folder)
- Address
In this way, I will have a namespace to place all my context-specific data exchanges.
2) How about service design? I should create a service for everyone that may be placed, order and create a PlaceOrder method in it, as follows:
Partner.svc / PlaceOrder
Customer.svc / PlaceOrder
Or use PlaceOrderForPartner and PlaceInternalOrder to create an order service, as shown below:
Order.svc / PlaceOrderForPartner
Order.svc / PlaceOrderForCustomer
3) Suppose I am in the previous I chose the first option in the question. How should I handle the operations on the order and the joint operations between partners and customers?
4) Should I put DataContracts and Service definitions in the same assembly? Each one? Everything is implemented with the service?
5) How to name the input and output messages for the operation? Should I use the entity itself or use the OperationNameRequest and OperationNameResponse templates?
The most important thing is, my question is: How to “organize” the data exchange and services involved in service creation?
Thank you in advance for any thoughts on this!
In addition to what TomTom mentioned, I also want to add 2 cents here:
I like to build mine like this WCF solution:
Contract (class library)
Contains all services, operations, faults and data contracts. It can be shared between the server and the client in a pure .NET to .NET solution
p>
Service Implementation (Class Library)
Contains the code to implement the service, and any support/helper methods needed to achieve this purpose. No other.
Service host (optional -It can be Winforms, Console App, NT Service)
Include the service host for debugging/testing, or it may also include the service host for production.
This basically gives me the server side Stuff.
On the client side:
Client agent (class library)
I like to package my client agent into a separate class library so that they can Reused by multiple actual client applications. This can be done using svcutil or “Add Service Reference” and manually adjust the generated terrible app.config, or by using ClientBase
1-n actual clients (any type of application)
Usually only the client proxy assembly will be referenced, or May refer to the contract assembly (if it is being shared). This can be ASP.NET, WPF, Winforms, console applications, other services-you can name it.
That way; I have a nice and clean I use it over and over again, and I really think it makes my code cleaner and easier to maintain.
This is influenced by Miguel Castro’s Extreme WCF screen cast on DotNet Rocks TV with Inspired by Carl Franklin-highly recommended screen actor!