如何确定要在 svcutil 命令行中包含哪些架构文件 (xsd)?

发布于 2024-10-17 10:07:54 字数 1963 浏览 1 评论 0原文

使用 svcutil,我尝试为 web 生成代理类遵循 OGC CSW 2.0.2 (07-006r1) 的服务端点目录服务标准。

我已经下载了整个OGC架构文件并将它们放入我的“D:/temp/OGCSchemas” /”目录。

我感兴趣的模式是 CSW,但是 CSW 模式包含并导入其他模式,这就是我下载整个集的原因。

例如,您将看到类似这样的内容:

<wsdl:import namespace="http://www.opengis.net/cat/csw/2.0.2/requests" location="./xml-interfaces.wsdl"/>
<xsd:schema targetNamespace="http://www.opengis.net/cat/csw/2.0.2" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" version="2.0.2">
    <xsd:include schemaLocation="../../csw/2.0.2/CSW-discovery.xsd"/>
    <xsd:include schemaLocation="../../csw/2.0.2/CSW-publication.xsd"/>
</xsd:schema>

到目前为止,我的命令行看起来像:

svcutil D:\temp\OGCSchemas\csw\2.0.2\examples\wsdl\2.0.2\*.wsdl D:\temp\OGCSchemas\csw\2.0.2\*.xsd D:\temp\OGCSchemas\filter\1.1.0\*.xsd D:\temp\OGCSchemas\ows\1.0.0\*.xsd /out:D:\temp\ogc.csw.proxy.cs

但我收到了许多类似这样的错误:

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://www.opengis.net/cat/csw/2.0.2/soap']/wsdl:binding[@name='csw-SO
AP']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.opengis.net/cat/csw/2.0.2/wsdl']/wsdl:service[@name='CSW']/
wsdl:port[@name='csw-SOAP-Port']

我相信此错误告诉我在命令行中包含更多 xsd。

所以我的问题是:如何确定要在命令行中包含哪些 xsd?

我以为我已经为它包含的每个目录包含了 *.xsd,但显然没有。

编辑#1 包含 xsd 文件时有哪些规则?是否必须添加所有导入或包含的文件?有了这么大的模式,我想我需要构建一个工具来找到它们。

Using svcutil, I'm trying to generate a proxy class for a web service endpoint which follows the OGC CSW 2.0.2 (07-006r1) standard for catalog services.

I've downloaded the entire OGC schema files and placed them into my "D:/temp/OGCSchemas/" Directory.

The schema i'm interested in is CSW, however CSW schema includes and imports other schemas and that's why i've downloaded the entire set.

For example you will see something like this:

<wsdl:import namespace="http://www.opengis.net/cat/csw/2.0.2/requests" location="./xml-interfaces.wsdl"/>
<xsd:schema targetNamespace="http://www.opengis.net/cat/csw/2.0.2" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" version="2.0.2">
    <xsd:include schemaLocation="../../csw/2.0.2/CSW-discovery.xsd"/>
    <xsd:include schemaLocation="../../csw/2.0.2/CSW-publication.xsd"/>
</xsd:schema>

My command line so far looks like:

svcutil D:\temp\OGCSchemas\csw\2.0.2\examples\wsdl\2.0.2\*.wsdl D:\temp\OGCSchemas\csw\2.0.2\*.xsd D:\temp\OGCSchemas\filter\1.1.0\*.xsd D:\temp\OGCSchemas\ows\1.0.0\*.xsd /out:D:\temp\ogc.csw.proxy.cs

But I'm getting many errors that look like this:

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://www.opengis.net/cat/csw/2.0.2/soap']/wsdl:binding[@name='csw-SO
AP']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.opengis.net/cat/csw/2.0.2/wsdl']/wsdl:service[@name='CSW']/
wsdl:port[@name='csw-SOAP-Port']

I believe this error is telling me to include more xsds in my command line.

So my question is: How do i determine which xsds to include in my command line?

I thought i'd included a *.xsd for every directory that it was including from, but obviously not.

EDIT #1
What are the rules when including xsd files? Must all files that are imported or included be added? With such a big schema, I'm thinking i'm going to need to build a tool to find them all.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ζ澈沫 2024-10-24 10:07:54

不确定这是否是正确的方法,但我创建了一个程序,该程序将遍历架构并通过遵循所有“xs:import”、“wsdl:import”、“xsd:include”为我创建命令行"、"xsd:import" 和递归地"include" xml 元素。

我最终得到了以下命令行,最终生成了代码。但代码太小了。还是有什么问题。但至少我能够确定命令行中包含哪些文件。

命令行:

