java - 请求中带有 jaxb null 对象的 Spring WS

标签 java spring jaxb

我有 Spring WS,我正在向它发送对象请求 Request.java类,如果我在 jaxb 类中硬编码值就可以了(但不是这样..)
我在 SoapUI 中测试的肥皂请求:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cas="http://jakisadres.com/caservice">
   <soapenv:Header/>
   <soapenv:Body>
      <cas:Request>
         <cas:atr1>some value</cas:machineName>
      </cas:Request>
   </soapenv:Body>
</soapenv:Envelope>

我得到的是:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <ns3:Response xmlns:ns3="http://jakisadres.com/caservice">
         <responseValue>response: null</responseValue>
      </ns3:CARevokeCertResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

我的终点:
    @PayloadRoot(localPart = "Request", namespace = "http://jakisadres.com/caservice")
    @ResponsePayload
    public Response revokeCert(@RequestPayload Request param) {
        String request= param.getAtr1();
        Resoponse response_ = new Response();
        response.setResponseValue("response: "+request);
        return response;
    }

和我的 jaxb marshaller 类:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "atr1"
})
@XmlRootElement(name = "Request")
public class Request{

    protected String atr1;


    public String getAtr1() {
        return atr1;
    }

    public void setAtr1(String value) {
        this.atr1 = value;
    }

}

任何线索我错过了什么?

最佳答案

可能是你的 atr1元素位于默认命名空间中,而不是在 http://jakisadres.com/caservice 中命名空间..您的请求应该是:

  <cas:Request>
     <atr1>some value</atr1>
  </cas:Request>

或者您可以明确指定 atr1 的命名空间场

关于java - 请求中带有 jaxb null 对象的 Spring WS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13652255/

相关文章:

java - JAXB xsd 到对象绑定(bind)错误

java - 如何解码包含 DIFFGR 的 XML 代码

java - 使用 JAXB 编码 xml 期间忽略 null 标签

java - ActiveMQ 消费者 OutOfMemoryException

java - Discord 机器人中的命令问题

java - 单元测试中的@Autowire 似乎不起作用

java - 使用Spring依赖注入(inject)时如何模拟在其他方法中调用的方法?

java - 如何在自定义 Spring Data JPA 存储库中注入(inject)配置

java - ExceptionInInitializerError - 使用getResourceAsStream读取jar包中的文件

java - 通过 Java 应用程序发布到 Twitter 的最佳方式