Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - I need help

 
Thread Tools Search this Thread
Old 04-17-2006, 11:34 PM   #1
Default I need help


I don't know if it's me or .net is just getting more complicated. I am trying
to call a sp and pass a parameter and return the data using VB2005. First I
couldn't find any docs with samples. Second I tryed this

<%@ WebService Language="VB" Class="GetList" %>
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Data
Imports System.Data.SqlClient


<WebService(Namespace := "http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicPr ofile1_1)> _
Public Class GetList
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Function GetProducts(ByVal sName As String) As SqlDataReader
Try
Dim conn As SqlConnection
Dim cmd As SqlCommand
Dim oReader As SqlDataReader

conn = New
SqlConnection("Server=machine\Enterprise;Database= Staging;User
ID=me;Password=pass")
conn.Open()

cmd = New SqlCommand("GetProdList", conn)
cmd.CommandType = CommandType.StoredProcedure

Dim param As SqlParameter =
cmd.Parameters.AddWithValue("@productName", sName)


conn.Open()
oReader = cmd.ExecuteReader()
Return oReader

Catch ex As Exception

End Try





End Function

End Class

and get the error



To be XML serializable, types which inherit from IEnumerable must have an
implementation of Add(System.Object) at all levels of their inheritance
hierarchy. System.Data.SqlClient.SqlDataReader does not implement
Add(System.Object).
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.InvalidOperationException: To be XML serializable,
types which inherit from IEnumerable must have an implementation of
Add(System.Object) at all levels of their inheritance hierarchy.
System.Data.SqlClient.SqlDataReader does not implement Add(System.Object).

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:


[InvalidOperationException: To be XML serializable, types which inherit from
IEnumerable must have an implementation of Add(System.Object) at all levels
of their inheritance hierarchy. System.Data.SqlClient.SqlDataReader does not
implement Add(System.Object).]
System.Xml.Serialization.TypeScope.GetEnumeratorEl ementType(Type type,
TypeFlags& flags) +731
System.Xml.Serialization.TypeScope.ImportTypeDesc( Type type, MemberInfo
memberInfo, Boolean directReference) +1996
System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type, MemberInfo
source, Boolean directReference, Boolean throwOnError) +135

System.Xml.Serialization.XmlReflectionImporter.Imp ortMemberMapping(XmlReflectionMember
xmlReflectionMember, String ns, XmlReflectionMember[] xmlReflectionMembers,
Boolean rpc, Boolean openModel) +78

System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlReflectionMember[]
xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc,
Boolean openModel) +280

[InvalidOperationException: There was an error reflecting
'GetProductsResult'.]

System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlReflectionMember[]
xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc,
Boolean openModel) +881

System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(String
elementName, String ns, XmlReflectionMember[] members, Boolean
hasWrapperElement, Boolean rpc, Boolean openModel, XmlMappingAccess access)
+112

System.Web.Services.Protocols.SoapReflector.Import MembersMapping(XmlReflectionImporter
xmlImporter, SoapReflectionImporter soapImporter, Boolean
serviceDefaultIsEncoded, Boolean rpc, SoapBindingUse use, SoapParameterStyle
paramStyle, String elementName, String elementNamespace, Boolean nsIsDefault,
XmlReflectionMember[] members, Boolean validate, Boolean openModel, String
key, Boolean writeAccess) +203

System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs) +3391

[InvalidOperationException: Method GetList.GetProducts can not be reflected.]

System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs) +6633
System.Web.Services.Description.SoapProtocolReflec tor.ReflectMethod() +134

System.Web.Services.Description.ProtocolReflector. ReflectBinding(ReflectedBinding reflectedBinding) +2512
System.Web.Services.Description.ProtocolReflector. Reflect() +626

System.Web.Services.Description.ServiceDescription Reflector.ReflectInternal(ProtocolReflector[] reflectors) +560
System.Web.Services.Description.ServiceDescription Reflector.Reflect(Type
type, String url) +117
System.Web.Services.Protocols.DocumentationServerT ype..ctor(Type type,
String uri) +159
System.Web.Services.Protocols.DocumentationServerP rotocol.Initialize() +335
System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&
abortProcessing) +99

[InvalidOperationException: Unable to handle request.]
System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&
abortProcessing) +258

System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
type, HttpContext context, HttpRequest request, HttpResponse response) +93

