views:

194

answers:

1

Hi all,

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.

My questions are:

  1. Is xsd:integer a valid WSDL data type or shouldn't it be xsd:int?
  2. How can I tell VS 2008 that this field should be int?
  3. 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?

Thanks for your help!

+2  A: 

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

marc_s
Thanks for that - I'll post this information to the web service provider.
Thorsten Dittmar
Will I still be able to communicate with the web service properly (see my question #2)?
Thorsten Dittmar