在复杂类型上添加属性和长度限制时出错

时间:2014-07-01 08:10:38

标签: java spring web-services xsd xsd-validation

我们在系统中使用了一个请求XSD,并且有一个使用此请求XSD的Spring Web服务。

正确编译和部署所有内容。我可以在IE中输入WSDL url并查看它。我可以导航到IE中的请求XSD。因此请求XSD似乎没有任何问题。 但是当我试图通过SOAP UI调用Web服务时:创建一个新项目并添加WSDL并点击OK我收到以下错误

ERROR:error: src-ct.2: To Extend the specified base type ‘Name@*MyNAMESPACE*‘ it must be a simple type or be a complex type with simple content.

在我的XSD中,我有一个名称字段

<xs:simpleType name="Name">
    <xs:restriction base="xs:string">
        <xs:minLength value="1"/>
        <xs:maxLength value="15"/>
    </xs:restriction>
</xs:simpleType>

然后我在几个地方使用它,我通过添加一个属性来扩展它

<xs:complexType name="MyCustomeName">
      <xs:simpleContent>
             <xs:extension base="mc:Name">
                    <xs:attribute name="MyTypeOfName" fixed="MCN"/>
             </xs:extension>
      </xs:simpleContent>
</xs:complexType>

从我所看到的,强制执行长度限制和添加属性的唯一方法就像我定义它的方式。

不知道错误定义了什么。有什么想法吗?


这里要求的是我的服务WSDL

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="the-location"
                  xmlns="http://schemas.mycomp.com/myowndir/"
                  xmlns:xs="http://www.w3.org/2001/XMLSchema"
                  targetNamespace="http://schemas.mycomp.com/myowndir/"
                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <wsdl:types>
        <xs:schema>
            <xs:import namespace="http://schemas.mycomp.com/myowndir/"
                       schemaLocation="../xsd/MyRequest-1.0.xsd"/>
            <xs:import namespace="http://schemas.mycomp.com/myowndir/"
                       schemaLocation="../xsd/MyResponse-1.0.xsd"/>

            <xs:element name="TheServiceResponse">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="MessageId" type="xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:schema>
    </wsdl:types>

    <wsdl:message name="TheServiceRequest">
        <wsdl:part name="TheServiceRequestPart" element="TheServiceRequest"/>
    </wsdl:message>
    <wsdl:message name="TheServicePlanResponse">
        <wsdl:part name="TheServiceResponsePart" element="TheServiceResponse"/>
    </wsdl:message>

    <wsdl:portType name="TheServicePortType">
        <wsdl:operation name="MyOperation">
            <wsdl:input message="TheServiceRequest" name="TheServiceRequestInput"/>

            <wsdl:output message="TheServicePlanResponse" name="TheServicePortTypeResponseOutput"/>
        </wsdl:operation>
    </wsdl:portType>

    <wsdl:binding name="TheServiceBinding" type="TheServicePortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="MyOperation">
            <soap:operation soapAction="http://schemas.mycomp.com/myowndir/MyOperation"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>

    <wsdl:service name="TheService">
        <wsdl:port binding="TheServiceBinding" name="TheServiceIntegrationPort">
            <soap:address location="/the-location/the-service"/>
        </wsdl:port>
    </wsdl:service>

</wsdl:definitions>

0 个答案:

没有答案
相关问题