Error: System.ArgumentException: Cannot convert to System.Int32.

S

Simon Harris

I have created a web service, which when I call in my browser presents the
text form etc. When I click the button, I get this error:

System.ArgumentException: Cannot convert to System.Int32.
Parameter name: type ---> System.FormatException: Input string was not in
a
correct format.
at System.Number.ParseInt32(String s, NumberStyles style,
NumberFormatInfo info)
at System.String.System.IConvertible.ToInt32(IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType,
IFormatProvider provider)
at System.Web.Services.Protocols.ScalarFormatter.FromString(String
value,
Type type)
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.ScalarFormatter.FromString(String
value,
Type type)
at
System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValu
eCollection
collection)
at
System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest
request)
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.Invoke()
at
System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()This
seems to happen only when I have parameters of different data types, e.g.:

Works:
======
<WebMethod()> _
Public Function GetAddresses(ByVal a As String, ByVal b As String) As
DataSet

Causes Error:
===========
<WebMethod()> _
Public Function GetAddresses(ByVal a As String, ByVal b As Integer) As
DataSet

Any ideas/suggestions will be much appreciated.



Regards,

Simon.
 
K

Ken Cox [Microsoft MVP]

Hi Simon,

Are you able to show some of the code that is calling this Web service?

If the SOAP defaults the type to a string, your Web service is going to have
the problem you're seeing if it expects an integer.

Ken
MVP [ASP.NET]
 
S

Simon Harris

Ken Cox said:
Hi Simon,

Are you able to show some of the code that is calling this Web service?

If the SOAP defaults the type to a string, your Web service is going to
have the problem you're seeing if it expects an integer.

Ken
MVP [ASP.NET]

Hi Ken,

I solved it earlier - You were correct, it was expecting an Int, I was
passing it null.

Many Thanks for your reply.

Simon.
 

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

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top