简单的WSDL显示错误"此绑定中指定的所有操作必须在端口类型中定义"

时间:2016-08-27 02:48:59

标签: java web-services soap xsd wsdl

我正在尝试编写一个具有内联xsd的简单wsdl文件。 我显示以下错误。我提到了其他stackoverflow问题,但没有人帮助解决这个问题。感谢任何帮助。 以下是代码

<wsdl:types>
    <!-- <xsd:schema targetNamespace="http://www.example.org/createEmployee/">
        <xsd:import schemaLocation="..\schema\Employee.xsd"/>
    </xsd:schema> -->
    <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
                targetNamespace="http://www.example.org/Employee" 
                xmlns:tns="http://www.example.org/Employee" elementFormDefault="qualified"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:element name="Employee" type="tns:EmployeeRequestType"></xsd:element>

<xsd:complexType name="EmployeeRequestType">
    <xsd:all>
        <xsd:element name="fname" type="string" maxOccurs="1" minOccurs="1"></xsd:element>
        <xsd:element name="lname" type="string" maxOccurs="1" minOccurs="1"></xsd:element>
        <xsd:element name="salary" type="double" maxOccurs="1" minOccurs="1"></xsd:element>
        <xsd:element name="type" type="string" maxOccurs="1" minOccurs="1"></xsd:element>
    </xsd:all>
</xsd:complexType>

<xsd:element name="EmployeeResponse" type="tns:EmployeeResponseType"></xsd:element>

<xsd:complexType name="EmployeeResponseType">
    <xsd:all>
        <xsd:element name="EmpId" type="string" maxOccurs="1" minOccurs="1">
        </xsd:element>
        <xsd:element name="type" type="string" maxOccurs="1" minOccurs="1"></xsd:element>
    </xsd:all>
</xsd:complexType>

    

<wsdl:message name="addEmployeeRequest">
    **<wsdl:part name="parameters" element="tns:Employee"/>**
</wsdl:message>
<wsdl:message name="addEmployeeResponse">
    **<wsdl:part name="parameters" element="tns:EmployeeResponse"/>**
</wsdl:message>

<wsdl:portType name="addEmployeePortType">
    <wsdl:operation name="addEmployee">
        <wsdl:input message="tns:addEmployeeRequest"/>
        <wsdl:output message="tns:addEmployeeResponse"/>
    </wsdl:operation>
</wsdl:portType>

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

    <wsdl:operation name="addEmployee">
        **<soap:operation style="document" soapAction="http://www.example.org/createEmployee/addEmployee" />**
        <wsdl:input name="addEmployeeRequest">
            <soap:body use="literal" />
        </wsdl:input>
        <wsdl:output name="addEmployeeResponse">
            <soap:body use="literal" />
        </wsdl:output>
    </wsdl:operation>

    </wsdl:binding>

<wsdl:service name="addEmployeeService">
    <wsdl:port name="addEmployeePort" binding="tns:addEmp_Binding">
        <soap:address
            location="http://localhost:8080/service/addEmployee" />
    </wsdl:port>
</wsdl:service>

错误:

Below are the errors at highlighted 

1。部分参数&#39;有一个无效的值&#39;员工&#39;为其元素定义。元素声明必须引用模式中定义的有效值。

  1. 部分&#39;参数&#39;具有无效值&#39; EmployeeResponse&#39;为其元素定义。元素声明必须引用模式中定义的有效值。

    1. 为&#39; addEmp_Binding&#39;指定的操作没有为端口类型定义绑定&#39; addEmployeePortType&#39;。此绑定中指定的所有操作必须是 在端口类型中定义&#39; addEmployeePortType&#39;。

1 个答案:

答案 0 :(得分:0)

回答我的问题是命名空间存在问题。一旦我更正了名称空间,就解决了以下错误:

  1. &#34;部分&#39;参数&#39;有一个无效的值&#39;员工&#39;为其元素定义。元素声明必须引用模式中定义的有效值。&#34;

  2. &#34;部分&#39;参数&#39;具有无效值&#39; EmployeeResponse&#39;为其元素定义。元素声明必须引用模式中定义的有效值。&#34;