springweb服务请求格式int

gstyhher  于 2021-07-13  发布在  Java
关注(0)|答案(1)|浏览(336)

我使用springwebservices连接到一个安全的url并发送soap请求。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,并手动将字段类型更改为string,这样就可以使用修改后的字段类型生成java类。这个网址是在一家银行托管的,所以他们不可能做任何更改。

0ve6wy6x

0ve6wy6x1#

这里的答案是:我可以在xsd生成的类中零填充一个整数吗?
让一个终端系统来修复他们的东西是一种痛苦,而且往往不是一种选择。

相关问题