如何解决如何在进行 SOAP webservice 调用时避免强制转换为 JAXBElement?
我有一个 Spring Boot Java 应用程序。我正在使用 spring webservice 模板调用soap web 服务。 webservice 调用总是返回一个 JAXBElement。以下是我的代码片段。
JAXBElement<ItemResponse> itemResponse = (JAXBElement<ItemResponse> ) getWebServiceTemplate().marshalSendAndReceive(
this.cconfServiceConfiguration.getServices().getLocation(),itemRequest,new SoapActionCallback(this.cconfServiceConfiguration.getServices().getGetItemAction()));
return itemResponse.getValue();
marshalSendAndReceive 返回一个 JAXBElement。有什么办法可以重写代码,以便它返回 ItemResponse 的对象,这样我就可以避免强制转换。 以下是 ItemResponse 类声明。
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ItemResponse",propOrder = {
"result","item"
})
public class ItemResponse {
@XmlElement(required = true)
protected Result result;
protected Item item;
/**
* Gets the value of the result property.
*
* @return
* possible object is
* {@link Result }
*
*/
public Result getResult() {
return result;
}
/**
* Sets the value of the result property.
*
* @param value
* allowed object is
* {@link Result }
*
*/
public void setResult(Result value) {
this.result = value;
}
/**
* Gets the value of the item property.
*
* @return
* possible object is
* {@link Item }
*
*/
public Item getItem() {
return item;
}
/**
* Sets the value of the item property.
*
* @param value
* allowed object is
* {@link Item }
*
*/
public void setItem(Item value) {
this.item = value;
}
}
如果你能提供一些信息,真的很感激
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。