James Baxter
James Baxter

Reputation: 139

C# Web Service returns objects as null from WinForms application

I am returning a array from my web service like so:

   [WebMethod]
   public Test_UserData[] GetLimitUsers(int min, int max)
   {
   return UserServiceLayer.GetLimitUsers(min, max);    
   }

If i call this web service from my browser is shows the array and content in XML format as expected.

I then added the web reference to a winforms project. Bare in mine i have other web services connected in the same way between the two projects which return plain old objects and they work fine.

UserWS.UserWS userWebService = new UserWS.UserWS();
Test_UserData[] testUserData = userWebService.GetLimitUsers(1, 2);

However, when i call this web service i get the amount of objects expected but all fields are null and Boolean are false.(The same behavior with Arrays, Lists and ienumerable.)

Could someone explain why i am getting the right objects but they are all "nullified" ?

Edit:

<Test_UserData>
<Id_ValueIncluded>true</Id_ValueIncluded>
<Id>
<Value xmlns="http://www.blah.co.uk/JamesTest/Data/">100001</Value>
<References xmlns="http://www.blah.co.uk/JamesTest/Data/"/>
</Id>
<ExtensionData_ValueIncluded>true</ExtensionData_ValueIncluded>
<Password_ValueIncluded>true</Password_ValueIncluded>
<Password>h</Password>
<UserName_ValueIncluded>true</UserName_ValueIncluded>
<UserName>h</UserName>
<OutputData>
<Type_ValueIncluded>true</Type_ValueIncluded>
<Type>Test_User</Type>
</OutputData>
</Test_UserData>

Upvotes: 2

Views: 234

Answers (1)

James Baxter
James Baxter

Reputation: 139

In the end it was a namespace problem when using the asmx file with winforms.

Upvotes: 1

Related Questions