解组错误:意外元素(uri:“”,local:“user”)。预期要素是(无)

时间:2015-02-26 12:48:21

标签: xml soap xsd wsdl cxf-client

我在生成肥皂反应时遇到了上述错误。我也想让fname成为必需的,我几乎尝试了所有的东西,比如minOccurs = 1,nillable:false但没有运气。

以下是我要求的参数: -

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Body>
        <RUser xmlns="http://www.test.org/">
            <RInfo xmlns="">
                <user>
                    <fname>[string]</fname>
                </user>
            </RInfo>
        </RUser>
    </Body>
</Envelope>

我的wsdl文件如下: -

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="TestServiceService" targetNamespace="http://www.test.org/"
                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                  xmlns:tns="http://www.test.org/"
                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
    <wsdl:types>
        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                   xmlns:tns="http://www.test.org/"
                   attributeFormDefault="unqualified"
                   elementFormDefault="unqualified"
                   targetNamespace="http://www.test.org/">


            <xs:element name="RUser" type="tns:RUser"/>
            <xs:element name="RResponse" type="tns:RResponse"/>

            <xs:complexType name="RUser">
                <xs:sequence>
                    <xs:element  name="RInfo" type="tns:rInfo"/>
                </xs:sequence>
            </xs:complexType>


            <xs:complexType name="rInfo">
                <xs:sequence>
                    <xs:element name="user">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="fname" type="xs:string" nillable="false"/>
                        </xs:sequence>
                    </xs:complexType>
                    </xs:element>
                </xs:sequence>
            </xs:complexType>


            <xs:complexType name="RResponse">
                <xs:sequence>
                    <xs:element minOccurs="1" name="RResult" type="tns:RResult"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="RResult">
                <xs:sequence>
                    <xs:element minOccurs="0" name="rType" type="xs:string"/>
                    <xs:element minOccurs="0" name="ruserID" type="xs:string"/>
                    <xs:element minOccurs="0" name="authFailed" type="xs:string"/>
                    <xs:element minOccurs="0" name="soapMessage" type="xs:string"/>
                </xs:sequence>
           </xs:complexType>

        </xs:schema>
    </wsdl:types>



    <wsdl:message name="RUser">
        <wsdl:part name="parameters" element="tns:RUser"/>
    </wsdl:message>
    <wsdl:message name="RResponse">
        <wsdl:part name="parameters" element="tns:RResponse"/>
    </wsdl:message>




    <wsdl:portType name="TestServiceWsdlEndpointPortType">
        <wsdl:operation name="RUser">
            <wsdl:input name="RUser" message="tns:RUser"/>
            <wsdl:output name="RResponse" message="tns:RResponse"/>
        </wsdl:operation>
    </wsdl:portType>

    <wsdl:binding name="TestServiceWsdlEndpointBinding" type="tns:TestServiceWsdlEndpointPortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

        <wsdl:operation name="RUser">
            <soap:operation soapAction="" style="document"/>
            <wsdl:input name="RUser">
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="RResponse">
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>

    </wsdl:binding>

    <wsdl:service name="TestServiceWsdlEndpoint">
        <wsdl:port name="TestServiceWsdlPort" binding="tns:TestServiceWsdlEndpointBinding">
            <soap:address location="http://localhost:8080/testapp/services/TestServiceWsdl"/>
        </wsdl:port>
    </wsdl:service>

</wsdl:definitions>

1 个答案:

答案 0 :(得分:0)

这应该是您的要求,

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:test="http://www.test.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <test:RUser>
         <RInfo>
            <user>
               <fname>?</fname>
            </user>
         </RInfo>
      </test:RUser>
   </soapenv:Body>
</soapenv:Envelope>
相关问题