Link to home
Start Free TrialLog in
Avatar of pamsauto
pamsauto

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pamsauto
pamsauto

ASKER

Sorry, that is just a cut a paste error.  In the executing code has the End Function in it.
Was not the solution, but I figured out the issue off site