[InvalidOperationException: Failed to handle request.]

System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
type, HttpContext context, HttpRequest request, HttpResponse response) +240

System.Web.Services.Protocols.WebServiceHandlerFac tory.GetHandler(HttpContext
context, String verb, String url, String filePath) +106
Microsoft.Web.Services.ScriptHandlerFactory.GetHan dler(HttpContext
context, String requestType, String url, String pathTranslated) +246
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
+328

System.Web.MapHandlerExecutionStep.System.Web.Http Application.IExecutionStep.Execute() +139
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +146




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET
Version:2.0.50727.42

Please advice.



=?Utf-8?B?Q2hyaXM=?=
  Reply With Quote
Old 04-17-2006, 11:46 PM   #2
Chris Chilvers
 
Posts: n/a
Default Re: I need help
> To be XML serializable, types which inherit from IEnumerable must have an
> implementation of Add(System.Object) at all levels of their inheritance
> hierarchy. System.Data.SqlClient.SqlDataReader does not implement
> Add(System.Object).
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information about
> the error and where it originated in the code.


What it's complaining about is that the value returned by the web method isn't anything
it can serialize before sending to the client.

> Return oReader


This is the line to look at, did you really mean to try and send the client machine your data reader
complete with the database connection?

You'll have to read the results out into an array and send the array of results back to the client.


Chris Chilvers
  Reply With Quote
Old 04-17-2006, 11:57 PM   #3
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
 
Posts: n/a
Default RE: I need help
You cannot pass a sqldatareader from a webservice to a client function
because the sqldatareader is a means of reading a forward-only stream of data
that keeps the underlying connection opened until you call the
sqldatareader.close method. You use the (disconnected) dataset to pass the
data from a webservice to a client application. Here is a sample
http://msdn2.microsoft.com/en-us/lib...er(VS.80).aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"Chris" wrote:

