473,385 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem with webservice returning an array (You must implement a default accessor on System.Array because it inherits from ICollection. )??

I have a webservice that I wanted to return an ArrayList..Well the service
compiles and runs when I have the output defined as ArrayList, but the WSDL
defines the output as an Object so I was having a problem in the calling
program. I searched online and found suggestions that I return an Array
instead so I modified my code (below) to return an Array instead of an
ArrayList. Now I get the message when I try to run just my webservice
saying " You must implement.." The code and complete message are below. I
am unsure of where to go from here. I have found several other people that
had similar problems, but nothing seems to work. Thanks for your help.

<WebMethod()> _

Public Function GetTitlesForBin(ByVal BinNum As String) As Array

Dim sSql As String

Dim MyTitles As ArrayList = New ArrayList

Dim oConn As New SqlClient.SqlConnection(gMerch)

sSql = "SELECT P.POSDesc, X.UPC FROM Bin_Xref X "

sSql = sSql & " LEFT JOIN tblItm I"

sSql = sSql & " ON X.UPC = I.UPC"

sSql = sSql & " LEFT JOIN tblPrd P"

sSql = sSql & " ON I.GrphcKey = P.GrphcKey"

sSql = sSql & " WHERE X.Bin_Num='" & BinNum & "'"

sSql = sSql & " ORDER BY P.POSDesc"

Dim oCmd As New SqlClient.SqlCommand(sSql, oConn)

Dim oRead As SqlClient.SqlDataReader

oConn.Open()

oRead = oCmd.ExecuteReader

While oRead.Read

MyTitles.Add(Convert.ToString(oRead("POSDesc")))

MyTitles.Add(Convert.ToString(oRead("UPC")))

End While

oRead.Close()

oCmd.Dispose()

oConn.Dispose()

Return MyTitles.ToArray

End Function

____________________ERROR MESSAGE____________

You must implement a default accessor on System.Array because it inherits
from ICollection.
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: You must implement a
default accessor on System.Array because it inherits from ICollection.

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: You must implement a default accessor on
System.Array because it inherits from ICollection.]
System.Xml.Serialization.TypeScope.GetCollectionEl ementType(Type type)
System.Xml.Serialization.TypeScope.ImportTypeDesc( Type type, Boolean
canBePrimitive, MemberInfo memberInfo)
System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type, MemberInfo source,
Boolean directReference)
System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type)
System.Xml.Serialization.XmlReflectionImporter.Imp ortMemberMapping(XmlReflectionMember
xmlReflectionMember, String ns, XmlReflectionMember[] xmlReflectionMembers)
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlReflectionMember[]
xmlReflectionMembers, String ns, Boolean hasWrapperElement)
[InvalidOperationException: There was an error reflecting
'GetTitlesForBinResult'.]
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlReflectionMember[]
xmlReflectionMembers, String ns, Boolean hasWrapperElement)
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(String
elementName, String ns, XmlReflectionMember[] members, Boolean
hasWrapperElement)
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)
System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs)
[InvalidOperationException: Method ItemLookup.GetTitlesForBin can not be
reflected.]
System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs)
System.Web.Services.Description.SoapProtocolReflec tor.ReflectMethod()
System.Web.Services.Description.ProtocolReflector. ReflectBinding(ReflectedBinding
reflectedBinding)
System.Web.Services.Description.ProtocolReflector. Reflect()
System.Web.Services.Description.ServiceDescription Reflector.ReflectInternal(ProtocolReflector[]
reflectors)
System.Web.Services.Description.ServiceDescription Reflector.Reflect(Type
type, String url)
System.Web.Services.Protocols.DocumentationServerT ype..ctor(Type type,
String uri)
System.Web.Services.Protocols.DocumentationServerP rotocol.Initialize()
System.Web.Services.Protocols.ServerProtocol.SetCo ntext(Type type,
HttpContext context, HttpRequest request, HttpResponse response)
System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&
abortProcessing) [InvalidOperationException: Unable to handle request.]
System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&
abortProcessing)
System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
type, HttpContext context, HttpRequest request, HttpResponse response)
[InvalidOperationException: Failed to handle request.]
System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
type, HttpContext context, HttpRequest request, HttpResponse response)
System.Web.Services.Protocols.WebServiceHandlerFac tory.GetHandler(HttpContext
context, String verb, String url, String filePath)
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, String path, String pathTranslated, Boolean useAppConfig)
System.Web.MapHandlerExecutionStep.System.Web.Http Application+IExecutionStep.Execute()

