Visual Studio生成了SAP WebService Reference肥皂体问题 [英] Visual Studio generated SAP WebService Reference Soap Body Problem
问题描述
我们正在尝试使用SAP webservice。我们为Visual Studio添加了服务引用。 WS包含定义了这些参数的MethodX方法:
we are trying to consume SAP webservice. We added service reference to Visual Studio. WS contains method MethodX that has these parameters defined:
<xsd:element name="Card" type="n0:curr13.2"/>
<xsd:element name="Cash" type="n0:curr13.2"/>
数据类型定义如下:
<xsd:simpleType name="curr13.2">
<xsd:restriction base="xsd:decimal">
<xsd:totalDigits value="13"/>
<xsd:fractionDigits value="2"/>
</xsd:restriction>
</xsd:simpleType>
Visual Studio生成" decimal "这些"现金"的属性和"卡"数据成员。一切似乎都没问。
Visual Studio generates "decimal" properties for these "Cash" and "Card" data members. All seems OK.
但是,当调用此MethodX Web服务时,由于无效的soap请求而返回错误:
But, when calling this MethodX web service returns error because of invalid soap request:
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MethodX xmlns="urn:sap-com:document:sap:soap:functions:mc-style">
<Card xmlns="">49</Card>
<Cash xmlns="">50.0000</Cash>
</MethodX>
</s:Body>
查看生成的soap body。卡和现金定义为2位数的小数,但生成的肥皂体值为" 49 "和" 50.0000 "。
Look at the generated soap body. Card and Cash are defined as decimals with 2 digits but generated soap body values are "49" and "50.0000".
有没有人知道可能出现什么问题以及如何解决这个问题?它是Visual Studio soap服务客户端生成器中的错误吗?
Does anyone have any idea what could be wrong and how to solve this? Is it bug in Visual Studio soap service client generator?
谢谢,
Mirek Vanicky
Mirek Vanicky
推荐答案
我发现问题与十进制数据类型及其ToString实现有关(它与十进制内部实现绑定,如何存储值)。 .NET将此ToString表示形式放入soap body。这意味着它有时是
"50",有时是"50.0","50.0000",......
I have found that problem is related with decimal data type and its ToString implementation (that is bound to decimal's internal implementation, how the value is stored). .NET puts this ToString representation to soap body. So that means it is sometimes "50", sometimes "50.0", "50.0000",...
但为什么这种行为会破坏xsd架构?为什么.NET发送"50.0000"当xsd允许2个十进制数字时?
But why is this behaviour breaking the xsd schema? Why .NET sends "50.0000" when xsd allows 2 decimal digits?
这篇关于Visual Studio生成了SAP WebService Reference肥皂体问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!