Invoking a Web Service without using a Proxy by using WCF Adapter in BizTalk Server 2006 R2






4.64/5 (3 votes)
Invoking a Web Service without using a Proxy by using WCF adapter in BizTalk Server 2006 R2
Introduction - WCF Adapters for BizTalk Server 2006
The BizTalk Adapters for Windows Communication Foundation (WCF) allow Microsoft BizTalk Server 2006 R2 to communicate with WCF-based applications. The BizTalk WCF adapters include five physical adapters that represent the WCF predefined bindings.
The screen shot below depicts the list of WCF Biztalk adapters on the Biztalk Server 2006 R2 Server:
The TASK at Hand
In this article, we shall invoke a Web Service using the WCF adapter, but without using a web service proxy which is done typically. This can be any web service which has a WSDL file to describe itself.
Understanding the Solution Structure
The screen shot below shows the solution structure:
EmployeeSchemas
- A BizTalk project which holds all the internal domain specific schemas. This has no references to any other project.ProcessEmployee
- A BizTalk project which contains an orchestration to process internal domain specific schemas, this has no knowledge about the web service schemas to be invoked.EmployeeMaps
- A BizTalk project which holds all the web service specific schemas and maps. This of course would have references to domain specific schemas. The maps are used to transform the domain specific message into a web service request message and vice versa.
Using the WCF Adapter Wizard
Once the Web Service is setup and running, right click on the BizTalk Project, select "Add" -> "Add Generated Items..." and select "Consume WCF Service". Follow the screen shots below...
- Select Metadata exchange point and select the web service end point.
- Specify the web service URL address to generate the WSDL.
- Finally specify the namespace and click finish to generate the schemas.
The following files would be generated by the WCF wizard:
EmployeeInfoServicePort.BindingInfo.xml - For transport type : WCF-BasicHttp
EmployeeInfoServicePort.odx
EmployeeInfoServicePort_Custom.BindingInfo.xml - For transport type : WCF-Custom
EmployeeInfoServicePort_org_naveen_employee.xsd
Open the file EmployeeInfoServicePort.BindingInfo.xml and note the 'Operation name' which is RetrieveEmployeeInfo
. This must match the Send Port operation name. Observe the screen shot below for more clarity:
NOTE: The orchestration (*.odx) file and the WCF-Custom binding which were auto-generated can be safely deleted.
Configure the Maps in the WCF Send Port
Once the orchestration has been coded and deployed, import the bindings file which has been auto generated. This would generate a WCF send port. Now specify the maps which convert the message from domain-specific into a web service request using the send port 'Filters and Maps' section. Observe the screen show below.
Common WCF Adapter - Error Condition
Consuming BizTalk WCF Service Adapter Wizard: Object reference not set to an instance of an object.
Resolution
This happens when no target namespace is specified for a schema tag in the WSDL. Open the WSDL file, observe the tag xsd:schema
and add the attribute targetNamespace
.
<xsd:schema targetNamespace="http://com.naveen.employee">
...
</xsd:schema>
Takeaways
- We have separated the web services schemas from the domain specific schemas. The orchestration has no knowledge of the web service schemas.
- Using the Send Port maps, the web service end point and the schemas can be changed without re-deploying/modifying/recoding/recompiling the orchestration.
History
- 4th March, 2009: Initial post