Webservice problems.

Hello. I am desperately trying to send data from a client application to a webserver via a webservice. Apparently I cannot pass an object class as a parameter, so have decided to use a dataset. When I run the code, I get the following error at this line in Reference.vb:Dim results()AsObject =Me.Invoke("SendSpecs",NewObject() {serial})

An unhandled exception of type 'System.Web.Services.Protocols.SoapException' occurred in system.web.services.dll

Additional information: Server was unable to process request. --> Object reference not set to an instance of an object.

This occurs even when I simply request a dataset from the webservice. Here is the code for my webservice.

<WebMethod()>PublicFunction SendSpecs(ByVal serialAsString)As DataSet

Dim dsMainAs DataSet

Dim cmdAs SqlCommand =New SqlCommand

Dim paramAsNew SqlParameter

dsMain.Clear()

cnMain.Open()

cmd.CommandText = "Select * From PCSpecs Where SerialNo = @SerialNo"

param.ParameterName = "@SerialNo"

param.Value = serialNo

cmd.Parameters.Add(param)

cmd.Connection = cnMain

Dim daMainAsNew SqlDataAdapter(cmd)

daMain.Fill(dsMain, "PCSpecs")

cnMain.Close()

Return dsMain
I call the code client side by:dsSpec = WMIservices.SendSpecs(serial). Can anyone help me with this? I have been trying for ages, and really need this to work.

Thanks,
Robert

[2968 byte] By [hoffi] at [2007-12-23]
# 1

The obvious error is that the dataset is not created, yet you use it, thus the error "Object reference not set to an instance of an object"
Dim dsMain As DataSet = New DataSet should do it, if there are no subsequent errors.
You can debug Web services like any other project, set a breakpoint, set the Start Page of the project to be the asmx page containing the Web service and run it in the debugger.

Chris_S at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 2
can u send me the coding for my reference
laja at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 3
What do you mean you can't send an object in a webmethod?

Did you try something like this?

Public Class Specs
Public SpecID As String
Public SpecName As String
End Class

<WebMethod()>

Public Function SendSpecs(ByVal serial As String) As Specs

Dim spec As new Specs
spec.SpecID = 1
spec.SpecName = serial

Return spec

End Function

<WebMethod()>

Public Function ReceiveSpecs(ByVal spec As Specs) As Boolean

Dim serial As String = spec.SpecName

Return true

End Function
kbradl1 at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...

.NET Development

Site Classified