By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,214 Members | 2,099 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,214 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.