Stacey Levine


Nov 23 '05 #1
5 19545
Hi Stacey,

Welcome to MSDN newsgroup.
From your description, in one of your ASP.NET webservice's webmethod,
you're returning a List of custom objects(string values), you used to use
ArrayList , and it now changed to use Array , but continue get the
"You must implement a default accessor on System.Array because it inherits
from ICollection. "
error when calling the webservice at clientside, yes?

AS for the return type, yes, generally we should avoid using .NET specific
type, so changing ArrayList to Array is a reasonable suggesiton. However, I
think the "Array" other member mentioned maybe means a specific
strong-named Array. For example,
int[] or string[]

So have you tried define your webmethod's return value as a explicit
defined string array like:

<WebMethod()>
Public Function GetTitlesForBin(ByVal BinNum as String) as String()
.....

also, you can check what's the type the clientside generated for this
webmethod in the proxy class. Generally there won't occur problems with
normal Array object.

Please have a test and feel free to post here if you got any new findings.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
From: "Stacey Levine" <st****@newsgroup.nospam>
Subject: Problem with webservice returning an array (You must implement a
default accessor on System.Array because it inherits from ICollection. )??
Date: Tue, 20 Sep 2005 14:32:03 -0400
Lines: 162
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
Message-ID: <e0**************@TK2MSFTNGP15.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: 208.49.251.54
Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
microsoft.public.dotnet.framework.webservices:7961
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

I have a webservice that I wanted to return an ArrayList..Well the service
compiles and runs when I have the output defined as ArrayList, but the WSDL
defines the output as an Object so I was having a problem in the calling
program. I searched online and found suggestions that I return an Array
instead so I modified my code (below) to return an Array instead of an
ArrayList. Now I get the message when I try to run just my webservice
saying " You must implement.." The code and complete message are below. I
am unsure of where to go from here. I have found several other people that
had similar problems, but nothing seems to work. Thanks for your help.

<WebMethod()> _

Public Function GetTitlesForBin(ByVal BinNum As String) As Array

Dim sSql As String

Dim MyTitles As ArrayList = New ArrayList

Dim oConn As New SqlClient.SqlConnection(gMerch)

sSql = "SELECT P.POSDesc, X.UPC FROM Bin_Xref X "

sSql = sSql & " LEFT JOIN tblItm I"

sSql = sSql & " ON X.UPC = I.UPC"

sSql = sSql & " LEFT JOIN tblPrd P"

sSql = sSql & " ON I.GrphcKey = P.GrphcKey"

sSql = sSql & " WHERE X.Bin_Num='" & BinNum & "'"

sSql = sSql & " ORDER BY P.POSDesc"

Dim oCmd As New SqlClient.SqlCommand(sSql, oConn)

Dim oRead As SqlClient.SqlDataReader

oConn.Open()

oRead = oCmd.ExecuteReader

While oRead.Read

MyTitles.Add(Convert.ToString(oRead("POSDesc")))

MyTitles.Add(Convert.ToString(oRead("UPC")))

End While

oRead.Close()

oCmd.Dispose()

oConn.Dispose()

Return MyTitles.ToArray

End Function

____________________ERROR MESSAGE____________

