繁体   English   中英

Spring web 服务请求格式 int 带前导零

[英]Spring web service request format int with leading zero

我正在使用 Spring web 服务连接到安全的 url 并发送 Z4DE91F0FCB6100A20B3DZB1A6 请求。 特定字段在 wsdl 中定义为:<xs:element minOccurs="1" name="collectionDay" type="xs:int"/>

我使用 genjaxb 从 wsdl 生成类,所以这个字段生成为:

...

* &lt;element name="collectionDay" type="{http://www.w3.org/2001/XMLSchema}int"/&gt;

...

protected int collectionDay;

...

/**
 * Gets the value of the collectionDay property.
 * 
 */
public int getCollectionDay() {
    return collectionDay;
}

/**
 * Sets the value of the collectionDay property.
 * 
 */
public void setCollectionDay(int value) {
    this.collectionDay = value;
}

...

问题是主机期望任何一位数天(第 1 天到第 9 天)发送为:“&ltcollectionDay&gt03&lt/collectionDay&gt”(前导 0)

如果我可以将其转换为字符串很容易,但是 Spring 根据生成的类在未知的某处生成请求,因此该字段需要 int,但生成的字段为:

"&ltcollectionDay&gt3&lt/collectionDay&gt"(没有前导零)

此时我看到的唯一选择是在本地保存 WSDL 并手动将字段类型更改为字符串,以便使用修改后的字段类型生成 java 类。 url 托管在银行,因此他们没有机会进行任何更改。

这在这里得到了回答: 我可以在 XSD 生成的 class 中对 integer 进行零填充吗?

让一个终端系统来修复他们的东西是一种痛苦,而且通常不是一个选择。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM