1

我正在使用axis2 Web服务,其中我使用以下messageFormatter(org.apache.axis2.json.JSONMessageFormatter):

<messageFormatter contentType="application/json" class="org.apache.axis2.json.JSONMessageFormatter"/>

并遵循 messageBuilder(org.apache.axis2.json.JSONOMBuilder):

<messageBuilder contentType="application/json" class="org.apache.axis2.json.JSONOMBuilder"/>.

我有一个作为字符串返回的元素,其 Wsdl 合同如下:

<xs:element minOccurs="0" name="totalCostStr" nillable="true" type="xs:String">

我的问题是当我收到相应的 JSON 并且如果 totalCostStr 大于 0.00,我将在 JSON 中的客户端获取 totalCostStr 作为字符串“0.00”

当值 totalCostStr 大于 0 时,我在客户端获取值,在 JSON 中作为浮点数(例如 12.65)而不是字符串“12.65”。

有没有办法强制轴总是将 totalCostStr 作为浮点数或字符串返回?

提前致谢, 切坦

4

1 回答 1

2

这是一个奇怪的行为:/

您可以使用 wsdl 元素中的 float 类型始终将其用作 float

<xs:element minOccurs="0" name="totalCostStr" nillable="true" type="xs:float"/> 

这应该工作...

于 2013-02-04T14:25:52.277 回答