spring—如何避免在进行soapwebservice调用时转换为jaxbelement?

yhived7q  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(266)

我有一个springbootjava应用程序。我使用springwebservice模板调用soapweb服务。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;
    }

}

如果你能提供一些信息,我真的很感激

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题