|
-
May 26th, 2004, 08:53 AM
#1
Thread Starter
Frenzied Member
Problem when returning custom object by webservice
Im trying to return a collection of objects, the collection object itself inherits from CollectionBase. And somehow the objects need to be serializable...
When Im trying to run the webservice I get this error :
You must implement a default accessor on EasyPrinting.EasyPrinting.CDocumentCollection because it inherits from ICollection.
How can I implement such a default accessor?
kind regards
Henrik
-
May 26th, 2004, 09:05 AM
#2
Check out "default keyword" on MSDN for full info on this.
But in the meantime, I wrote a default accessor for one of my classes recently...
VB Code:
<Serializable()> Public Class BoundaryDataStorage
'...
Default Public Property Boundary(ByVal index As Integer) As Boundary
Get
'...
End Get
Set(ByVal Value As Boundary)
'...
End Set
End Property
'...
End Class
Basically it lets the class behave like a wrapper for an array, returning some internal data as pertains to a passed in parameter.
So you can call the above sub with either of the following to get the same result...
VB Code:
dim x as boundary
x = MyBoundaryDataStorageObject.Boundary(i)
or
VB Code:
dim x as boundary
x = MyBoundaryDataStorageObject(i)
Last edited by wossname; May 26th, 2004 at 09:14 AM.
I don't live here any more.
-
May 26th, 2004, 09:11 AM
#3
Thread Starter
Frenzied Member
Yeah, I reminded mysself about that keyword minutes after I posted the question...
Anyway, I put a default accessor... and something strange happened...
I have a webmethod that returns a collection of CDocument objects, a CDocumentCollection object... But when I run this method as a webmethod instead it is created in the proxy class as
CDocument()
My method that is using this can't use this, it works with CDocumentCollection only... not an array of CDocument objects.
Here is my webmethod
VB Code:
<WebMethod()> Public Function CreatePrintList(ByVal OrderNo As String, ByVal OpNo As Integer, ByVal PartNo As String) As CDocumentCollection
And here is the proxy class that was generated:
VB Code:
Public Function CreatePrintList(ByVal OrderNo As String, ByVal OpNo As Integer, ByVal PartNo As String) As CDocument()
Dim results() As Object = Me.Invoke("CreatePrintList", New Object() {OrderNo, OpNo, PartNo})
Return CType(results(0),CDocument())
End Function
Why did this conversion take place???
kind regards
Henrik
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|