【问题标题】:Setting the original WSDL with externalMetadataLocation doesn't work使用 externalMetadataLocation 设置原始 WSDL 不起作用
【发布时间】:2011-03-01 09:45:45
【问题描述】:

我正在使用 C# 在 Web 应用程序中构建 WCF Web 服务,并且由于我需要包含对某些 Xml 参数的架构验证,因此我想为在 @987654322 中使用 <xs:include schemaLocation="<schemafilename>.xsd"/> 的服务设置自定义 wsdl @节点。

我知道这样做的地方是

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

但我无法让它工作。让我感到困惑的是,即使我让服务生成自己的wsdl(即不设置属性),通过&lt;serviceurl&gt;/&lt;servicename&gt;.svc?wsdl访问生成的元数据,保存到文件然后将这个文件设置为externalMetadataLocation(使用..\&lt;wsdlfilename&gt;.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"
  • 是的,它会将我重定向到我的本地文件

标签: .net wcf wsdl


【解决方案1】:

我遇到了同样的问题,并发现这是因为 WCF WSDL 包含通过 Import 语句对外部 XSD 的引用。

我通过使用 WcfExtras.Codeplex.com 实现单个 WSDL 然后查看原始 WSDL 并将其复制到我的静态 WSDL 文件中解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-24
    • 2019-05-27
    • 1970-01-01
    • 2012-12-06
    • 2013-05-15
    • 2016-12-17
    • 1970-01-01
    相关资源
    最近更新 更多