0

hi when I invoke my web service It returns me :

    <?xml version="1.0" encoding="UTF-8"?>
    -<ArrayOfAnyType xmlns="http://localhost:5669/TAWebService.asmx" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <anyType xsi:nil="true"/> 
<anyType xsi:nil="true"/> 
<anyType xsi:nil="true"/> 
<anyType xsi:nil="true"/>
 <anyType xsi:nil="true"/> 
<anyType xsi:nil="true"/> 
<anyType xsi:nil="true"/>
 <anyType xsi:nil="true"/>
 <anyType xsi:nil="true"/>
 <anyType xsi:nil="true"/>
 </ArrayOfAnyType>

any idea what could be wrong ? and when I call it from my winapp It returns null ! but in the website that I have developed the webservice It works correct and returns me the object !

here is the linqtosql query I use to retrieve object :

[WebMethod]
public Object[] getPersonnel(string hashCode)
{
    Personnel personnel = new Personnel();
    Object[] objReturn = new Object[10];
    try
    {
        db = new TimeAttendanceDataBaseDataContext();
        personnel = db.Personnels.FirstOrDefault(x => x.HashRecord == hashCode.Substring(0,10));
        objReturn[0] = personnel.ID;
        objReturn[1] = personnel.UserName;
        objReturn[2] = personnel.Password;
        objReturn[3] = personnel.FirstName;
        objReturn[4] = personnel.LastName;
        objReturn[5] = personnel.Mobile;
        objReturn[6] = personnel.Email;
        objReturn[7] = personnel.HashRecord;
        objReturn[8] = personnel.AccessLevel;
        objReturn[9] = personnel.PersonnelCode;
    }
    catch
    {
        objReturn[0] = null;
        objReturn[1] = null;
        objReturn[2] = null;
        objReturn[3] = null;
        objReturn[4] = null;
        objReturn[5] = null;
        objReturn[6] = null;
        objReturn[7] = null;
        objReturn[8] = null;
        objReturn[9] = null;

    }
    return objReturn;
}
James A Mohler
  • 11,060
  • 15
  • 46
  • 72
gwt
  • 2,331
  • 4
  • 37
  • 59
  • It looks like you're catching an exception and return an array containing 10 `null Objects`. – bluevector Aug 30 '12 at 12:26
  • 3
    may be exception occurred ? and u are returning null in catch – Waqar Janjua Aug 30 '12 at 12:26
  • Try to return some data about the exception. For example `objReturn[0] = -1; objReturn[1] = ex.Message;` – Steve Aug 30 '12 at 12:30
  • the code works fine in the web site ! i use the webservice in the website and It works fine ! but when calling It from a windows application or invoking it in IE it returns null ! – gwt Aug 30 '12 at 12:30
  • Can't you recreate this situation on your local environment? In this case you would be able to set a breakpoint – Claudio Redi Aug 30 '12 at 12:33

2 Answers2

2

An exception is happening inside your try block. Set a breakpoint there an debug the code to see what's wrong.

Maybe hashcode is null or have a length lower than 10? or db.Personnels.FirstOrDefault(...) is returning null?

As a side note, it would be good if you implement some logging logic so you can troubleshoot more easily in live environment. Log4net is a good option for this

Claudio Redi
  • 67,454
  • 15
  • 130
  • 155
0

I got the answear , the problem was that I had to change my apppool to local system in iis and the I could login to the webservice through my other applications

gwt
  • 2,331
  • 4
  • 37
  • 59