You must implement a default accessor on System.Array because it inherits
from ICollection.
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: You must implement a
default accessor on System.Array because it inherits from ICollection.

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: You must implement a default accessor on
System.Array because it inherits from ICollection.]
System.Xml.Serialization.TypeScope.GetCollectionEl ementType(Type type)
System.Xml.Serialization.TypeScope.ImportTypeDesc( Type type, Boolean
canBePrimitive, MemberInfo memberInfo)
System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type, MemberInfo
source,
Boolean directReference)
System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type)
System.Xml.Serialization.XmlReflectionImporter.Imp ortMemberMapping(XmlReflec
tionMember
xmlReflectionMember, String ns, XmlReflectionMember[] xmlReflectionMembers)
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlRefle
ctionMember[]
xmlReflectionMembers, String ns, Boolean hasWrapperElement)
[InvalidOperationException: There was an error reflecting
'GetTitlesForBinResult'.]
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlRefle
ctionMember[]
xmlReflectionMembers, String ns, Boolean hasWrapperElement)
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(String
elementName, String ns, XmlReflectionMember[] members, Boolean
hasWrapperElement)
System.Web.Services.Protocols.SoapReflector.Import MembersMapping(XmlReflecti
onImporter
xmlImporter, SoapReflectionImporter soapImporter, Boolean
serviceDefaultIsEncoded, Boolean rpc, SoapBindingUse use,
SoapParameterStyle
paramStyle, String elementName, String elementNamespace, Boolean
nsIsDefault, XmlReflectionMember[] members, Boolean validate)
System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs)
[InvalidOperationException: Method ItemLookup.GetTitlesForBin can not be
reflected.]
System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs)
System.Web.Services.Description.SoapProtocolReflec tor.ReflectMethod()
System.Web.Services.Description.ProtocolReflector. ReflectBinding(ReflectedBi
nding
reflectedBinding)
System.Web.Services.Description.ProtocolReflector. Reflect()
System.Web.Services.Description.ServiceDescription Reflector.ReflectInternal(
ProtocolReflector[]
reflectors)
System.Web.Services.Description.ServiceDescription Reflector.Reflect(Type
type, String url)
System.Web.Services.Protocols.DocumentationServerT ype..ctor(Type type,
String uri)
System.Web.Services.Protocols.DocumentationServerP rotocol.Initialize()
System.Web.Services.Protocols.ServerProtocol.SetCo ntext(Type type,
HttpContext context, HttpRequest request, HttpResponse response)
System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&
abortProcessing) [InvalidOperationException: Unable to handle request.]
System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&
abortProcessing)
System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
type, HttpContext context, HttpRequest request, HttpResponse response)
[InvalidOperationException: Failed to handle request.]
System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
type, HttpContext context, HttpRequest request, HttpResponse response)
System.Web.Services.Protocols.WebServiceHandlerFac tory.GetHandler(HttpContex
t
context, String verb, String url, String filePath)
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, String path, String pathTranslated, Boolean useAppConfig)
System.Web.MapHandlerExecutionStep.System.Web.Http Application+IExecutionStep
..Execute()

Stacey Levine



Nov 23 '05 #2
Stacey,

I wonder if it's because at compile time it can't know whether the classes
can serialised. For this instance, have you considered returning a DataSet or
DataTable which the proxy knows how to serialise?

"Stacey Levine" wrote:
I have a webservice that I wanted to return an ArrayList..Well the service
compiles and runs when I have the output defined as ArrayList, but the WSDL
defines the output as an Object so I was having a problem in the calling
program. I searched online and found suggestions that I return an Array
instead so I modified my code (below) to return an Array instead of an
ArrayList. Now I get the message when I try to run just my webservice
saying " You must implement.." The code and complete message are below. I
am unsure of where to go from here. I have found several other people that
had similar problems, but nothing seems to work. Thanks for your help.

<WebMethod()> _

Public Function GetTitlesForBin(ByVal BinNum As String) As Array

Dim sSql As String

Dim MyTitles As ArrayList = New ArrayList

Dim oConn As New SqlClient.SqlConnection(gMerch)

sSql = "SELECT P.POSDesc, X.UPC FROM Bin_Xref X "

sSql = sSql & " LEFT JOIN tblItm I"

sSql = sSql & " ON X.UPC = I.UPC"

sSql = sSql & " LEFT JOIN tblPrd P"

sSql = sSql & " ON I.GrphcKey = P.GrphcKey"

sSql = sSql & " WHERE X.Bin_Num='" & BinNum & "'"

sSql = sSql & " ORDER BY P.POSDesc"

Dim oCmd As New SqlClient.SqlCommand(sSql, oConn)

Dim oRead As SqlClient.SqlDataReader

oConn.Open()

oRead = oCmd.ExecuteReader

While oRead.Read

MyTitles.Add(Convert.ToString(oRead("POSDesc")))

MyTitles.Add(Convert.ToString(oRead("UPC")))

End While

