我有 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/