Thursday, 31 December 2015

BizTalk Published Service SingleWSDL -schemaLocation is missing , Cannot import wsdl:portType

Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: The required attribute 'schemaLocation' is missing.

I have been publishing number WCF services using BizTalk Schema's  and I never encountered any issues when end client generating a proxy class using  direct service url  or singlewsdl url.

Recently one  of my client had an issue with service which I recently published. I was really skeptical about the issue and I was keep asking him to try different ways, in fact I requested to use new .net SDK to use it.


after course of attempts I realized that service was throwing an unknown error as below


Attempting to download metadata from 'http://ccrsd027.stl.int/PublishSchemaTestService/PublishTest.svc?singleWsdl' using WS-Metadata Exchange or DISCO.
Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: The required attribute 'schemaLocation' is missing.XPath to Error Source: //wsdl:definitions[@targetNamespace='http://PublishSchema.Test/']/wsdl:portType[@name='PublishTest']


Error: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://PublishSchema.Test/']/wsdl:portType[@name='PublishTest']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://PublishSchema.Test/']/wsdl:binding[@name='WSHttpBinding_ITwoWayAsync']


Error: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://PublishSchema.Test/']/wsdl:binding[@name='WSHttpBinding_ITwoWayAsync']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://PublishSchema.Test/']/wsdl:service[@name='BizTalkServiceInstance']/wsdl:port[@name='WSHttpBin
ding_ITwoWayAsync']


Generating files...
Warning: No code was generated.
If you were trying to generate a client, this could be because the metadata documents did not contain any valid contracts or services
or because all contracts/services were discovered to exist in /reference assemblies. Verify that you passed all the metadata documents to the tool.

Warning: If you would like to generate data contracts from schemas make sure touse the /dataContractOnly option.


The root cause of the above problem was I had a Common Types schema which I included for my Generic complex types schema

When you Generate a SingleWSDL SVCUTIL tool generates a single WSDL File which includes all referenced schema's. however the Included schema's does not work when you generate a Proxy class using SvcUtil.exe.

The Fix is very simple:
Generate a Single WSDL file and open in Note pad (NotePad++) and identify a schema which you originally included a schema and simply Delete the auto generated empty include node 

and save the wsdl and try SvcUtil.exe "UpdatedSinglewsdl.wsdl"
Drop a comment if this article helps you. you can reach me @ raj.webjunky@yahoo.com

No comments:

Post a Comment