I have a ws that exposes a class with a user defined type containg a bool, a
string and an int type properties. I've also set the default values of these
properties. Unfortunately, when passing the object from a consumer, the
default properties are not set, exept for the string value.
The WS is coded as follows:
public class TestData
{
private int _iInt = 10;
private string _sString = "hi";
private bool _bBool = true;
public int IInt
{
get { return _iInt; }
set { _iInt = value; }
}
public string SString
{
get { return _sString; }
set { _sString = value; }
}
public bool BBool
{
get { return _bBool; }
set { _bBool = value; }
}
}
A web method accepts the object and returns it:
[WebMethod]
public TestData ReturnObject(Te stData testInfo)
{
TestData returnData = new TestData();
returnData = testInfo;
return returnData;
}
The consumer instantiates the object and passes it to the method above which
returns it back:
[Test]
public void Test1()
{
TestData t = new TestData();
TestData t2 = _obj.ReturnObje ct(t);
}
Looking at t2, I can see the value of SString = "hi", but bBool is false and
iInt is 0.
What we're actually trying to do is to add new properties without affecting
current consumers by defaulting their values. I also tried to set the
defaultValue attribute but it didn't work either.
string and an int type properties. I've also set the default values of these
properties. Unfortunately, when passing the object from a consumer, the
default properties are not set, exept for the string value.
The WS is coded as follows:
public class TestData
{
private int _iInt = 10;
private string _sString = "hi";
private bool _bBool = true;
public int IInt
{
get { return _iInt; }
set { _iInt = value; }
}
public string SString
{
get { return _sString; }
set { _sString = value; }
}
public bool BBool
{
get { return _bBool; }
set { _bBool = value; }
}
}
A web method accepts the object and returns it:
[WebMethod]
public TestData ReturnObject(Te stData testInfo)
{
TestData returnData = new TestData();
returnData = testInfo;
return returnData;
}
The consumer instantiates the object and passes it to the method above which
returns it back:
[Test]
public void Test1()
{
TestData t = new TestData();
TestData t2 = _obj.ReturnObje ct(t);
}
Looking at t2, I can see the value of SString = "hi", but bBool is false and
iInt is 0.
What we're actually trying to do is to add new properties without affecting
current consumers by defaulting their values. I also tried to set the
defaultValue attribute but it didn't work either.
Comment