> I don't know if it's me or .net is just getting more complicated. I am trying
> to call a sp and pass a parameter and return the data using VB2005. First I
> couldn't find any docs with samples. Second I tryed this
>
> <%@ WebService Language="VB" Class="GetList" %>
> Imports System.Web
> Imports System.Web.Services
> Imports System.Web.Services.Protocols
> Imports System.Data
> Imports System.Data.SqlClient
>
>
> <WebService(Namespace := "http://tempuri.org/")> _
> <WebServiceBinding(ConformsTo:=WsiProfiles.BasicPr ofile1_1)> _
> Public Class GetList
> Inherits System.Web.Services.WebService
>
> <WebMethod()> _
> Public Function GetProducts(ByVal sName As String) As SqlDataReader
> Try
> Dim conn As SqlConnection
> Dim cmd As SqlCommand
> Dim oReader As SqlDataReader
>
> conn = New
> SqlConnection("Server=machine\Enterprise;Database= Staging;User
> ID=me;Password=pass")
> conn.Open()
>
> cmd = New SqlCommand("GetProdList", conn)
> cmd.CommandType = CommandType.StoredProcedure
>
> Dim param As SqlParameter =
> cmd.Parameters.AddWithValue("@productName", sName)
>
>
> conn.Open()
> oReader = cmd.ExecuteReader()
> Return oReader
>
> Catch ex As Exception
>
> End Try
>
>
>
>
>
> End Function
>
> End Class
>
> and get the error
>
>
>
> To be XML serializable, types which inherit from IEnumerable must have an
> implementation of Add(System.Object) at all levels of their inheritance
> hierarchy. System.Data.SqlClient.SqlDataReader does not implement
> Add(System.Object).
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information about
> the error and where it originated in the code.
>
> Exception Details: System.InvalidOperationException: To be XML serializable,
> types which inherit from IEnumerable must have an implementation of
> Add(System.Object) at all levels of their inheritance hierarchy.
> System.Data.SqlClient.SqlDataReader does not implement Add(System.Object).
>
> Source Error:
>
> An unhandled exception was generated during the execution of the current web
> request. Information regarding the origin and location of the exception can
> be identified using the exception stack trace below.
>
> Stack Trace:
>
>
> [InvalidOperationException: To be XML serializable, types which inherit from
> IEnumerable must have an implementation of Add(System.Object) at all levels
> of their inheritance hierarchy. System.Data.SqlClient.SqlDataReader does not
> implement Add(System.Object).]
> System.Xml.Serialization.TypeScope.GetEnumeratorEl ementType(Type type,
> TypeFlags& flags) +731
> System.Xml.Serialization.TypeScope.ImportTypeDesc( Type type, MemberInfo
> memberInfo, Boolean directReference) +1996
> System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type, MemberInfo
> source, Boolean directReference, Boolean throwOnError) +135
>
> System.Xml.Serialization.XmlReflectionImporter.Imp ortMemberMapping(XmlReflectionMember
> xmlReflectionMember, String ns, XmlReflectionMember[] xmlReflectionMembers,
> Boolean rpc, Boolean openModel) +78
>
> System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlReflectionMember[]
> xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc,
> Boolean openModel) +280
>
> [InvalidOperationException: There was an error reflecting
> 'GetProductsResult'.]
>
> System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlReflectionMember[]
> xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc,
> Boolean openModel) +881
>
> System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(String
> elementName, String ns, XmlReflectionMember[] members, Boolean
> hasWrapperElement, Boolean rpc, Boolean openModel, XmlMappingAccess access)
> +112
>
> System.Web.Services.Protocols.SoapReflector.Import MembersMapping(XmlReflectionImporter
> xmlImporter, SoapReflectionImporter soapImporter, Boolean
> serviceDefaultIsEncoded, Boolean rpc, SoapBindingUse use, SoapParameterStyle
> paramStyle, String elementName, String elementNamespace, Boolean nsIsDefault,
> XmlReflectionMember[] members, Boolean validate, Boolean openModel, String
> key, Boolean writeAccess) +203
>
> System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
> methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
> SoapReflectionImporter soapImporter, String defaultNs) +3391
>
> [InvalidOperationException: Method GetList.GetProducts can not be reflected.]
>
> System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
> methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
> SoapReflectionImporter soapImporter, String defaultNs) +6633
> System.Web.Services.Description.SoapProtocolReflec tor.ReflectMethod() +134
>
> System.Web.Services.Description.ProtocolReflector. ReflectBinding(ReflectedBinding reflectedBinding) +2512
> System.Web.Services.Description.ProtocolReflector. Reflect() +626
>
> System.Web.Services.Description.ServiceDescription Reflector.ReflectInternal(ProtocolReflector[] reflectors) +560
> System.Web.Services.Description.ServiceDescription Reflector.Reflect(Type
> type, String url) +117
> System.Web.Services.Protocols.DocumentationServerT ype..ctor(Type type,
> String uri) +159
> System.Web.Services.Protocols.DocumentationServerP rotocol.Initialize() +335
> System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
> HttpContext context, HttpRequest request, HttpResponse response, Boolean&
> abortProcessing) +99
>
> [InvalidOperationException: Unable to handle request.]
> System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
> HttpContext context, HttpRequest request, HttpResponse response, Boolean&
> abortProcessing) +258
>
> System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
> type, HttpContext context, HttpRequest request, HttpResponse response) +93
>
> [InvalidOperationException: Failed to handle request.]
>
> System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
> type, HttpContext context, HttpRequest request, HttpResponse response) +240
>
> System.Web.Services.Protocols.WebServiceHandlerFac tory.GetHandler(HttpContext
> context, String verb, String url, String filePath) +106
> Microsoft.Web.Services.ScriptHandlerFactory.GetHan dler(HttpContext
> context, String requestType, String url, String pathTranslated) +246
> System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
> requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
> +328
>
> System.Web.MapHandlerExecutionStep.System.Web.Http Application.IExecutionStep.Execute() +139
> System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
> completedSynchronously) +146
>
>
>
>
> --------------------------------------------------------------------------------
> Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET
> Version:2.0.50727.42
>
> Please advice.
>



=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
  Reply With Quote
Old 04-18-2006, 12:05 AM   #4
=?Utf-8?B?Q2hyaXM=?=
 
Posts: n/a
Default RE: I need help
So then what does the Data access block returns when you use the
"ExecuteReader"?

"Chris" wrote:

