如果架构位置为WSDL中的相对路径,则无法解析Webservice XSD文件

时间:2018-06-18 19:42:37

标签: c# xsd wsdl

我正在使用WCF代理生成代码来解析WSDL文件。在指定为相对路径的WSDL架构位置中,我在同一文件夹中托管了WSDL和XSD文件,并在默认网站下的IIS中进行了配置。但是代码会抛出错误。

The document was understood, but it could not be processed.
  - The WSDL document contains links that could not be resolved.
  - There was an error downloading 'file:///C:/Windows/TEMP/UserService.xsd'.
  - Could not find file 'C:\Windows\TEMP\UserService.xsd'.
  - Could not find file 'C:\Windows\TEMP\UserService.xsd'.
  - Could not find file 'C:\Windows\TEMP\UserService.xsd'.

WSDL的一部分如下所示

在WSDL文件中,它指的是使用相对位置的外部UserService.xsd:

<xsd:import namespace="http://document.webservice.business.cav" schemaLocation="UsweService.xsd">

但是,即使XSD文件与WSDL文件位于同一位置,它也不会解析WSDL文件。

如果我修改schemaLocation而没有相对路径,我就能生成代理dll。

代码段

//首先下载合同(如果通过网络访问)。                 DownloadContract(选项);

            // Try to run RPC2DocumentLiteral converter.
            TryTranslateRpc2DocumentLiteral(options);
            MetadataSet metadataSet = new MetadataSet();
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(options.MetadataLocation);
            MetadataSection ms = new MetadataSection(null, null, doc);
            metadataSet.MetadataSections.Add(ms);
            ResolveImports(options, metadataSet);
        // Resolve metadata using a DiscoveryClientProtocol.
        DiscoveryClientProtocol dcp = new DiscoveryClientProtocol();
        try
        {
            dcp.Credentials = options.Credentials;
            dcp.AllowAutoRedirect = true;
            dcp.DiscoverAny(options.MetadataLocation);   Code failing with above error
            dcp.ResolveAll();
           ----

有人可以帮我这方面。

拉​​马

0 个答案:

没有答案
相关问题