1

我想从 wsdl 和一些 xsd 文件生成代理类 (C#)。wsdl 和 xsd 文件都位于我磁盘上的同一个文件夹中。我发出的命令是:

svcutil.exe AuthenticateAndGetAssertionsSOAP12v2.wsdl .xsd /t:code /l:cs /o:AuthAndGetAssertionsProxy.cs /n: ,TestNamespace

但未生成代理类,我收到此错误:

如果包含 -annotation- 以外的任何子项,则“SchemaLocation”必须成功解析。

svcutil 还指出有问题的文档 ID 是http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd

其中一个 xsd 文件确实有效地重新定义了在此命名空间中定义的 complexType,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
    <xs:redefine schemaLocation="oasis-200401-wss-wssecurity-secext-1.0.xsd">
        <xs:complexType name="UsernameTokenType">
            <xs:complexContent>
                <xs:extension base="UsernameTokenType">
                    <xs:sequence>
                        <xs:element name="NewPassword" type="xs:base64Binary"/>
                    </xs:sequence>
                </xs:extension>
            </xs:complexContent>
        </xs:complexType>
    </xs:redefine>
</xs:schema>

我尝试像这样完全限定 schemaLocation URI:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
       <xs:redefine schemaLocation="file:///C:/AuthAndGetAssertionsSOAP12v2/oasis-200401-wss-wssecurity-secext-1.0.xsd">    
       <xs:complexType name="UsernameTokenType">
            <xs:complexContent>
                <xs:extension base="UsernameTokenType">
                    <xs:sequence>
                        <xs:element name="NewPassword" type="xs:base64Binary"/>
                    </xs:sequence>
                </xs:extension>
            </xs:complexContent>
        </xs:complexType>
    </xs:redefine>
</xs:schema>

其中 C:\AuthAndGetAssertionsSOAP12v2 是 wsdl 和 xsd 文件的实际路径,但我仍然无法正常工作。

作为参考,这是在 oasis-200401-wss-wssecurity-secext-1.0.xsd 中定义 complexType UsernameTokenType 的方式:

<xsd:complexType name="UsernameTokenType">
        <xsd:annotation>
            <xsd:documentation>This type represents a username token per Section 4.1</xsd:documentation>
        </xsd:annotation>
        <xsd:sequence>
            <xsd:element name="Username" type="wsse:AttributedString"/>
            <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:attribute ref="wsu:Id"/>
        <xsd:anyAttribute namespace="##other" processContents="lax"/>
    </xsd:complexType>

我搜索了很多,但我找不到任何解决方案,但是在阅读了这篇文章之后

如果 <redefine> 包含 <annotation> 以外的任何子项,则 svcUtil 错误“SchemaLocation”必须成功解决

我开始认为问题可能出在 wsdl 的其他地方。有什么建议么?

4

0 回答 0