p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   .NET Web Services (http://p2p.wrox.com/forumdisplay.php?f=102)
-   -   Please help me with web methods (http://p2p.wrox.com/showthread.php?t=11637)

DiegoF April 9th, 2004 06:34 AM

Please help me with web methods
 
I've been days searching about this. I'm writing a web service that uses a class that is in a DLL. In some web methods it has to receive and return custom objects. The problem is that in the application, when I try to call the web method and pass the custom object it doesn't compile because the web service created it's own custom object and it can't be casted.

I tried to use the object created by the web service, but I get exceptions (Null reference errors).

What should I do? I understand that this issue has to be quite common.




planoie April 9th, 2004 03:54 PM

I have created several web service methods that use some custom objects. When I reference the web service, I get object "stubs" much in the same whay you get function stubs in the reference map code. I haven't had any problems casting or using those mapped objects in my web methods.

What kind of problems are you getting when you try to cast the objects? What kinds of objects are you building? What types of data members are in the objects?

Peter
-------------------------
Work smarter, not harder

DiegoF April 10th, 2004 09:45 AM

Firstly I was trying with a class thas has some numeric attributes and an ArrayList. Then, I tried with a basic one with string fields, but always get the same error when compiling.

If I modify the Reference.cs file, then I can compile, but I get NullReferenceException error.

In the next try, I just pass the strings so the web service builds the object, but when I try to store it (using a HashTable) it isn't stored. Did you tried storing objects in a web service?


planoie April 10th, 2004 11:10 AM

I'm sure what you mean by "storing objects in a web service".

Here's one of my web methods:

<WebMethod(Description:="Authenticates a ReminderService user.", MessageName:="LoadUserByLogin")> _
Public Function getUser(ByVal sUsername As String, ByVal sPassword As String) As userReturnArgs
    Return getUser(Nothing, sUsername, sPassword)
End Function

As you can see, the web service returns a custom data type. userReturnArgs is actually a class that contains another class. I have had no problems with doing this. I also have web methods that accept custom data types (my classes) as arguments and I have not had problems with this either.

Post some of the relevant code and maybe we can see what is wrong.

Peter
-------------------------
Work smarter, not harder


All times are GMT -4. The time now is 06:19 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.