Java 春季天气预报。Soap请求为空

Java 春季天气预报。Soap请求为空,java,web-services,soap,jaxb,spring-ws,Java,Web Services,Soap,Jaxb,Spring Ws,我有一个soapweb服务。我尝试在请求中传递实体。基本类型(包括字符串)传递正常值。但如果我想发送实体,我的实体是空的。我可能有什么不对劲吗 所有类都是由maven生成的 TestUserRequest package soap.test.spring_boot_soap_example; import javax.xml.bind.annotation.*; @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propO

我有一个soapweb服务。我尝试在请求中传递实体。基本类型(包括字符串)传递正常值。但如果我想发送实体,我的实体是空的。我可能有什么不对劲吗

所有类都是由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.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>

4.0.0
肥皂测试
spring示例
0.0.1-快照
罐子
org.springframework.boot
spring启动程序父级
1.5.10.1发布
UTF-8
UTF-8
1.8
org.springframework.boot
SpringBootStarterWeb服务
wsdl4j
wsdl4j
org.springframework.boot
弹簧起动试验
测试
org.springframework.boot
springbootmaven插件
org.codehaus.mojo
jaxb2 maven插件
1.6
xjc
xjc
${project.basedir}/src/main/resources/
${project.basedir}/src/main/java
假的
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>

自闭症
125
aasdg

我在网上找过这样的问题。但不幸的是,我发现在错误的请求中没有任何问题。我没有写入用户字段

请提供完整的错误消息。没有例外。我尝试在TestUserRequest.getUser()中获取用户,但用户为null。谢谢:)我也有同样的问题,你能用你的代码解释一下吗?是的。您应该将包信息添加到包中。一切都会好起来的。如果我能帮你更多,请告诉我
<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>