【问题标题】:ID Attribute missing while marshaling during webservicetemplate.convertandsend(...)在 webservicetemplate.convertandsend(...) 期间编组时缺少 ID 属性
【发布时间】:2017-05-22 08:05:49
【问题描述】:

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

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

在 windows 和 linux 上进行封送处理有什么区别吗?

Spring WebserviceTemplate 配置:

    <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”的属性外,所有属性均已填充。

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。

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

【问题讨论】:

    标签: spring jaxb spring-integration jax-ws spring-ws


    【解决方案1】:

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

    <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()方法分别是属性“id”的getID()和setID()。

    解决方案:
    1. 我在生成的绑定类中手动将 getID() 更新为 getId() 并将 setID() 更新为 setId()。
    2. 停止重新生成绑定类,因为 WSDL 是固定合同。

    【讨论】:

      猜你喜欢
      • 2021-01-17
      • 1970-01-01
      • 2014-01-08
      • 2011-04-13
      • 2011-10-07
      • 1970-01-01
      • 2021-07-26
      • 1970-01-01
      • 2011-05-08
      相关资源
      最近更新 更多