Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Can you pass an SPListItem object as a parameter into a custom [WebMethod] deployed into SharePoint? I understand that it would be essentially disconnected from the the SharePoint context if it was, but that suits me fine as I'm just saving some of this SPListItem data elsewhere (no updates).

I tried this for testing purposes but SPDev threw an error generating the .disco & .wsdl;

[WebMethod]
public bool saveData(SPListItem ticket, string action)
{

    string msg = "";

    try
    {
        msg += ticket.Xml.ToString();
        msg += Environment.NewLine;

    }catch(Exception ex){
        msg += ex.Message.ToString();
    }
    finally{

        processLog.WriteToLog(msg, LogFile_NM);
    }

    return true;

}

Something about this approach seems wrong, but I can't quite put my finger on it...

Thanks.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

SPListItem is not serializable so you cannot pass it as a parameter to a web service.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.