Return more than one item with an ASMX page

Discussion in 'ASP .Net Web Services' started by USCG, Mar 10, 2005.

  1. USCG

    USCG Guest

    My ASMX page currently returns one item in the XML
    document when I click the invoke button. Can anyone tell
    me how to return two or more items on the same XML
    document?

    I just need a simple example-I have included my current
    code for reference. Thank you.




    Imports System.Web.Services
    'The class is Service1
    <System.Web.Services.WebService
    (Namespace := "http://tempuri.org/Prototype/Service1")> _
    Public Class Service1
    Inherits System.Web.Services.WebService
    #Region " Web Services Designer Generated Code "
    Public Sub New()
    MyBase.New()
    'This call is required by the Web Services
    Designer.
    InitializeComponent()
    'Add your own initialization code after the
    InitializeComponent() call
    End Sub
    'Required by the Web Services Designer
    Private components As System.ComponentModel.IContainer
    'NOTE: The following procedure is required by the Web
    Services Designer
    'It can be modified using the Web Services Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private
    Sub InitializeComponent()
    components = New System.ComponentModel.Container
    End Sub
    Protected Overloads Overrides Sub Dispose(ByVal
    disposing As Boolean)
    'CODEGEN: This procedure is required by the Web
    Services Designer
    'Do not modify it using the code editor.
    If disposing Then
    If Not (components Is Nothing) Then
    components.Dispose()
    End If
    End If
    MyBase.Dispose(disposing)
    End Sub
    #End Region
    <WebMethod()> _
    Public Function HelloWorld() As String
    Dim TheMessage As String = "First message"
    Return TheMessage
    Dim TheNextMessage As String = "Second message"
    Return TheNextMessage
    End Function
    End Class
     
    USCG, Mar 10, 2005
    #1
    1. Advertising

  2. You can use the "out" parameters into the method

    [WebMethod]
    public string HellWorld(out string anotherString)
    {
    anotherString = "Hello";

    return "World!";
    }

    while calling your proxy object:

    string outString;
    string returnString = proxy.HelloWorld(out outString);

    Another idea is to create a composite class and return that object. Hope
    that helps.

    --
    Manohar Kamath
    Editor, .netWire
    www.dotnetwire.com


    "USCG" <> wrote in message
    news:6d8b01c525b8$736b9e10$...
    > My ASMX page currently returns one item in the XML
    > document when I click the invoke button. Can anyone tell
    > me how to return two or more items on the same XML
    > document?
    >
    > I just need a simple example-I have included my current
    > code for reference. Thank you.
    >
    >
    >
    >
    > Imports System.Web.Services
    > 'The class is Service1
    > <System.Web.Services.WebService
    > (Namespace := "http://tempuri.org/Prototype/Service1")> _
    > Public Class Service1
    > Inherits System.Web.Services.WebService
    > #Region " Web Services Designer Generated Code "
    > Public Sub New()
    > MyBase.New()
    > 'This call is required by the Web Services
    > Designer.
    > InitializeComponent()
    > 'Add your own initialization code after the
    > InitializeComponent() call
    > End Sub
    > 'Required by the Web Services Designer
    > Private components As System.ComponentModel.IContainer
    > 'NOTE: The following procedure is required by the Web
    > Services Designer
    > 'It can be modified using the Web Services Designer.
    > 'Do not modify it using the code editor.
    > <System.Diagnostics.DebuggerStepThrough()> Private
    > Sub InitializeComponent()
    > components = New System.ComponentModel.Container
    > End Sub
    > Protected Overloads Overrides Sub Dispose(ByVal
    > disposing As Boolean)
    > 'CODEGEN: This procedure is required by the Web
    > Services Designer
    > 'Do not modify it using the code editor.
    > If disposing Then
    > If Not (components Is Nothing) Then
    > components.Dispose()
    > End If
    > End If
    > MyBase.Dispose(disposing)
    > End Sub
    > #End Region
    > <WebMethod()> _
    > Public Function HelloWorld() As String
    > Dim TheMessage As String = "First message"
    > Return TheMessage
    > Dim TheNextMessage As String = "Second message"
    > Return TheNextMessage
    > End Function
    > End Class
     
    Manohar Kamath, Mar 11, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Craig G
    Replies:
    1
    Views:
    459
    William F. Robertson, Jr.
    Dec 6, 2004
  2. Merciadri Luca
    Replies:
    4
    Views:
    817
  3. Bob Rashkin
    Replies:
    5
    Views:
    74
    Dennis Lee Bieber
    Dec 23, 2013
  4. Steven D'Aprano
    Replies:
    0
    Views:
    98
    Steven D'Aprano
    Dec 23, 2013
  5. Replies:
    3
    Views:
    88
    Gary Herron
    Dec 23, 2013
Loading...

Share This Page