在webservicetemplate.convertandsend(...)期间编组时ID属性丢失 [英] ID Attribute missing while marshaling during webservicetemplate.convertandsend(...)

查看:413
本文介绍了在webservicetemplate.convertandsend(...)期间编组时ID属性丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jaxb2Marshaller来使用SOAP服务。我在Spring webServiceTemplate中使用它。 marhsalling在Windows上运行良好,但在linux上运行不正常。

I am using jaxb2Marshaller for consuming a SOAP service. I am using it inside Spring webServiceTemplate. The marhsalling works fine on windows but not on linux.

问题仅出现在名为ID的属性上。将属性名称更改为id或其他可以正常工作。

The issue only comes for attribute named "ID". Changing the attribute name to "id" or something else works fine.

在Windows和Linux上进行编组之间有什么区别吗?

Is there any difference between marshaling done on windows and linux?

Spring WebserviceTemplate配置:

Spring WebserviceTemplate configuration:

    <bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
        <property name="marshaller" ref="jaxb2Marshaller"></property>
        <property name="unmarshaller" ref="jaxb2Marshaller"></property>
        <property name="defaultUri"><value>${ws.url}</value></property>
...
    </bean>

现在我正在调用方法 webServiceTemplate.marshalSendAndReceive(createRequest); CreateRequest对象正在编组为XML。除了名为ID的属性外,将填充所有属性。

Now when I am calling the method webServiceTemplate.marshalSendAndReceive(createRequest); The "CreateRequest" object is getting marshaled into an XML. All the attributes are populated except the attribute named "ID".

SubscriberList.java extends Parent {
    protected String abc;
    protected String def;
     ...
    }

Parent.java {
    protected int ID;

    public getID(){return this.id}
    public setID(int value){this.id=value}
}

我正在使用此Web服务,因此不允许更改WSDL。

I am consuming this webservice, so changing WSDL is not allowed.

有人可以帮我解决这个问题吗?

Can someone help me in fixing this issue?

推荐答案

好吧这个问题有点奇怪。
在XML内部,属性名称为ID,而在生成的绑定类中,变量声明如下:

Well the issue was little strange. Inside XML the attribute name was "ID", whereas in binding class generated had variable declaration as below:

<element name="ID" minOccurs="0" maxOccurs="1" type="xsd:int" />


@XmlElement(name = "ID")
   protected Integer id;

   public Integer getID() {
        return id;
   }

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

插件生成的getxxx()和setxxx()方法是getID()和setID()表示属性id。

The getxxx() and setxxx() methods generated by plugin were getID() and setID() for attribute "id".

解决方案:

1.我手动将getID()更新为getId()和setID( )生成的绑定类中的setId()。

2.由于WSDL是固定合同,因此停止重新生成绑定类。

Solution:
1. I manually updated the getID() to getId() and setID() to setId() in generated binding classes.
2. Stopped regenerating the binding classes as WSDL is a fixed contract.

这篇关于在webservicetemplate.convertandsend(...)期间编组时ID属性丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