springboot soap webservice中的意外元素错误

时间:2018-12-11 19:02:13

标签: java web-services spring-boot soap

我正在尝试使用intellij中的springboot创建soap webservice,并提供一些教程。但是在提交请求时出现以下错误。

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
    <SOAP-ENV:Fault>
        <faultcode>SOAP-ENV:Server</faultcode>
        <faultstring xml:lang="en">unexpected element (uri:"http://localhost:8080/students", local:"GetStudentDetailsRequest"). Expected elements are &lt;{}GetStudentDetailsRequest&gt;</faultstring>
    </SOAP-ENV:Fault>
</SOAP-ENV:Body>

教程链接creating a soap webservice with springboot

student-details.xsd:

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="http://localhost:8080/students"
           xmlns:tns="http://localhost:8080/students" elementFormDefault="qualified">

    <xs:element name="GetStudentDetailsRequest">
        <xs:complexType>
            <xs:sequence>
                <xs:element name= "id" type="xs:int"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="GetStudentDetailsResponse">
        <xs:complexType>
            <xs:sequence>
                <xs:element name= "StudentDetails" type="tns:StudentDetails"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:complexType name="StudentDetails">
        <xs:sequence>
            <xs:element name="id" type="xs:int"/>
            <xs:element name="name" type="xs:string"/>
            <xs:element name="passportNumber" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>

</xs:schema>

下面是对象工厂

ObjectFactory.java:

package com.example.epro.model;

import javax.xml.bind.annotation.XmlRegistry;



@XmlRegistry
public class ObjectFactory {


    public ObjectFactory() {
    }


    public GetStudentDetailsResponse createGetStudentDetailsResponse() {
        return new GetStudentDetailsResponse();
    }

    public StudentDetails createStudentDetails() {
        return new StudentDetails();
    }

    public GetStudentDetailsRequest createGetStudentDetailsRequest() {
        return new GetStudentDetailsRequest();
    }

}

0 个答案:

没有答案