On one of the projects we were doing, we needed to migrate the BizTalk 2006 R2 applications to BizTalk 2010.
This gave us the chance to change the running SOAP BizTalk services to WCF services. These services have more capabilities and are easier to configure.
We only had one restriction: the clients may not be forced to change. After some searching on the web, I found following post:
http://maximelabelle.wordpress.com/2010/08/12/creating-soap-compatible-biztalk-wcf-services/ and I like to share it with you.
First of all, I will explain how to expose a schema as a WCF Service;
Expose a Schema as a WCF Service
To create a WCF-service, use the BizTalk WCF Service Publishing Wizard. You can find it in the BizTalk Server 2010 folder at the Windows start menu.
With this wizard you can set up the service endpoint.
You can choose between WCF-BasicHttp, WCF-WSHttp and WCF-CustomIsolated as a transport type and choose the application where you want to create the receive location in BizTalk.
At the next step you get the choice to choose if you want to expose an orchestration or a schema as a WCF Service. In our case we will choose the schema choice.
The wizard gives you a tree of service methods, operations and request-response. Here you can add methods and one- or two-way operations. Define the schema type for your request and/or response from an assembly.
Fill in the target namespace of the WCF Service and choose the host and web directory where the service will be reachable.
The last step is a summary of the service you are going to create.... congratulations, you have created a WCF Service in BizTalk!
A new site is created in IIS and a receive location has been created for this service. The URI property refers to the address of the site in IIS.
Look also at the Receive Handler which is the BizTalkServerIsolatedHost. This means that this port is running under IIS.
Check if the receive location is started and if the Application pool of the site has the correct identity to work with BizTalk.
If you try to browse to the site and receive a login error then you have to give the application pool the correct identity.
If after browsing to the site and you receive the following screen, you have created a WCF service with success.
Change the Service to be able to communicate with the old SOAP-clients
First thing you need to do, is download the WSDL of the old SOAP Service and store it in the same folder of your SVC-file.
Open the WSDL and change the address location to the URI of the SVC-service.
When you look in the folder where the SVC-file is situated, there is also a web.config file of the service.
Load this web.config file in the WCF Service Configuration Editor for easy modifying.
Go to the advanced tab and open the Service Behavior. Open the configuration and in the Service Metadata\ExternalMetadataLocation you have to add the path to the old WSDL. Save the config and close the configuration editor.
Now if you go to the service you will see that the URL of the WSDL has changed, also the WSDL itself now refers to the old one.
For the last step, you will need to change the Inbound BizTalk message body and the outbound WCF message Body.
The old ASMX message has one node more than a WCF envelope. You have to tell BizTalk were to get the find the message in the received envelope.
Open the settings of the receive location and click on configure, go to the message Tab. In the Inbound BizTalk message body check the path option and use the xpath '”/*/*” to go to the child node of the received message.
For the outboundWCF message body you need to wrap your message in an extra node because the client is demanding an extra Operation node as a wrapper. You also have to give this node the service namespace.
Restrictions, this pattern can only be used when you have a service that only has one operation due to the wrapper element you have to declare in the outbound WCF message body.
Hope this helps.
- Robert Maes