> I don't know if it's me or .net is just getting more complicated. I am trying
> to call a sp and pass a parameter and return the data using VB2005. First I
> couldn't find any docs with samples. Second I tryed this
>
> <%@ WebService Language="VB" Class="GetList" %>
> Imports System.Web
> Imports System.Web.Services
> Imports System.Web.Services.Protocols
> Imports System.Data
> Imports System.Data.SqlClient
>
>
> <WebService(Namespace := "http://tempuri.org/")> _
> <WebServiceBinding(ConformsTo:=WsiProfiles.BasicPr ofile1_1)> _
> Public Class GetList
> Inherits System.Web.Services.WebService
>
> <WebMethod()> _
> Public Function GetProducts(ByVal sName As String) As SqlDataReader
> Try
> Dim conn As SqlConnection
> Dim cmd As SqlCommand
> Dim oReader As SqlDataReader
>
> conn = New
> SqlConnection("Server=machine\Enterprise;Database= Staging;User
> ID=me;Password=pass")
> conn.Open()
>
> cmd = New SqlCommand("GetProdList", conn)
> cmd.CommandType = CommandType.StoredProcedure
>
> Dim param As SqlParameter =
> cmd.Parameters.AddWithValue("@productName", sName)
>
>
> conn.Open()
> oReader = cmd.ExecuteReader()
> Return oReader
>
> Catch ex As Exception
>
> End Try
>
>
>
>
>
> End Function
>
> End Class
>
> and get the error
>
>
>
> To be XML serializable, types which inherit from IEnumerable must have an
> implementation of Add(System.Object) at all levels of their inheritance
> hierarchy. System.Data.SqlClient.SqlDataReader does not implement
> Add(System.Object).
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information about
> the error and where it originated in the code.
>
> Exception Details: System.InvalidOperationException: To be XML serializable,
> types which inherit from IEnumerable must have an implementation of
> Add(System.Object) at all levels of their inheritance hierarchy.
> System.Data.SqlClient.SqlDataReader does not implement Add(System.Object).
>
> Source Error:
>
> An unhandled exception was generated during the execution of the current web
> request. Information regarding the origin and location of the exception can
> be identified using the exception stack trace below.
>
> Stack Trace:
>
>
> [InvalidOperationException: To be XML serializable, types which inherit from
> IEnumerable must have an implementation of Add(System.Object) at all levels
> of their inheritance hierarchy. System.Data.SqlClient.SqlDataReader does not
> implement Add(System.Object).]
> System.Xml.Serialization.TypeScope.GetEnumeratorEl ementType(Type type,
> TypeFlags& flags) +731
> System.Xml.Serialization.TypeScope.ImportTypeDesc( Type type, MemberInfo
> memberInfo, Boolean directReference) +1996
> System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type, MemberInfo
> source, Boolean directReference, Boolean throwOnError) +135
>
> System.Xml.Serialization.XmlReflectionImporter.Imp ortMemberMapping(XmlReflectionMember
> xmlReflectionMember, String ns, XmlReflectionMember[] xmlReflectionMembers,
> Boolean rpc, Boolean openModel) +78
>
> System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlReflectionMember[]
> xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc,
> Boolean openModel) +280
>
> [InvalidOperationException: There was an error reflecting
> 'GetProductsResult'.]
>
> System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlReflectionMember[]
> xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc,
> Boolean openModel) +881
>
> System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(String
> elementName, String ns, XmlReflectionMember[] members, Boolean
> hasWrapperElement, Boolean rpc, Boolean openModel, XmlMappingAccess access)
> +112
>
> System.Web.Services.Protocols.SoapReflector.Import MembersMapping(XmlReflectionImporter
> xmlImporter, SoapReflectionImporter soapImporter, Boolean
> serviceDefaultIsEncoded, Boolean rpc, SoapBindingUse use, SoapParameterStyle
> paramStyle, String elementName, String elementNamespace, Boolean nsIsDefault,
> XmlReflectionMember[] members, Boolean validate, Boolean openModel, String
> key, Boolean writeAccess) +203
>
> System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
> methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
> SoapReflectionImporter soapImporter, String defaultNs) +3391
>
> [InvalidOperationException: Method GetList.GetProducts can not be reflected.]
>
> System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
> methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
> SoapReflectionImporter soapImporter, String defaultNs) +6633
> System.Web.Services.Description.SoapProtocolReflec tor.ReflectMethod() +134
>
> System.Web.Services.Description.ProtocolReflector. ReflectBinding(ReflectedBinding reflectedBinding) +2512
> System.Web.Services.Description.ProtocolReflector. Reflect() +626
>
> System.Web.Services.Description.ServiceDescription Reflector.ReflectInternal(ProtocolReflector[] reflectors) +560
> System.Web.Services.Description.ServiceDescription Reflector.Reflect(Type
> type, String url) +117
> System.Web.Services.Protocols.DocumentationServerT ype..ctor(Type type,
> String uri) +159
> System.Web.Services.Protocols.DocumentationServerP rotocol.Initialize() +335
> System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
> HttpContext context, HttpRequest request, HttpResponse response, Boolean&
> abortProcessing) +99
>
> [InvalidOperationException: Unable to handle request.]
> System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
> HttpContext context, HttpRequest request, HttpResponse response, Boolean&
> abortProcessing) +258
>
> System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
> type, HttpContext context, HttpRequest request, HttpResponse response) +93
>
> [InvalidOperationException: Failed to handle request.]
>
> System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
> type, HttpContext context, HttpRequest request, HttpResponse response) +240
>
> System.Web.Services.Protocols.WebServiceHandlerFac tory.GetHandler(HttpContext
> context, String verb, String url, String filePath) +106
> Microsoft.Web.Services.ScriptHandlerFactory.GetHan dler(HttpContext
> context, String requestType, String url, String pathTranslated) +246
> System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
> requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
> +328
>
> System.Web.MapHandlerExecutionStep.System.Web.Http Application.IExecutionStep.Execute() +139
> System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
> completedSynchronously) +146
>
>
>
>
> --------------------------------------------------------------------------------
> Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET
> Version:2.0.50727.42
>
> Please advice.
>



