春季 WS.肥皂请求为空

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


所有类都是由 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());

    }

}


30秒到达战场
浏览 78回答 1
1回答

摇曳的蔷薇

问题出在错误的请求中。我没有写入用户字段
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java