开发者

Setting the original WSDL with externalMetadataLocation doesn't work

I'm building a WCF web service inside a Web Application with C#, and since I need to include schema validation for some Xml parameters I want to set a custom wsdl for the service where I use <xs:include schemaLocation="<schemafilename>.xsd"/> inside the <wsdl:types> node.

I've learned that the place to do this is

<serviceMetadata externalMetadataLocation="<wsdlfilename>.wsdl"/>

but I can't get it to work. What baffles me is that it doesn't work even if I let the service generate its own wsdl (that is, not setting the attribute), access the generated metadata through <serviceurl>/<servicename>.svc?wsdl, save it to a file and then set this file as the externalMetadataLocation (using ..\<wsdlfilename>.wsdl). WcfTestClient gives me this:

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 servicesor
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 dat开发者_如何学Pythona contracts from schemas make sure to use the /dataContractOnly
option.

Sometimes it gives me more complicated errors, like

Error: Cannot import wsdl:port
Detail: Cannot find definition for http://tempuri.org/:BasicHttpBinding_IProcessi.  Service Description with namespace http://tempuri.org/ is missing.Parameter name: name
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.archinet.it/HRSuite/Processi/']/wsdl:service[@name='Processi']/wsdl:port[@name='BasicHttpBinding_IProcessi']

Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter

Error: Schema with target namespace 'http://www.archinet.it/HRSuite/Processi/' could not be found.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.archinet.it/HRSuite/Processi/']/wsdl:portType[@name='IProcessi']

I'm not really all that skilled with xml namespaces yet, so it might as well be something about them, but I've tried both with and without namespaces, so I'm at a loss

Thank you


I had the same issue and figured out that it was because WCF WSDL's contain references to external XSD's via the Import statement.

I resolved the issue by implementing a single WSDL using WcfExtras.Codeplex.com then viewing the original WSDL and copying that into my static WSDL file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