Custom object as input parameter

Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default Custom object as input parameter

    Hello!
    I'm implementing a simple .NET(C#) web service.
    The experiment is to pass custom object or complex data type as the
    input parameter to my web service.

    I have created a custom class:

    [Serializable]
    public class Person
    {
    private int userid;
    private string username;
    ....
    public string Username
    {
    get{ return username;}
    set{username=value;}
    }
    ...
    }

    Now, my web service has a method:

    [WebMethod]
    public int addUser(Person p)
    {
    Console.WriteLine("User ID is: "+p.Username);// line#278 !
    return 0;
    }


    At the top of the web service provider class, I have
    [System.Xml.Serialization.XmlInclude(typeof(Person) )]

    I have a .NET GUI client that takes as input a userID, username etc etc.
    When I call the addUser() method using the .NET client, it just fails,
    complaining about "System.NullReferenceException: Object reference not
    set to an instance of an object .....
    at addUser(Person p) in ...dp.asmx.cs line 278 "

    So, there is something wrong with the web service provider.
    I'm sure that my client works fine and send a non-empty object
    correctly(I've tested it with a Java implementation of the same service,
    It also works fine with other methods in this problememtic .NET
    provider, but I'm having troubles with the only method that takes
    complex data type.) It seems(?) that the problem is with the web service
    provider not being able to unmarshall the sent object.


    Any help is welcome.

    Arcadius.

    Arcadius A. Guest

  2. Similar Questions and Discussions

    1. XML document as input parameter ot WS ?
      Hei, I have to create web service which accepts xml document as parameter: <CATALOG> <PLANT>
    2. Custom object parameter
      I have a web method which works when i send a custom object as a parameter. Today i added a DataSet after the Custom object and it wouldn't execute...
    3. Get input parameter values
      Hi Is there any way to get the values of input parameter of current executing web method programmatically? I just want to put the input parameters...
    4. output/input parameter
      i follow this help: http://support.microsoft.com/default.aspx?scid=kb;en- us;209576 to synchronize two combo boxes. the form works but the form...
  3. #2

    Default Re: Custom object as input parameter

    Arcadius A. wrote:
    > Hello!
    > I'm implementing a simple .NET(C#) web service.
    > The experiment is to pass custom object or complex data type as the
    > input parameter to my web service.
    I figured out the problem.
    In the XML file sent to the WS provider, is and element of
    <user>...<user> while the service provider was expecting a parameter
    <p>...<p>
    So the problem was that the called parameter on the client has a
    different name than the parameter on the server.

    I've just changed the name and it's working.

    Thanks.

    Arcadius.

    Arcadius A. Guest

  4. #3

    Default Re: Custom object as input parameter

    Can you send me the comple code. I'm trying to do the same task .

    Thanks,
    Nic Guest

  5. #4

    Default Re: Custom object as input parameter

    Can you please send me the code for this task? I'm trying to achieve the same task.

    Thanks,
    Unregistered Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139