【发布时间】:2011-03-01 09:45:45
【问题描述】:
我正在使用 C# 在 Web 应用程序中构建 WCF Web 服务,并且由于我需要包含对某些 Xml 参数的架构验证,因此我想为在 @987654322 中使用 <xs:include schemaLocation="<schemafilename>.xsd"/> 的服务设置自定义 wsdl @节点。
我知道这样做的地方是
<serviceMetadata externalMetadataLocation="<wsdlfilename>.wsdl"/>
但我无法让它工作。让我感到困惑的是,即使我让服务生成自己的wsdl(即不设置属性),通过<serviceurl>/<servicename>.svc?wsdl访问生成的元数据,保存到文件然后将这个文件设置为externalMetadataLocation(使用..\<wsdlfilename>.wsdl)。 WcfTestClient 给了我这个:
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 data contracts from schemas make sure to use the /dataContractOnly
option.
有时它会给我带来更复杂的错误,比如
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']
我对 xml 命名空间还不是很熟练,所以它也可能是关于它们的一些东西,但我已经尝试过使用和不使用命名空间,所以我很茫然
谢谢
【问题讨论】:
-
如果您使用外部元数据,您可以从浏览器访问 WSDL 吗? (您必须设置
httpGetEnabled="true") -
是的,它会将我重定向到我的本地文件