oRead.Close()

oCmd.Dispose()

oConn.Dispose()

Return MyTitles.ToArray

End Function

____________________ERROR MESSAGE____________

You must implement a default accessor on System.Array because it inherits
from ICollection.
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: You must implement a
default accessor on System.Array because it inherits from ICollection.

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: You must implement a default accessor on
System.Array because it inherits from ICollection.]
System.Xml.Serialization.TypeScope.GetCollectionEl ementType(Type type)
System.Xml.Serialization.TypeScope.ImportTypeDesc( Type type, Boolean
canBePrimitive, MemberInfo memberInfo)
System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type, MemberInfo source,
Boolean directReference)
System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type)
System.Xml.Serialization.XmlReflectionImporter.Imp ortMemberMapping(XmlReflectionMember
xmlReflectionMember, String ns, XmlReflectionMember[] xmlReflectionMembers)
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlReflectionMember[]
xmlReflectionMembers, String ns, Boolean hasWrapperElement)
[InvalidOperationException: There was an error reflecting
'GetTitlesForBinResult'.]
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlReflectionMember[]
xmlReflectionMembers, String ns, Boolean hasWrapperElement)
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(String
elementName, String ns, XmlReflectionMember[] members, Boolean
hasWrapperElement)
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)
System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs)
[InvalidOperationException: Method ItemLookup.GetTitlesForBin can not be
reflected.]
System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs)
System.Web.Services.Description.SoapProtocolReflec tor.ReflectMethod()
System.Web.Services.Description.ProtocolReflector. ReflectBinding(ReflectedBinding
reflectedBinding)
System.Web.Services.Description.ProtocolReflector. Reflect()
System.Web.Services.Description.ServiceDescription Reflector.ReflectInternal(ProtocolReflector[]
reflectors)
System.Web.Services.Description.ServiceDescription Reflector.Reflect(Type
type, String url)
System.Web.Services.Protocols.DocumentationServerT ype..ctor(Type type,
String uri)
System.Web.Services.Protocols.DocumentationServerP rotocol.Initialize()
System.Web.Services.Protocols.ServerProtocol.SetCo ntext(Type type,
HttpContext context, HttpRequest request, HttpResponse response)
System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&
abortProcessing) [InvalidOperationException: Unable to handle request.]
System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&
abortProcessing)
System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
type, HttpContext context, HttpRequest request, HttpResponse response)
[InvalidOperationException: Failed to handle request.]
System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
type, HttpContext context, HttpRequest request, HttpResponse response)
System.Web.Services.Protocols.WebServiceHandlerFac tory.GetHandler(HttpContext
context, String verb, String url, String filePath)
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, String path, String pathTranslated, Boolean useAppConfig)
System.Web.MapHandlerExecutionStep.System.Web.Http Application+IExecutionStep.Execute()

Stacey Levine



Nov 23 '05 #3
The only possible problem is that I want a PocketPC device to be able to
call the webservice. And from what I can tell, it doesn't have the SQLClient
namespace..
"Paul Hasell" <pa*********@community.nospam> wrote in message
news:BF**********************************@microsof t.com...
Stacey,

I wonder if it's because at compile time it can't know whether the classes
can serialised. For this instance, have you considered returning a DataSet
or
DataTable which the proxy knows how to serialise?

"Stacey Levine" wrote:
I have a webservice that I wanted to return an ArrayList..Well the
service
compiles and runs when I have the output defined as ArrayList, but the
WSDL
defines the output as an Object so I was having a problem in the calling
program. I searched online and found suggestions that I return an Array
instead so I modified my code (below) to return an Array instead of an
ArrayList. Now I get the message when I try to run just my webservice
saying " You must implement.." The code and complete message are below.
I
am unsure of where to go from here. I have found several other people
that
had similar problems, but nothing seems to work. Thanks for your help.

<WebMethod()> _

Public Function GetTitlesForBin(ByVal BinNum As String) As Array

Dim sSql As String

Dim MyTitles As ArrayList = New ArrayList

Dim oConn As New SqlClient.SqlConnection(gMerch)

sSql = "SELECT P.POSDesc, X.UPC FROM Bin_Xref X "

sSql = sSql & " LEFT JOIN tblItm I"

