Monday, 6 August 2012

Difference between Publishing orchestration as wcf service and schema as wcf service

Publishing an orchestration as a WCF Service leads to tight coupling. Whereas publishing schema as a WCF Service achieves loose coupling.

When an orchestration is published as a WCF Service, the data (message) received via the WCF Service will be directly bound the Orchestration which is published.

On the other hand when a schema is published as a WCF Service, the data (BizTalk message) received via the WCF Service will be published to the BizTalk Server Message Box and hence any number of subscribers can subscribe for the message.
When we expose an orchestration as a WCF service, it means we should execute the orchestration by calling the WCF service from client with the parameter message payload same as what the orchestration receive shape expects. The message payload is received by message box first and the subscribing orchestration instance then gets fired and the 'processing' takes place very much similar to what happens inside the method of a WCF service which is decorated with [OperationContract] attribute.
Now when a schema is exposed as a WCF service, it gives rise to a very loosely coupled pattern. Here only the schema is coupled, which is the contract of the 'contract first' approach. Here no 'processing' like orchestration is yet defined, which means, any orchestration can subscribe to the message payload received from the message box, when the WCF service is called by client. Here the loose coupling comes from the fact that we can simply make any, just any orchestration to subscribe to that message. Whereas, while you expose an orchestration as WCF service, you essentially mean to use that orchestration alone, a tighter coupling scenario.
Now the thing is after you expose certain schemas as WCF service, then when you add reference to the .svc file from your client application then appropriate proxy classes are created in the wsdl wherein all the types you declared are already available. This also happens when you consume the WCF service from another orchestration by saying "Add Generated Items --> Consume WCF service" eventually going through the WCF service consuming wizard. The types with appropriate namespaces would be automatically available to you and you need to populate the objects from your client code and call the service by submitting the payload

No comments:

Post a Comment