Java spring ws-jaxb pojo字段未填充/umarshalled

Java spring ws-jaxb pojo字段未填充/umarshalled,java,xml,spring,web-services,jaxb,Java,Xml,Spring,Web Services,Jaxb,。然而,那里没有解释问题是如何解决的,也没有解释问题的真正症结所在 我尝试了一个非常基本的配置来消除任何潜在的问题 我的spring-ws-context.xml如下所示: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance

。然而,那里没有解释问题是如何解决的,也没有解释问题的真正症结所在

我尝试了一个非常基本的配置来消除任何潜在的问题

我的spring-ws-context.xml如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:sws="http://www.springframework.org/schema/web-services"
    xmlns:oxm="http://www.springframework.org/schema/oxm"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
      http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.2.xsd">
<context:component-scan base-package="test" />

<sws:annotation-driven marshaller="marshaller" unmarshaller="marshaller" />

<sws:dynamic-wsdl id="person" portTypeName="Person"
    locationUri="/personService/" targetNamespace="http://myschema/person/definitions">
    <sws:xsd location="classpath:person.xsd" />
</sws:dynamic-wsdl>
<sws:interceptors>
    <bean
        class="org.springframework.ws.soap.server.endpoint.interceptor.SoapEnvelopeLoggingInterceptor">
        <property name="logRequest" value="true"></property>
        <property name="logResponse" value="true"></property>
    </bean>
</sws:interceptors>

<oxm:jaxb2-marshaller id="marshaller">
    <oxm:class-to-be-bound name="test.request.GetPersonRequest" />
</oxm:jaxb2-marshaller>
我的目标是:

@Endpoint
public class PersonEndpoint {

    public static final String NAMESPACE_URI = "http://myschema/person/schemas";

    @Autowired
    PersonService service;

    @PayloadRoot(namespace = NAMESPACE_URI, localPart="GetPersonRequest")
    public @ResponsePayload GetPersonResponse handleGetPersonRequest(@RequestPayload Element request) {
        System.out.println("handleGetPersonRequest()");
        // TODO: Go to service.getPerson(request)
        return new GetPersonResponse();
    }
}
我想指出的是,整个服务已经启动,运行良好,没有错误。这是目前为止可以接受的(按照上面的说明):

1) 端点可以向soapui和浏览器显示wsdl

2) SOAPXML可以无错误地提交

3) 日志文件显示正在发送xml正文

但是对于我来说@RequestPayload GetPersonRequest是空白的!它只有一个字段,甚至不会设置

现在,如果我不使用JAXB作为请求对象,而是使用org.w3c.dom.Element,我可以看到我提交的所有数据都在那里

我错过了什么?我忍不住觉得我遗漏了一些非常简单的东西

顺便说一下,这是示例输入(至少日志显示):


1.

我找不到更好的解决方案。到目前为止,我能想到的唯一答案是使用一个包-info.java

@javax.xml.bind.annotation.XmlSchema(namespace = test.ws.PersonEndpoint.NAMESPACE_URI, elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package test.request;

我以前的项目没有使用spring,spring要求xsd文件具有targetNamespace属性。目前我想通过使用名称空间来简化我当前的应用程序,但这似乎不适用于spring ws。

您可以忽略marhaller声明,因为我后来为了测试目的添加了它,所以这很奇怪。显然,在XmlElement上显式声明名称空间解决了这个问题。但我觉得不应该是这样。我在一个普通的soap项目上工作过,但这根本不需要它。
  <sch1:GetPersonRequest xmlns:sch1="http://myschema/person/schemas">
     <sch1:id>1</sch1:id>
  </sch1:GetPersonRequest>
@javax.xml.bind.annotation.XmlSchema(namespace = test.ws.PersonEndpoint.NAMESPACE_URI, elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package test.request;