=?Utf-8?B?Q2hyaXM=?=
  Reply With Quote
Old 04-18-2006, 12:11 AM   #5
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
 
Posts: n/a
Default RE: I need help
http://msdn2.microsoft.com/en-us/lib...er(VS.80).aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"Chris" wrote:

> So then what does the Data access block returns when you use the
> "ExecuteReader"?
>
> "Chris" wrote:
>
> > I don't know if it's me or .net is just getting more complicated. I am trying
> > to call a sp and pass a parameter and return the data using VB2005. First I
> > couldn't find any docs with samples. Second I tryed this
> >
> > <%@ WebService Language="VB" Class="GetList" %>
> > Imports System.Web
> > Imports System.Web.Services
> > Imports System.Web.Services.Protocols
> > Imports System.Data
> > Imports System.Data.SqlClient
> >
> >
> > <WebService(Namespace := "http://tempuri.org/")> _
> > <WebServiceBinding(ConformsTo:=WsiProfiles.BasicPr ofile1_1)> _
> > Public Class GetList
> > Inherits System.Web.Services.WebService
> >
> > <WebMethod()> _
> > Public Function GetProducts(ByVal sName As String) As SqlDataReader
> > Try
> > Dim conn As SqlConnection
> > Dim cmd As SqlCommand
> > Dim oReader As SqlDataReader
> >
> > conn = New
> > SqlConnection("Server=machine\Enterprise;Database= Staging;User
> > ID=me;Password=pass")
> > conn.Open()
> >
> > cmd = New SqlCommand("GetProdList", conn)
> > cmd.CommandType = CommandType.StoredProcedure
> >
> > Dim param As SqlParameter =
> > cmd.Parameters.AddWithValue("@productName", sName)
> >
> >
> > conn.Open()
> > oReader = cmd.ExecuteReader()
> > Return oReader
> >
> > Catch ex As Exception
> >
> > End Try
> >
> >
> >
> >
> >
> > End Function
> >
> > End Class
> >
> > and get the error
> >
> >
> >
> > To be XML serializable, types which inherit from IEnumerable must have an
> > implementation of Add(System.Object) at all levels of their inheritance
> > hierarchy. System.Data.SqlClient.SqlDataReader does not implement
> > Add(System.Object).
> > Description: An unhandled exception occurred during the execution of the
> > current web request. Please review the stack trace for more information about
> > the error and where it originated in the code.
> >
> > Exception Details: System.InvalidOperationException: To be XML serializable,
> > types which inherit from IEnumerable must have an implementation of
> > Add(System.Object) at all levels of their inheritance hierarchy.
> > System.Data.SqlClient.SqlDataReader does not implement Add(System.Object).
> >
> > Source Error:
> >
> > An unhandled exception was generated during the execution of the current web
> > request. Information regarding the origin and location of the exception can
> > be identified using the exception stack trace below.
> >
> > Stack Trace:
> >
> >
> > [InvalidOperationException: To be XML serializable, types which inherit from
> > IEnumerable must have an implementation of Add(System.Object) at all levels
> > of their inheritance hierarchy. System.Data.SqlClient.SqlDataReader does not
> > implement Add(System.Object).]
> > System.Xml.Serialization.TypeScope.GetEnumeratorEl ementType(Type type,
> > TypeFlags& flags) +731
> > System.Xml.Serialization.TypeScope.ImportTypeDesc( Type type, MemberInfo
> > memberInfo, Boolean directReference) +1996
> > System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type, MemberInfo
> > source, Boolean directReference, Boolean throwOnError) +135
> >
> > System.Xml.Serialization.XmlReflectionImporter.Imp ortMemberMapping(XmlReflectionMember
> > xmlReflectionMember, String ns, XmlReflectionMember[] xmlReflectionMembers,
> > Boolean rpc, Boolean openModel) +78
> >
> > System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlReflectionMember[]
> > xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc,
> > Boolean openModel) +280
> >
> > [InvalidOperationException: There was an error reflecting
> > 'GetProductsResult'.]
> >
> > System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlReflectionMember[]
> > xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc,
> > Boolean openModel) +881
> >
> > System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(String
> > elementName, String ns, XmlReflectionMember[] members, Boolean
> > hasWrapperElement, Boolean rpc, Boolean openModel, XmlMappingAccess access)
> > +112
> >
> > System.Web.Services.Protocols.SoapReflector.Import MembersMapping(XmlReflectionImporter
> > xmlImporter, SoapReflectionImporter soapImporter, Boolean
> > serviceDefaultIsEncoded, Boolean rpc, SoapBindingUse use, SoapParameterStyle
> > paramStyle, String elementName, String elementNamespace, Boolean nsIsDefault,
> > XmlReflectionMember[] members, Boolean validate, Boolean openModel, String
> > key, Boolean writeAccess) +203
> >
> > System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
> > methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
> > SoapReflectionImporter soapImporter, String defaultNs) +3391
> >
> > [InvalidOperationException: Method GetList.GetProducts can not be reflected.]
> >
> > System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
> > methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
> > SoapReflectionImporter soapImporter, String defaultNs) +6633
> > System.Web.Services.Description.SoapProtocolReflec tor.ReflectMethod() +134
> >
> > System.Web.Services.Description.ProtocolReflector. ReflectBinding(ReflectedBinding reflectedBinding) +2512
> > System.Web.Services.Description.ProtocolReflector. Reflect() +626
> >
> > System.Web.Services.Description.ServiceDescription Reflector.ReflectInternal(ProtocolReflector[] reflectors) +560
> > System.Web.Services.Description.ServiceDescription Reflector.Reflect(Type
> > type, String url) +117
> > System.Web.Services.Protocols.DocumentationServerT ype..ctor(Type type,
> > String uri) +159
> > System.Web.Services.Protocols.DocumentationServerP rotocol.Initialize() +335
> > System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
> > HttpContext context, HttpRequest request, HttpResponse response, Boolean&
> > abortProcessing) +99
> >
> > [InvalidOperationException: Unable to handle request.]
> > System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
> > HttpContext context, HttpRequest request, HttpResponse response, Boolean&
> > abortProcessing) +258
> >
> > System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
> > type, HttpContext context, HttpRequest request, HttpResponse response) +93
> >
> > [InvalidOperationException: Failed to handle request.]
> >
> > System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
> > type, HttpContext context, HttpRequest request, HttpResponse response) +240
> >
> > System.Web.Services.Protocols.WebServiceHandlerFac tory.GetHandler(HttpContext
> > context, String verb, String url, String filePath) +106
> > Microsoft.Web.Services.ScriptHandlerFactory.GetHan dler(HttpContext
> > context, String requestType, String url, String pathTranslated) +246
> > System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
> > requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
> > +328
> >
> > System.Web.MapHandlerExecutionStep.System.Web.Http Application.IExecutionStep.Execute() +139
> > System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
> > completedSynchronously) +146
> >
> >
> >
> >
> > --------------------------------------------------------------------------------
> > Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET
> > Version:2.0.50727.42
> >
> > Please advice.
> >



=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46