sSql = sSql & " ON X.UPC = I.UPC"

sSql = sSql & " LEFT JOIN tblPrd P"

sSql = sSql & " ON I.GrphcKey = P.GrphcKey"

sSql = sSql & " WHERE X.Bin_Num='" & BinNum & "'"

sSql = sSql & " ORDER BY P.POSDesc"

Dim oCmd As New SqlClient.SqlCommand(sSql, oConn)

Dim oRead As SqlClient.SqlDataReader

oConn.Open()

oRead = oCmd.ExecuteReader

While oRead.Read

MyTitles.Add(Convert.ToString(oRead("POSDesc")))

MyTitles.Add(Convert.ToString(oRead("UPC")))

End While

oRead.Close()

oCmd.Dispose()

oConn.Dispose()

Return MyTitles.ToArray

End Function

____________________ERROR MESSAGE____________

You must implement a default accessor on System.Array because it inherits
from ICollection.
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: You must implement a
default accessor on System.Array because it inherits from ICollection.

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: You must implement a default accessor on
System.Array because it inherits from ICollection.]
System.Xml.Serialization.TypeScope.GetCollectionEl ementType(Type type)
System.Xml.Serialization.TypeScope.ImportTypeDesc( Type type, Boolean
canBePrimitive, MemberInfo memberInfo)
System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type, MemberInfo
source,
Boolean directReference)
System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type)
System.Xml.Serialization.XmlReflectionImporter.Imp ortMemberMapping(XmlReflectionMember
xmlReflectionMember, String ns, XmlReflectionMember[]
xmlReflectionMembers)
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlReflectionMember[]
xmlReflectionMembers, String ns, Boolean hasWrapperElement)
[InvalidOperationException: There was an error reflecting
'GetTitlesForBinResult'.]
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlReflectionMember[]
xmlReflectionMembers, String ns, Boolean hasWrapperElement)
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(String
elementName, String ns, XmlReflectionMember[] members, Boolean
hasWrapperElement)
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)
System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs)
[InvalidOperationException: Method ItemLookup.GetTitlesForBin can not be
reflected.]
System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs)
System.Web.Services.Description.SoapProtocolReflec tor.ReflectMethod()
System.Web.Services.Description.ProtocolReflector. ReflectBinding(ReflectedBinding
reflectedBinding)
System.Web.Services.Description.ProtocolReflector. Reflect()
System.Web.Services.Description.ServiceDescription Reflector.ReflectInternal(ProtocolReflector[]
reflectors)
System.Web.Services.Description.ServiceDescription Reflector.Reflect(Type
type, String url)
System.Web.Services.Protocols.DocumentationServerT ype..ctor(Type type,
String uri)
System.Web.Services.Protocols.DocumentationServerP rotocol.Initialize()
System.Web.Services.Protocols.ServerProtocol.SetCo ntext(Type type,
HttpContext context, HttpRequest request, HttpResponse response)
System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&
abortProcessing) [InvalidOperationException: Unable to handle request.]
System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&
abortProcessing)
System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
type, HttpContext context, HttpRequest request, HttpResponse response)
[InvalidOperationException: Failed to handle request.]
System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
type, HttpContext context, HttpRequest request, HttpResponse response)
System.Web.Services.Protocols.WebServiceHandlerFac tory.GetHandler(HttpContext
context, String verb, String url, String filePath)
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, String path, String pathTranslated, Boolean useAppConfig)
System.Web.MapHandlerExecutionStep.System.Web.Http Application+IExecutionStep.Execute()

Stacey Levine



Nov 23 '05 #4
Stacey,

System.Data is not SQL specific but sits above the provider specific
namespaces for SQLClient and OLEDb. According to the documenation, SqlClient
is support on the copact framework (via a SQL CE driver) but OleDb isn't. So
in this instance use of DataSet and/or DataTable should be OK...unless you
want access from a non .NET client.

"Stacey Levine" wrote:
The only possible problem is that I want a PocketPC device to be able to
call the webservice. And from what I can tell, it doesn't have the SQLClient
namespace..
"Paul Hasell" <pa*********@community.nospam> wrote in message
news:BF**********************************@microsof t.com...
Stacey,