svcutil D:\temp\OGCSchemas\csw\2.0.2\http-binding.wsdl D:\temp\OGCSchemas\csw\2.0.2\xml-interfaces.wsdl D:\temp\OGCSchemas\csw\2.0.2\responses.wsdl D:\temp\OGCSchemas\csw\2.0.2\CSW-discovery.xsd D:\temp\OGCSchemas\csw\2.0.2\CSW-publication.xsd D:\temp\OGCSchemas\ows\1.0.0\owsExceptionReport.xsd D:\temp\OGCSchemas\csw\2.0.2\record.xsd D:\temp\OGCSchemas\ows\1.0.0\owsAll.xsd D:\temp\OGCSchemas\filter\1.1.0\filter.xsd D:\temp\OGCSchemas\csw\2.0.2\rec-dcterms.xsd D:\temp\OGCSchemas\csw\2.0.2\rec-dcmes.xsd D:\temp\OGCSchemas\ows\1.0.0\owsGetCapabilities.xsd D:\temp\OGCSchemas\filter\1.1.0\expr.xsd D:\temp\OGCSchemas\filter\1.1.0\sort.xsd D:\temp\OGCSchemas\filter\1.1.0\filterCapabilities.xsd D:\temp\OGCSchemas\gml\3.1.1\base\geometryAggregates.xsd D:\temp\OGCSchemas\ows\1.0.0\owsServiceIdentification.xsd D:\temp\OGCSchemas\ows\1.0.0\owsServiceProvider.xsd D:\temp\OGCSchemas\ows\1.0.0\owsOperationsMetadata.xsd D:\temp\OGCSchemas\gml\3.1.1\base\geometryPrimitives.xsd D:\temp\OGCSchemas\ows\1.0.0\owsDataIdentification.xsd D:\temp\OGCSchemas\ows\1.0.0\ows19115subset.xsd D:\temp\OGCSchemas\ows\1.0.0\owsCommon.xsd D:\temp\OGCSchemas\gml\3.1.1\base\geometryBasic2d.xsd D:\temp\OGCSchemas\gml\3.1.1\base\geometryBasic0d1d.xsd D:\temp\OGCSchemas\gml\3.1.1\base\measures.xsd D:\temp\OGCSchemas\gml\3.1.1\base\units.xsd D:\temp\OGCSchemas\gml\3.1.1\base\dictionary.xsd D:\temp\OGCSchemas\gml\3.1.1\base\gmlBase.xsd D:\temp\OGCSchemas\gml\3.1.1\base\basicTypes.xsd D:\temp\OGCSchemas\xlink\1.0.0\xlinks.xsd /out:D:\temp\ogc.csw.proxy.cs

但它生成的代码太小:

[assembly: System.Runtime.Serialization.ContractNamespaceAttribute("http://www.opengis.net/ows", ClrNamespace="www.opengis.net.ows")]
namespace www.opengis.net.ows
{
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    [System.Xml.Serialization.XmlSchemaProviderAttribute("ExportSchema")]
    [System.Xml.Serialization.XmlRootAttribute(IsNullable=false)]
    public partial class ExceptionReport : object, System.Xml.Serialization.IXmlSerializable
    {
        private System.Xml.XmlNode[] nodesField;
        private static System.Xml.XmlQualifiedName typeName = new System.Xml.XmlQualifiedName("ExceptionReport", "http://www.opengis.net/ows");
        public System.Xml.XmlNode[] Nodes
        {
            get
            {
                return this.nodesField;
            }
            set
            {
                this.nodesField = value;
            }
        }
        public void ReadXml(System.Xml.XmlReader reader)
        {
            this.nodesField = System.Runtime.Serialization.XmlSerializableServices.ReadNodes(reader);
        }

        public void WriteXml(System.Xml.XmlWriter writer)
        {
            System.Runtime.Serialization.XmlSerializableServices.WriteNodes(writer, this.Nodes);
        }

        public System.Xml.Schema.XmlSchema GetSchema()
        {
            return null;
        }
        public static System.Xml.XmlQualifiedName ExportSchema(System.Xml.Schema.XmlSchemaSet schemas)
        {
            System.Runtime.Serialization.XmlSerializableServices.AddDefaultSchema(schemas, typeName);
            return typeName;
        }
    }
}

Not sure if this was the right way to go about it, but i created a program that would go through the schema and create my command line for me by following all "xs:import", "wsdl:import", "xsd:include", "xsd:import", and "include" xml elements recursively.

I ended up with the following command line which finally got generating code. But the code is way to small. Something is still wrong. But at least i was able to determine what files to include in the command line.

command line:

