Spring WS。肥皂请求为空

Spring WS. Soap request is null

我有一个 SOAP 网络服务。我尝试在我的请求中传递实体。原始类型(包括字符串)通过正常。但是如果我想发送实体,我的实体是空的。我可能有什么问题吗?

所有 类 都是由 maven 生成的。

TestUserRequest 

package soap.test.spring_boot_soap_example;

import javax.xml.bind.annotation.*;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
        "user"
})
@XmlRootElement(name = "testUser")
public class TestUserRequest {
    @XmlElement(required = true)
    private User user;

    public User getUser() {
        return user;
    }

    public void setUser(User name) {
        this.user = name;
    }
}
getters/setters

用户

package soap.test.spring_boot_soap_example;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;


@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "user", propOrder = {
    "name",
    "empId",
    "salary"
})
public class User {

    @XmlElement(required = true)
    protected String name;
    @XmlElement(required = true)
    protected int empId;
    @XmlElement(required = true)
    protected double salary;
getters/setters;

端点

    package soap.test.springbootsoapexample.endpoint;

import soap.test.spring_boot_soap_example.TestUserRequest;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;

@Endpoint
public class UserEndpoint {

   @PayloadRoot(namespace = "http://soap.test",
            localPart = "testUser")
    public void testUser(@RequestPayload TestUserRequest saveUserRequest) {
       System.out.println(saveUserRequest.getUser());
    }
}

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>soap.test</groupId>
    <artifactId>spring-example</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>


    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.10.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency>

        <dependency>
            <groupId>wsdl4j</groupId>
            <artifactId>wsdl4j</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <id>xjc</id>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <schemaDirectory>${project.basedir}/src/main/resources/</schemaDirectory>
                    <outputDirectory>${project.basedir}/src/main/java</outputDirectory>
                    <clearOutputDir>false</clearOutputDir>
                </configuration>
            </plugin>
        </plugins>
    </build>


</project>

users.xsd

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

    <xs:element name="testUserRequest">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="user" type="tns:user" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:complexType name="user">
        <xs:sequence>
            <xs:element name="name" type="xs:string" />
            <xs:element name="empId" type="xs:int" />
            <xs:element name="salary" type="xs:double" />
        </xs:sequence>
    </xs:complexType>
</xs:schema>

并请求

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:us="http://soap.test">
    <soapenv:Header/>
    <soapenv:Body>
        <us:testUser>
            <us:name>asd</us:name>
            <us:empId>125</us:empId>
            <us:salary>aasdg</us:salary>
        </us:testUser>
    </soapenv:Body>
</soapenv:Envelope>

我在网上找过这样的问题。但不幸的是我什么也没找到

问题出在错误的请求上。我没有写用户字段