|
-
Jun 28th, 2002, 03:14 PM
#1
Thread Starter
Junior Member
Multiple wbsevices in on asmx file
HI,
Does any one know whow to access multiple webservices from the asmx file. I am just trying to test I don't need to access them from code. I just want to access them from the browser right now? - when I runt the project only one web service shows up.
Do I need to have 2 asmx files???
-
Jun 29th, 2002, 09:53 AM
#2
Fanatic Member
Re: Multiple wbsevices in on asmx file
Originally posted by dgruzew
HI,
Does any one know whow to access multiple webservices from the asmx file. I am just trying to test I don't need to access them from code. I just want to access them from the browser right now? - when I runt the project only one web service shows up.
Do I need to have 2 asmx files???
When you say multiple webservices, do you actually mean multiple methods(or functions) within a webservice ???
You can have as many methods in a service as you want. They just need to be setup properly.
Simple example....copy the following code into one file with the extension ASMX and run it.
Code:
<%@ WebService language="C#" class="Test" %>
using System;
using System.Web.Services;
using System.Xml.Serialization;
public class Test {
[WebMethod]
public int Add(int a, int b) {
return a + b;
}
[WebMethod]
public int Subtract(int a, int b) {
return a - b;
}
[WebMethod]
public int Divide(int a, int b) {
return a/b;
}
[WebMethod]
public int Multiply(int a, int b) {
return a * b;
}
}
John
-
Jun 30th, 2002, 10:00 AM
#3
Thread Starter
Junior Member
samx
no I mean multiple
<%@ WebService language="C#" class="Test" %>
Statements?? - is this possible?
-
Jun 30th, 2002, 02:11 PM
#4
Fanatic Member
Re: samx
Originally posted by dgruzew
no I mean multiple
<%@ WebService language="C#" class="Test" %>
Statements?? - is this possible?
I doubt it's possible. Why would you want multiple
Code:
<%@ WebService language="C#" class="Test" %>
in one ASMX file ??
You want to have a WebService inside a WebService ??
I'm confused. 
John
-
Jul 1st, 2002, 08:49 AM
#5
Thread Starter
Junior Member
heres the code I tried - it seems to ignore the second webservice??
From you reply - it seems that only one web service can be associated with one asmx unlike class files which may have more than one class in each file.
Imports System.Web.Services
Imports System.Data
Imports System.Data.SqlClient
<WebService(Namespace:="http://tempuri.org/")> _
Public Class WSEmployee
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 GetEmployeeInfo(ByVal bIncludeAddress As Boolean, ByVal bIncludeInactiveAddress As Boolean, ByVal EmployeeID As Int16) As DataSet
Dim objEmp As New Employee()
Return objEmp.GetEmployeeInfo(bIncludeAddress, bIncludeInactiveAddress, EmployeeID)
objEmp = Nothing
End Function
<WebMethod()> Public Function GetEmployeeList() As DataSet
'HelloWorld = "Hello World"
Dim objEmp As New Employee()
Return objEmp.GetEmployeeList
objEmp = Nothing
End Function
<WebMethod()> Public Function GetCallList(ByVal bByDeal As Boolean, ByVal ideal As Int16) As DataSet
Dim objCall As New CallReport()
If bByDeal = True Then
Return objCall.GetCallList(bByDeal, ideal)
Else
Return objCall.GetCallList(bByDeal)
End If
objCall = Nothing
End Function
End Class
<WebService(Namespace:="http://tempuri.org/")> _
Public Class WSCall
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 GetCallList(ByVal bByDeal As Boolean, ByVal ideal As Int16) As DataSet
Dim objCall As New CallReport()
If bByDeal = True Then
Return objCall.GetCallList(bByDeal, ideal)
Else
Return objCall.GetCallList(bByDeal)
End If
objCall = Nothing
End Function
End Class
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
|