Java Spring-WS请求输入为空

Java Spring-WS请求输入为空,java,spring,soap,jaxb,spring-ws,Java,Spring,Soap,Jaxb,Spring Ws,我使用SpringWS来生成SOAP Web服务。我的输入请求为空,请帮助我解决问题,因为我花了数小时试图解决问题。。 下面是我的代码快照 wsdl:(子集) GetPersonByUseridIP: import java.io.Serializable; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import

我使用SpringWS来生成SOAP Web服务。我的输入请求为空,请帮助我解决问题,因为我花了数小时试图解决问题。。 下面是我的代码快照

wsdl:(子集)

GetPersonByUseridIP:

    import java.io.Serializable;
    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 = "GetPersonByUserIdIP", propOrder = {
    "userId",
    "userType"
})
public class GetPersonByUserIdIP
    extends AttributeRequest
    implements Serializable
{

    @XmlElement(required = true, nillable = true)
    protected String userId;
    @XmlElement(required = true, nillable = true)
    protected String userType;


    public String getUserId() {
        return userId;
    }

    public void setUserId(String value) {
        this.userId = value;
    }

    public String getUserType() {
        return userType;
    }

    public void setUserType(String value) {
        this.userType = value;
    }

}
SpringWS配置:(将mvc和WS结合在一起)

服务类别:

@Endpoint
public class CommonUserWS {
private static final String NAMESPACE_URI = "http://v4_0.webservice.commonuser.u90.org.com";

@PayloadRoot(namespace = NAMESPACE_URI, localPart = "getPersonByUserId")
    @ResponsePayload
    public JAXBElement<GetPersonByUserIdOP> getPersonByUserId(@RequestPayload GetPersonByUserIdIP getPersonByUserIdIP)
            throws ContextException {
        final GetPersonByUserIdOP output = new GetPersonByUserIdOP();
        JAXBElement<GetPersonByUserIdOP> jaxbElement = null;
        try {
            String userType = getPersonByUserIdIP.getUserType();
            String userId = getPersonByUserIdIP.getUserId();

            // impl logic

            QName qname = new QName("getPersonByUserId");
            jaxbElement = new JAXBElement<GetPersonByUserIdOP>(qname, GetPersonByUserIdOP.class, output);
        } catch (ContextException e) {
            throw e;
        }
        return jaxbElement;
    }
}
@Endpoint
公共类CommonUserWS{
私有静态最终字符串命名空间_URI=”http://v4_0.webservice.commonuser.u90.org.com";
@PayloadRoot(namespace=namespace\u URI,localPart=“getPersonByUserId”)
@回应书
公共JAXBELENT getPersonByUserId(@RequestPayload GetPersonByUserIdIP GetPersonByUserIdIP)
抛出ContextException{
最终GetPersonByUserIdOP输出=新的GetPersonByUserIdOP();
JAXBElement JAXBElement=null;
试一试{
字符串userType=getPersonByUserIdIP.getUserType();
字符串userId=getPersonByUserIdIP.getUserId();
//impl逻辑
QName QName=新的QName(“getPersonByUserId”);
jaxbElement=newjaxbelement(qname,GetPersonByUserIdOP.class,output);
}捕获(ContextException e){
投掷e;
}
回归方程;
}
}
从上面的GetPersonByUserIdIP类中,requestpayload为null

以下是我发送的请求示例:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v4="http://v4_0.webservice.commonuser.u90.org.com" xmlns:bean="http://beans.v4_0.webservice.commonuser.u90.org.com">
   <soapenv:Header/>
   <soapenv:Body>
      <bean:getPersonByUserId>
         <bean:getPersonByUserIdIP>
            <!--1 or more repetitions:-->
            <bean:attribute>name</bean:attribute>
            <bean:attribute>address</bean:attribute>

<bean:userId>hx52301</bean:userId>
            <bean:userType/>
         </bean:getPersonByUserIdIP>
      </bean:getPersonByUserId>
   </soapenv:Body>
</soapenv:Envelope>

名称
地址
hx52301
我得到以下错误:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header/>
    <soapenv:Body>
        <soapenv:Fault>
            <faultcode>soapenv:Server</faultcode>
            <faultstring>UserId is null.</faultstring>
        </soapenv:Fault>
    </soapenv:Body>
</soapenv:Envelope>

soapenv:服务器
UserId为空。

感谢您的关注,非常感谢您的帮助。

通过查看@RequestPayload,正文应该以getPersonByUserIdIP而不是getPersonByUserId开头

 <soapenv:Body>
     <bean:getPersonByUserIdIP>
        <bean:attribute>name</bean:attribute>
        <bean:attribute>address</bean:attribute>

     <bean:userId>hx52301</bean:userId>
        <bean:userType/>
     </bean:getPersonByUserIdIP>
 </soapenv:Body>`

名称
地址
hx52301
`

Hi Jayesh,如果我删除getPersonByUserId,它将不起作用,因为请求无法与端点匹配。。我看到请求随服务器中的数据而来,但我看到当jax-b解组时,请求失败并返回null。您可以发布已经附加在post中的类GetPersonByUseridIP吗。。由于长度限制,已尝试将其附加到注释中。。请在GetPersonByUseridIP的帖子中找到:你找到解决方案了吗?
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v4="http://v4_0.webservice.commonuser.u90.org.com" xmlns:bean="http://beans.v4_0.webservice.commonuser.u90.org.com">
   <soapenv:Header/>
   <soapenv:Body>
      <bean:getPersonByUserId>
         <bean:getPersonByUserIdIP>
            <!--1 or more repetitions:-->
            <bean:attribute>name</bean:attribute>
            <bean:attribute>address</bean:attribute>

<bean:userId>hx52301</bean:userId>
            <bean:userType/>
         </bean:getPersonByUserIdIP>
      </bean:getPersonByUserId>
   </soapenv:Body>
</soapenv:Envelope>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header/>
    <soapenv:Body>
        <soapenv:Fault>
            <faultcode>soapenv:Server</faultcode>
            <faultstring>UserId is null.</faultstring>
        </soapenv:Fault>
    </soapenv:Body>
</soapenv:Envelope>
 <soapenv:Body>
     <bean:getPersonByUserIdIP>
        <bean:attribute>name</bean:attribute>
        <bean:attribute>address</bean:attribute>

     <bean:userId>hx52301</bean:userId>
        <bean:userType/>
     </bean:getPersonByUserIdIP>
 </soapenv:Body>`