As per the following MSDN article: http://msdn.microsoft.com/en-us/library/aa561724.aspx, while consuming the WCF service in BizTalk Server, The Add Service Reference does not support the Web Service Description Language (WSDL) import element.
Please Note that while we follow the above statement and recommend you not to use the import statement in the wsdl of the web/WCF services, here is the workaround for consuming such services.
Let us begin with the basics.
Import statement in WSDL
The import statement is used to import other WSDL documents or XML schemas into your WSDL document. This enables you to have more modular WSDL documents. For E.g. if you have a WCF service, then you can have a Service.wsdl which will import the Binding.wsdl which in turn imports Contract.wsdl.
The syntax would look like:
<wsdl:import namespace=”http://www.abc.com” location=”./Contract.wsdl” />
This would optimize your wsdls in terms of reusability but could cause problem while consuming in BizTalk Server.
Consuming WCF Service in BizTalk Server
We can consume WCF service in BizTalk Server by using BizTalk WCF Service Consuming Wizard. We need to follow the given steps:
- Add Generated Items
- Consume WCF Service
- In the WCF Wizard, select the Metadata files option
When you add the Service.wsdl using the Metadata files option, you will not see any of the artifact getting created as the Binding.wsdl and Contract.wsdl are still missing.
Therefore, in order to get all the metadata associated with a given WSDL, use the svcutil.exe tool.
Go to visual studio command prompt and type svcutil /t:metadata
You will get all the metadata associated with the WCF Service.
Now, go back to the WCF Service Consuming Wizard, select the Metadata files option.
Add all the metadata that is present in the service.
Now you would be able to see all the artifacts that are present in the service and would be able to consume the service successfully.
A new feature has been added in WCF 4.5 – Flat WSDL support. Enable the metadata like you do for enabling the serviceMetaData attribute for a 4.5 service. After this you will see the following additional link on the metadata page.
For more details, please refer to the following msdn blog:http://blogs.msdn.com/b/piyushjo/archive/2011/10/05/what-s-new-in-wcf-4-5-flat-wsdl-support.aspx
While working on this, we came across the following error:
Error consuming WCF service metadata. Port types that have a combination of one-way and request-response operations are not allowed. Correct service description http://www.abc.com/ port type “Port2” and rerun the wizard.
When we consume a service which contains both one way and a two way (request-response port) ports, the WCF service consuming wizard will give the following error:
Jainath V R
Microsoft India GTSC