Tuesday, 2 November 2010

Object reference not set to an instance of an object – BizTalk WCF Service Consuming Wizard

While consuming a WCF Service using BizTalk WCF Service Consuming Wizard you may end up with an error..

“Error consuming WCF service metadata.

Object reference not set to an instance of an object”



One possible reason for this issue is that the WSDL Generated after consuming the Service might not have any namespace for the schema to be imported.

This can be resolved in simple steps as below.

  1. Generate the metadata for the Service using Svcutil.exe as given below.

  2. C:\>svcutil /target:metadata <WCF Service Address>
  3. The above command will generate the Wsdl file and XML Schema file.

  4. Copy the Target namespace from the XML Schema file (.xsd file) and paste it in the <xsd:schema> node of the wsdl file.

  5. The Resultant <xsd:schema> node of the wsdl file should look some thing like this. <xsd:schema targetNamespace="http://Something.com">

  6. Now run the BizTalk WCF Service Consuming Wizard and select the second option.

  7. Add both the wsdl and schema file to the Wizard.

  8. Import should now be successful.


Post your comments if any has an alternate solution.
- Shiv



Web Counters

No comments:

Post a Comment