【发布时间】:2017-08-25 06:07:46
【问题描述】:
我们从客户那里获得 WSDL。 (即,我们无法更改它们。)
其中一种类型的定义如下所示:
<complexType name="Type1">
<complexContent>
<restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
<sequence>
<element name="value" minOccurs="0">
<complexType>
<complexContent>
<restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
<choice>
<element name="bigdecimal" type="{http://www.w3.org/2001/XMLSchema}double"/>
<element name="date" type="{http://www.w3.org/2001/XMLSchema}date"/>
<element name="string" type="{http://www.w3.org/2001/XMLSchema}string"/>
</choice>
</restriction>
</complexContent>
</complexType>
</element>
<element name="element2" type="{http://www.w3.org/2001/XMLSchema}integer" minOccurs="0"/>
</sequence>
</restriction>
</complexContent>
</complexType>
导致类似的事情
public void setBigdecimal(Double value) {
this.bigdecimal = value;
}
现在,当我们发送包含这种类型的请求时,它会生成如下内容:
<rpcOp:value>
<rpcOp:bigdecimal>10.0</rpcOp:bigdecimal> <!-- IN SPITE OF THE NAME, THIS IS A DOUBLE VALUE! -->
<rpcOp:string>N</rpcOp:string>
</rpcOp:value>
客户希望显示的内容不带十进制数字,即 10 等。
我怀疑JAX-WS框架在从Java对象生成request xml时,只是简单地调用了Double.toString(),必然会添加一个小数点和一个小数位。
有没有办法在不修改 WSDL 的情况下更改它?为这种类型或类似的东西注册一些自定义数字格式化程序?
谢谢!
【问题讨论】:
标签: java web-services wsdl jax-ws number-formatting