I wonder if it's because at compile time it can't know whether the classes
can serialised. For this instance, have you considered returning a DataSet
or
DataTable which the proxy knows how to serialise?

"Stacey Levine" wrote:
I have a webservice that I wanted to return an ArrayList..Well the
service
compiles and runs when I have the output defined as ArrayList, but the
WSDL
defines the output as an Object so I was having a problem in the calling
program. I searched online and found suggestions that I return an Array
instead so I modified my code (below) to return an Array instead of an
ArrayList. Now I get the message when I try to run just my webservice
saying " You must implement.." The code and complete message are below.
I
am unsure of where to go from here. I have found several other people
that
had similar problems, but nothing seems to work. Thanks for your help.

<WebMethod()> _

Public Function GetTitlesForBin(ByVal BinNum As String) As Array

Dim sSql As String

Dim MyTitles As ArrayList = New ArrayList

Dim oConn As New SqlClient.SqlConnection(gMerch)

sSql = "SELECT P.POSDesc, X.UPC FROM Bin_Xref X "

sSql = sSql & " LEFT JOIN tblItm I"

sSql = sSql & " ON X.UPC = I.UPC"

sSql = sSql & " LEFT JOIN tblPrd P"

sSql = sSql & " ON I.GrphcKey = P.GrphcKey"

sSql = sSql & " WHERE X.Bin_Num='" & BinNum & "'"

sSql = sSql & " ORDER BY P.POSDesc"

Dim oCmd As New SqlClient.SqlCommand(sSql, oConn)

Dim oRead As SqlClient.SqlDataReader

oConn.Open()

oRead = oCmd.ExecuteReader

While oRead.Read

MyTitles.Add(Convert.ToString(oRead("POSDesc")))

MyTitles.Add(Convert.ToString(oRead("UPC")))

End While

oRead.Close()

oCmd.Dispose()

oConn.Dispose()

Return MyTitles.ToArray

End Function

____________________ERROR MESSAGE____________

You must implement a default accessor on System.Array because it inherits
from ICollection.
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: You must implement a
default accessor on System.Array because it inherits from ICollection.

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: You must implement a default accessor on
System.Array because it inherits from ICollection.]
System.Xml.Serialization.TypeScope.GetCollectionEl ementType(Type type)
System.Xml.Serialization.TypeScope.ImportTypeDesc( Type type, Boolean
canBePrimitive, MemberInfo memberInfo)
System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type, MemberInfo
source,
Boolean directReference)
System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type)
System.Xml.Serialization.XmlReflectionImporter.Imp ortMemberMapping(XmlReflectionMember
xmlReflectionMember, String ns, XmlReflectionMember[]
xmlReflectionMembers)
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlReflectionMember[]
xmlReflectionMembers, String ns, Boolean hasWrapperElement)
[InvalidOperationException: There was an error reflecting
'GetTitlesForBinResult'.]
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlReflectionMember[]
xmlReflectionMembers, String ns, Boolean hasWrapperElement)
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(String
elementName, String ns, XmlReflectionMember[] members, Boolean
hasWrapperElement)
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)
System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs)
[InvalidOperationException: Method ItemLookup.GetTitlesForBin can not be
reflected.]
System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs)
System.Web.Services.Description.SoapProtocolReflec tor.ReflectMethod()
System.Web.Services.Description.ProtocolReflector. ReflectBinding(ReflectedBinding
reflectedBinding)
System.Web.Services.Description.ProtocolReflector. Reflect()
System.Web.Services.Description.ServiceDescription Reflector.ReflectInternal(ProtocolReflector[]
reflectors)
System.Web.Services.Description.ServiceDescription Reflector.Reflect(Type
type, String url)
System.Web.Services.Protocols.DocumentationServerT ype..ctor(Type type,
String uri)
System.Web.Services.Protocols.DocumentationServerP rotocol.Initialize()
System.Web.Services.Protocols.ServerProtocol.SetCo ntext(Type type,
HttpContext context, HttpRequest request, HttpResponse response)
System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&
abortProcessing) [InvalidOperationException: Unable to handle request.]
System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&
abortProcessing)
System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
type, HttpContext context, HttpRequest request, HttpResponse response)
[InvalidOperationException: Failed to handle request.]
System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
type, HttpContext context, HttpRequest request, HttpResponse response)
System.Web.Services.Protocols.WebServiceHandlerFac tory.GetHandler(HttpContext
context, String verb, String url, String filePath)
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, String path, String pathTranslated, Boolean useAppConfig)
System.Web.MapHandlerExecutionStep.System.Web.Http Application+IExecutionStep.Execute()

