Passing back a class in SOAP

burak

Well-known member
Joined
Jun 17, 2003
Messages
127
Hello,

I fixed the problem I was having before

http://www.computerhelp.forum/t73531.html

by including the .wsdl as a web reference in my client.

I changed the code to return a class insteadof a decimal, but I get soap errors on client when I try to access the values in the object. I am also having problems passing back a string. Decimal works fine.

Here is my code

-------------------

Imports System.Web.Services

Public Class temp_values
Public temp As Decimal
Public fUnit As String
End Class

<WebService(Namespace:="http://tempuri.org/")> _
Public Class CTemp
Inherits System.Web.Services.WebService

<WebMethod()> Public Function GetTemp(ByVal Temperature As Decimal, _
ByVal FromUnits As String ) As temp_values

Dim tVal As temp_values
tVal.fUnit = FromUnits

Select Case FromUnits.ToUpper.Chars(0)
Case "F" Fahrenheit
tVal.temp = ((Temperature - 32) * 5) / 9
Return tVal
Case "C" Celsius
tVal.temp = ((Temperature - 32) * 5) / 9
Return tVal
End Select
End Select

End Function

End Class
---------------------

The following page talks about returning a dataset
http://www.dotnetextreme.com/articles/complexDataType.asp

Do you know how to pass back user defined classes?

Thanks,

Burak
 
Have you refreshed the web reference on the client? If not that means the client is still expecting a decimal and not the string / user defined class.
 
Last edited by a moderator:
Back
Top