svcutil D:\temp\OGCSchemas\csw\2.0.2\http-binding.wsdl D:\temp\OGCSchemas\csw\2.0.2\xml-interfaces.wsdl D:\temp\OGCSchemas\csw\2.0.2\responses.wsdl D:\temp\OGCSchemas\csw\2.0.2\CSW-discovery.xsd D:\temp\OGCSchemas\csw\2.0.2\CSW-publication.xsd D:\temp\OGCSchemas\ows\1.0.0\owsExceptionReport.xsd D:\temp\OGCSchemas\csw\2.0.2\record.xsd D:\temp\OGCSchemas\ows\1.0.0\owsAll.xsd D:\temp\OGCSchemas\filter\1.1.0\filter.xsd D:\temp\OGCSchemas\csw\2.0.2\rec-dcterms.xsd D:\temp\OGCSchemas\csw\2.0.2\rec-dcmes.xsd D:\temp\OGCSchemas\ows\1.0.0\owsGetCapabilities.xsd D:\temp\OGCSchemas\filter\1.1.0\expr.xsd D:\temp\OGCSchemas\filter\1.1.0\sort.xsd D:\temp\OGCSchemas\filter\1.1.0\filterCapabilities.xsd D:\temp\OGCSchemas\gml\3.1.1\base\geometryAggregates.xsd D:\temp\OGCSchemas\ows\1.0.0\owsServiceIdentification.xsd D:\temp\OGCSchemas\ows\1.0.0\owsServiceProvider.xsd D:\temp\OGCSchemas\ows\1.0.0\owsOperationsMetadata.xsd D:\temp\OGCSchemas\gml\3.1.1\base\geometryPrimitives.xsd D:\temp\OGCSchemas\ows\1.0.0\owsDataIdentification.xsd D:\temp\OGCSchemas\ows\1.0.0\ows19115subset.xsd D:\temp\OGCSchemas\ows\1.0.0\owsCommon.xsd D:\temp\OGCSchemas\gml\3.1.1\base\geometryBasic2d.xsd D:\temp\OGCSchemas\gml\3.1.1\base\geometryBasic0d1d.xsd D:\temp\OGCSchemas\gml\3.1.1\base\measures.xsd D:\temp\OGCSchemas\gml\3.1.1\base\units.xsd D:\temp\OGCSchemas\gml\3.1.1\base\dictionary.xsd D:\temp\OGCSchemas\gml\3.1.1\base\gmlBase.xsd D:\temp\OGCSchemas\gml\3.1.1\base\basicTypes.xsd D:\temp\OGCSchemas\xlink\1.0.0\xlinks.xsd /out:D:\temp\ogc.csw.proxy.cs

But the code that it generates is way to small:

[assembly: System.Runtime.Serialization.ContractNamespaceAttribute("http://www.opengis.net/ows", ClrNamespace="www.opengis.net.ows")]
namespace www.opengis.net.ows
{
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    [System.Xml.Serialization.XmlSchemaProviderAttribute("ExportSchema")]
    [System.Xml.Serialization.XmlRootAttribute(IsNullable=false)]
    public partial class ExceptionReport : object, System.Xml.Serialization.IXmlSerializable
    {
        private System.Xml.XmlNode[] nodesField;
        private static System.Xml.XmlQualifiedName typeName = new System.Xml.XmlQualifiedName("ExceptionReport", "http://www.opengis.net/ows");
        public System.Xml.XmlNode[] Nodes
        {
            get
            {
                return this.nodesField;
            }
            set
            {
                this.nodesField = value;
            }
        }
        public void ReadXml(System.Xml.XmlReader reader)
        {
            this.nodesField = System.Runtime.Serialization.XmlSerializableServices.ReadNodes(reader);
        }

        public void WriteXml(System.Xml.XmlWriter writer)
        {
            System.Runtime.Serialization.XmlSerializableServices.WriteNodes(writer, this.Nodes);
        }

        public System.Xml.Schema.XmlSchema GetSchema()
        {
            return null;
        }
        public static System.Xml.XmlQualifiedName ExportSchema(System.Xml.Schema.XmlSchemaSet schemas)
        {
            System.Runtime.Serialization.XmlSerializableServices.AddDefaultSchema(schemas, typeName);
            return typeName;
        }
    }
}
烟火散人牵绊 2024-10-24 10:07:54

前几天我处理过这个问题。最简单的方法是在 IIS 中设置它们并修改主机文件以将这些地址指向您的本地主机。然后在主 wsdl 文件上使用 XSD,一切都会好起来的。

我确信有更好的方法,但几个小时后这就是我最终所做的。

您可以尝试修改名称空间,但这对我来说不起作用,而且您必须为所有文件修改它们,这真是太痛苦了。

I dealt with this the other day. The easiest way is to set them up in IIS and modify your hosts file to point those addresses to your localhost. Then use XSD on the main wsdl file and all will be good.

I'm sure there is a better way but after a few hours that is what I ended up doing.

you can try to modify the namespaces, but that didn't work for me plus you';d have to modify them for all files and thats such a pain.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文