Tech Off Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Cant get webservice to work. Could not be loaded error

Back to Forum: Tech Off
  • User profile image
    steinster

    Hi,

    I have this webservice;

    public class InfoSpreaderServices : System.Web.Services.WebService
        {
    
            [WebMethod]
            public void AddUser(int listRecno, string firstname, string lastname, string email) {
                if (!DataManager.EmailExists(listRecno, email)) {
                    DataManager.CreateNewRecipient(listRecno, firstname, lastname, email);
                }
                
            }
    
            [WebMethod]
            public void RemoveUser(int recipientRecno, string email) {
                DataRow r = DataManager.GetListRecipient(recipientRecno);
    
                if (r["Email"].ToString() == email) {
                    DataManager.DeleteRecipient(recipientRecno);
                }
            }
        }

     

    and I try to use the AddUser method like this;

    InfoSpreadServices.InfoSpreaderServicesSoapClient client = new InfoSpreadServices.InfoSpreaderServicesSoapClient();
    client.AddUser(int.Parse(TextBoxListRecno.Text), TextBoxFirstname.Text, TextBoxLastname.Text, TextBoxEmail.Text);

     

    But I always get this error;

    The operation 'AddUserAsync' could not be loaded because it has a parameter or return type of type System.ServiceModel.Channels.Message or a type that has MessageContractAttribute and other parameters of different types. When using System.ServiceModel.Channels.Message or types with MessageContractAttribute, the method must not use any other types of parameters.

     

     

    any ideas on how to fix this ??

  • User profile image
    vesuvius

    You can fix this by reading the message, but more code is required.

    You have decorated one or more objects with [MessageContract] instead of [OperationContract]. When you use this attribute you no longer pass individual parameters but the whole object instead. Please replace MessageContract with OperationContract or only pass in the class that has the MessageContract attribute

     

      
    public void AddUser(Recipient recipient)
    {
    
    }
    
    [MessageContract]
    public class Recipient
    {
    
    }
    

     

  • User profile image
    steinster

    ah ok, thanks ! Smiley

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.