简体   繁体   English

未填充spring / ws jaxb pojo字段

[英]spring-ws jaxb pojo fields not populated/umarshalled

This post is the closest one to my problem . 这篇帖子最接近我的问题 However, there is no explanation there how the problem was solved or what was really wrong with it. 但是,那里没有解释如何解决问题或真正出了什么问题。

I've tried a very basic configuration to eliminate any underlying issues. 我已经尝试了一种非常基本的配置来消除任何潜在的问题。

My spring-ws-context.xml is this: 我的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>

My GetPersonRequest.java is this 我的GetPersonRequest.java是这个

@XmlRootElement(name = "GetPersonRequest", namespace = PersonEndpoint.NAMESPACE_URI)
@XmlAccessorType(XmlAccessType.FIELD)
public class GetPersonRequest {
    @XmlElement
    private Integer id;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

}

My Endpoint is this: 我的端点是这样的:

@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();
    }
}

I would like to note that the entire service is up and running fine with no errors. 我想指出,整个服务正常运行且没有错误。 This is what's okay so far (as per the instructions above): 到目前为止,这还可以(按照上述说明):

1) Endpoint can display wsdl to soapui and browser. 1)端点可以将wsdl显示给soapui和浏览器。

2) soap xml can be submitted with no errors. 2)soap xml可以毫无错误地提交。

3) log files show the xml body was being sent. 3)日志文件显示正在发送xml正文。

But for the life of me @RequestPayload GetPersonRequest request is blank! 但是对我来说,@ RequestPayload GetPersonRequest请求是空白! It only has one field for chrissakes and it won't even get set! 它只有一个用于纪念的领域,甚至都不会被设置!

Now, if I don't use JAXB as the request object but use org.w3c.dom.Element instead I can see that all the data I submitted is all there. 现在,如果我不使用JAXB作为请求对象,而是使用org.w3c.dom.Element,那么我可以看到提交的所有数据都在那里。

What am I missing? 我想念什么? I can't help but think I'm missing something completely simple. 我忍不住想念我完全简单的东西。

This is the sample input by the way (at least what the logs show): 顺便说一下,这是示例输入(至少日志显示的是):

  <sch1:GetPersonRequest xmlns:sch1="http://myschema/person/schemas">
     <sch1:id>1</sch1:id>
  </sch1:GetPersonRequest>

I can't find a better solution for this. 我找不到更好的解决方案。 So far the only answer I can come up with is using a package-info.java 到目前为止,我唯一能想到的答案是使用package-info.java

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

My older project didn't use spring and spring REQUIRES the xsd file to have a targetNamespace attribute. 我的旧项目没有使用spring,spring并要求xsd文件具有targetNamespace属性。 I wanted to simplify my current app by doing with namespaces at the moment but it appears that won't work with spring-ws. 我现在想通过使用名称空间来简化当前应用程序,但看来不适用于spring-ws。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM