Ask a Question related to ASP.NET Web Services, Design and Development.
-
Arcadius A. #1
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
-
XML document as input parameter ot WS ?
Hei, I have to create web service which accepts xml document as parameter: <CATALOG> <PLANT> -
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... -
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... -
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... -
Arcadius A. #2
Re: Custom object as input parameter
Arcadius A. wrote:
I figured out the problem.> 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.
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
-
Nic #3
Re: Custom object as input parameter
Can you send me the comple code. I'm trying to do the same task .
Thanks,Nic Guest
-
Unregistered #4
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



Reply With Quote

