Testing webservice with parameter

G

Ger

Hi,
I am using vs.net2003 on a sbs2003 with IIS6 and SQL2000.

In vb.net I created on the sbs2003-machine a Webservice. When running the
project locally, I got the asmx-page with the available Webwservices. When
running the Webservice without parameters I got a the end the right data, but
when I run the second Webservice (with a parameter) I was asked to type in
the parameter and after invoking I got the following error:

System.Data.SqlClient.SqlException: Prepared statement '(@Param int)SELECT
ID, Voornaam, Tussenvoegsel, Achternaam, Tite' expects parameter @Param,
which was not supplied.
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
at
System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at AanzetWS.Service1.GetWZID(Int32 m_ID) in
C:\Inetpub\wwwroot\AanzetWS\Service1.asmx.vb:line 862

The code in my Webservice project looks like this:

<WebMethod()> _
Public Function GetWZVerkort() As dsWZVerkort
Dim ds As New dsWZVerkort
adapWZVerkort.Fill(ds)
Return ds
End Function

<WebMethod()> _
Public Function GetWZID(ByVal m_ID As Integer) As dsWZID
Dim ds As New dsWZID
adapWZID.Fill(ds)
Return ds
End Function

So the first function runs well and on the second function I got the error.
Why I got this error, while passing a (correct) parameter ?

Help is appreciated,

regards, Ger.
 
C

Cor Ligthert[MVP]

Ger,

AFAIK you can only send serialized data over the Internet (therefore
datasets), you can change the type of the ID into a string and than convert
it again to your integer in the webservice, I am for 80% sure that your
problem is than gone.

Cor
 
G

Ger

Thank you Cor for answering,

I probably was not clear enough. I understand what you answered, but I think
it is
not (yet) the case!

I run the webservice local on the server. I got a browser with all the
possible webservices of the asmx-page. I choosed the first one
(GetWZVerkort), clicked on
"Invoke" and received a XML-page with the right data.
Then I choosed the second one (GetWZID). I received an identical page, on
which I now have to enter a parameter (was asked within GetWZID-service). I
entered a (correct) parameter and clicked "Invoke". Now I got the mentioned
error!

When I tested GetWZID from a client (via the Internet), I received the same
error, while testing on Webservice GetWZVerkort, I receive a correct dataset.

Any other suggestions ?

regards, Ger.
 
M

Michel Posseth [MCP]

Your error is pretty obvious


Where is the parameter suplied to the table adapter ????

<WebMethod()> _
Public Function GetWZID(ByVal m_ID As Integer) As dsWZID
Dim ds As New dsWZID
adapWZID.Fill(ds)
Return ds
End Function

Why are you suplying a m_id parameter if you do not do anything with it in
your method call ??
if i look at your error stack it is obvious that @Param int should have
been your method parameter m_ID
however you do not suply this to the table adapter you do nothing with it

so create a table adapter method adapWZID.FillById(ds,m_ID ) and your
problem should be solved

HTH

Michel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top