Stacey Levine




Nov 23 '05 #5
Hi Stacey,

Yes, the System.Data namespace's classes are not specific to certain
DataBase product. Also, have you tried using the string[] as the return
type as I I mentioned in the last message?
If there're any further findings, please feel free to post here. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
Thread-Topic: Problem with webservice returning an array (You must implement
thread-index: AcW+tFxeV4gV37ZkSJ2RBhuq6cvzUA==
X-WBNR-Posting-Host: 62.6.144.66
From: "=?Utf-8?B?UGF1bCBIYXNlbGw=?=" <pa*********@community.nospam>
References: <e0**************@TK2MSFTNGP15.phx.gbl>
<BF**********************************@microsoft.co m>
<#H**************@TK2MSFTNGP12.phx.gbl>
Subject: Re: Problem with webservice returning an array (You must implement
Date: Wed, 21 Sep 2005 06:57:10 -0700
Lines: 197
Message-ID: <B8**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
microsoft.public.dotnet.framework.webservices:7985
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

Stacey,

System.Data is not SQL specific but sits above the provider specific
namespaces for SQLClient and OLEDb. According to the documenation,
SqlClient
is support on the copact framework (via a SQL CE driver) but OleDb isn't.
So
in this instance use of DataSet and/or DataTable should be OK...unless you
want access from a non .NET client.

"Stacey Levine" wrote:
The only possible problem is that I want a PocketPC device to be able to
call the webservice. And from what I can tell, it doesn't have the SQLClient namespace..
"Paul Hasell" <pa*********@community.nospam> wrote in message
news:BF**********************************@microsof t.com...
Stacey,

I wonder if it's because at compile time it can't know whether the classes can serialised. For this instance, have you considered returning a DataSet or
DataTable which the proxy knows how to serialise?

"Stacey Levine" wrote:
I have a webservice that I wanted to return an ArrayList..Well the
service
compiles and runs when I have the output defined as ArrayList, but the
WSDL
defines the output as an Object so I was having a problem in the calling program. I searched online and found suggestions that I return an Array instead so I modified my code (below) to return an Array instead of an
ArrayList. Now I get the message when I try to run just my webservice
saying " You must implement.." The code and complete message are below. I
am unsure of where to go from here. I have found several other people
that
had similar problems, but nothing seems to work. Thanks for your help.

<WebMethod()> _

Public Function GetTitlesForBin(ByVal BinNum As String) As Array

Dim sSql As String

Dim MyTitles As ArrayList = New ArrayList

Dim oConn As New SqlClient.SqlConnection(gMerch)

sSql = "SELECT P.POSDesc, X.UPC FROM Bin_Xref X "

sSql = sSql & " LEFT JOIN tblItm I"

sSql = sSql & " ON X.UPC = I.UPC"

sSql = sSql & " LEFT JOIN tblPrd P"

sSql = sSql & " ON I.GrphcKey = P.GrphcKey"

sSql = sSql & " WHERE X.Bin_Num='" & BinNum & "'"

sSql = sSql & " ORDER BY P.POSDesc"

Dim oCmd As New SqlClient.SqlCommand(sSql, oConn)

Dim oRead As SqlClient.SqlDataReader

oConn.Open()

oRead = oCmd.ExecuteReader

While oRead.Read

MyTitles.Add(Convert.ToString(oRead("POSDesc")))

MyTitles.Add(Convert.ToString(oRead("UPC")))

End While

oRead.Close()

oCmd.Dispose()

oConn.Dispose()

Return MyTitles.ToArray

End Function

____________________ERROR MESSAGE____________

You must implement a default accessor on System.Array because it inherits from ICollection.
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: You must implement a default accessor on System.Array because it inherits from ICollection.

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: You must implement a default accessor on
System.Array because it inherits from ICollection.]
System.Xml.Serialization.TypeScope.GetCollectionEl ementType(Type type)
System.Xml.Serialization.TypeScope.ImportTypeDesc( Type type, Boolean
canBePrimitive, MemberInfo memberInfo)
System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type, MemberInfo
source,
Boolean directReference)
System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type)
System.Xml.Serialization.XmlReflectionImporter.Imp ortMemberMapping(XmlReflec
tionMember xmlReflectionMember, String ns, XmlReflectionMember[]
xmlReflectionMembers)
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlRefle
ctionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement)
[InvalidOperationException: There was an error reflecting
'GetTitlesForBinResult'.]
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlRefle
ctionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement)
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(String elementName, String ns, XmlReflectionMember[] members, Boolean
hasWrapperElement)
System.Web.Services.Protocols.SoapReflector.Import MembersMapping(XmlReflecti
onImporter xmlImporter, SoapReflectionImporter soapImporter, Boolean
serviceDefaultIsEncoded, Boolean rpc, SoapBindingUse use,
SoapParameterStyle
paramStyle, String elementName, String elementNamespace, Boolean
nsIsDefault, XmlReflectionMember[] members, Boolean validate)
System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs)
[InvalidOperationException: Method ItemLookup.GetTitlesForBin can not be reflected.]
System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs)
System.Web.Services.Description.SoapProtocolReflec tor.ReflectMethod()
System.Web.Services.Description.ProtocolReflector. ReflectBinding(ReflectedBi
nding reflectedBinding)
System.Web.Services.Description.ProtocolReflector. Reflect()
System.Web.Services.Description.ServiceDescription Reflector.ReflectInternal(
ProtocolReflector[] reflectors)
System.Web.Services.Description.ServiceDescription Reflector.Reflect(Type type, String url)
System.Web.Services.Protocols.DocumentationServerT ype..ctor(Type type,
String uri)
System.Web.Services.Protocols.DocumentationServerP rotocol.Initialize()
System.Web.Services.Protocols.ServerProtocol.SetCo ntext(Type type,
HttpContext context, HttpRequest request, HttpResponse response)
System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing) [InvalidOperationException: Unable to handle request.]
System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response)
[InvalidOperationException: Failed to handle request.]
System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response)
System.Web.Services.Protocols.WebServiceHandlerFac tory.GetHandler(HttpContex
t context, String verb, String url, String filePath)
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, String path, String pathTranslated, Boolean useAppConfig)
System.Web.MapHandlerExecutionStep.System.Web.Http Application+IExecutionStep
.Execute()


