Abstract
Web Services bring with them great possibilities and with these possibilities are some pitfalls. one such pitfall is passing complex data types to and from Web Services without losing data integrity. the clearest thing to keep in mind when passing objects to Web Services is the data is passed for your object's fields, but the code is not.
What happens when I have an object that my web service passes as a return value?
WSDL does some magic when a programmer creates a referance to your web service. Visual Studio. NET creates wrapper objects around und foreign data types.
The struct you create inside your Web Service looks like this:
Public struct PersonData
{
Private int yearsExperience;
Public int YearsExperience
{
Get {return yearsExperience ;}
Set
{
If (value <2) {throw new Exception ("You're unemployable! ");}
YearsExperience = value;
}
}
Public String FirstName;
Public String LastName;
}
... Which then gets translated into WSDL which looks like this:
<S: complexType name = "PersonData">
<S: sequence>