Visual Studio 2008 imports WSDL with wrong data type
I'm trying to use a web service and thus added a web service reference to my project using the service's WSDL service description. All is well, there were no error message, but I noticed that one field is declared as string
in my web service reference while it should be int
.
Going through the WSDL service description, I noticed that the respective field is declared as:
<xsd:complexType name="ItemType">
<xsd:all>
<xsd:element name="quantity" type="xsd:integer"/>
</xsd:all>
</xsd:complexType>
Obviously, the field is supposed to be an integer, but Visual Studio 2008 thinks that it is a string.
M开发者_开发问答y questions are:
- Is
xsd:integer
a valid WSDL data type or shouldn't it bexsd:int
? - How can I tell VS 2008 that this field should be
int
? - Will I still be able to use the service when I provide a
string
(only containing numbers) in C# where the caller (obviously a PHP script) expects anint
?
Thanks for your help!
The trouble is: xs:integer
is "signed integer of arbitrary length" - so it could be larger than the .NET Int32 type's range --> thus it's converted to string by VS2008.
Use xs:int
- I believe that's being converted to Int32 properly.
See here: http://www.codesynthesis.com/projects/xsd/documentation/schema-authoring-guide.xhtml#integer
xs:int
maps to 32-bit integer, while xs:integer
is of arbitrary length.
Will I still be able to use the service when I provide a string (only containing numbers) in C# where the caller (obviously a PHP script) expects an int?
I would say yes, because in the end, the message going across the wire will always be textual XML at its core. It doesn't really care whether you supply a string "12345" and serialize that into your XML message, or whether you serialize '12345' as an INT into the message - in XML, in the end, everything is a string.
Marc
精彩评论