Stacey Levine





Nov 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: emma middlebrook | last post by:
Hi Straight to the point - I don't understand why System.Array derives from IList (given the methods/properties actually on IList). When designing an interface you specify a contract. Deriving...
7
by: ORC | last post by:
Hi, How to create an ArrayList from a System.Array or inserting the System.Array into the ArrayList ? Thanks Ole
4
by: Joe Doyle | last post by:
I'm trying to do this- .... void method1(System.Array arr) { // happen to know all elements in arr are int's // this line throws an InvalidCastException int intArr = (int) arr; }
2
by: Chris | last post by:
Hi, the specs for System.Array are : MustInherit Public Class Array Implements ICloneable, IList, ICollection, IEnumerable but I can't use any of the functions presented by IList in my code ...
2
by: Grigs | last post by:
I have a C# Web Service that some of the methods (ones that return integers) work and some do not (the ones that return a DataView. Here is some code in the WebService that is giving me the...
2
by: Justin Drerup | last post by:
I'm tryng to return a custom object that contains a collection of MembershipUsers through a web service however I receive the following error when trying to return the object through a web method:...
2
by: Polaris431 | last post by:
A property in some class shows up in the object browser as follows: public System.Collections.Generic.ICollection<DataSourceDataSources { get; } How do I access this property. I'm not sure...
4
by: =?Utf-8?B?aXdkdTE1?= | last post by:
hi, im having a small issue. I pass a String object to a method, but then when i try to use the Split method of a String array, it says System.Array does not contain Split. The parameter of my...
2
by: Fred Mellender | last post by:
I am trying to use reflection to output the fields (names and values) of an arbitrary object -- an object dump to a TreeView. It works pretty well, but I am having trouble with generic lists,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.