ASP.net Webservice with Multiple Functions and Custom Types not Working

I have a webservice that has two functions that both return a custom type.   If I comment out either function, the webservice works as expected, but if both functions are compliled the first function works fine, but the second gives this error.

System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidCastException: Unable to cast object of type ItemsOnInvoiceCollection; to type ;BusinessLogic.PartTypeCollection;.

He is the simplified code.

<XmlInclude(GetType(BusinessLogic.PartTypeCollection)), XmlInclude(GetType(BusinessLogic.PartType)), XmlInclude(GetType(BusinessLogic.Types.ItemsOnInvoiceCollection)), XmlInclude(GetType(BusinessLogic.Types.ItemsOnInvoice))> _
<WebService(Namespace:="http://barcoding.stcloud.pamsauto.com/webservices/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class ScannerFunctions
    Inherits System.Web.Services.WebService

 <WebMethod(), XmlInclude(GetType(BusinessLogic.PartTypeCollection)), XmlInclude(GetType(BusinessLogic.PartType))>
    Public Function GetGroupedPartData(ByVal GNumber As String, ByVal UserID As String) As BusinessLogic.PartTypeCollection
        Dim oEmployee As New Employee(Guid.Parse(UserID))
        If oEmployee.HasValue Then
            Dim oScannerHandler As New BusinessLogic.ScannerHandler()
            Dim parts As New PartTypeCollection
            parts.getPartsInAGroup(GNumber)
            Dim Info As String = ""
            For Each Part As PartType In parts
                If oScannerHandler.GetCurrent_DT_WO_INV_PO_AND_ROUTE_ByRNumber(Part.InventoryID, Info, True) Then
                    Part.extraInfo1 = Info
                End If
            Next
            Return parts
        Else
            Return Nothing
        End If

  <WebMethod(), XmlInclude(GetType(BusinessLogic.Types.ItemsOnInvoiceCollection)), XmlInclude(GetType(BusinessLogic.Types.ItemsOnInvoice))>
    Public Function GetItemsOnDTOrInvoice(ByVal Number As Integer, ByVal IsADeliveryTicket As Boolean) As BusinessLogic.Types.ItemsOnInvoiceCollection
        Dim objReturn As New BusinessLogic.Types.ItemsOnInvoiceCollection
        If IsADeliveryTicket Then
            objReturn.FillByDTNumber(Number)
        Else
            objReturn.FillByInvoiceNumber(Number)
        End If
        Return objReturn

    End Function

Open in new window

pamsautoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Miguel OzSoftware EngineerCommented:
The methods seems alright but I think you are missing :
End Function
on your first function,(add it at line 25)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pamsautoAuthor Commented:
Sorry, that is just a cut a paste error.  In the executing code has the End Function in it.
0
pamsautoAuthor Commented:
Was not the solution, but I figured out the issue off site
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.