473,472 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Two Classes in a same asmx page.

Hi,

I created a web service application using ASP.

My question is :
When i try to create an extra class in the same asmx file,At the time of
consuming the web service,its showing me only the default class only.
here is my code:

namespace WebService1
{
public class Service1 : System.Web.Services.WebService
{
public Service1()
{
InitializeComponent();
}
private IContainer components = null;

private void InitializeComponent()
{
}

protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}

#endregion

[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
public class newClass : System.Web.Services.WebService
{
public newClass()
{

}

[WebMethod]
public string HelloWorld1()
{
return "Hello World";
}
}
}

***********************************************

In my other ASP apllication
"newclass" is not visible at all.Itz showing only Service1.

What to do if I need other class also.
********************************

Thank you.
Kris.
Apr 20 '07 #1
6 2210
"kris" <kr**@discussions.microsoft.comwrote in message
news:20**********************************@microsof t.com...
Hi,

I created a web service application using ASP.

My question is :
When i try to create an extra class in the same asmx file,At the time of
consuming the web service,its showing me only the default class only.
here is my code:

namespace WebService1
{
public class Service1 : System.Web.Services.WebService
{
public Service1()
{
InitializeComponent();
}
private IContainer components = null;

private void InitializeComponent()
{
}

protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}

#endregion

[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
public class newClass : System.Web.Services.WebService
{
public newClass()
{

}

[WebMethod]
public string HelloWorld1()
{
return "Hello World";
}
}
}

***********************************************

In my other ASP apllication
"newclass" is not visible at all.Itz showing only Service1.

What to do if I need other class also.
********************************

Thank you.
Kris.
Are you unable to put the other class into a separate .asmx file? In
general, there should be one class per file.
--
John Saunders [MVP]
Apr 21 '07 #2
Hi John,

I have seen similar kind of code. That is why i am curious. But those
services are written in Java.

I have an other question,,,Can we add a namespace as the web reference.
So that i can use all the classes under that.
Apr 23 '07 #3
"kris" <kr**@discussions.microsoft.comwrote in message
news:F8**********************************@microsof t.com...
Hi John,

I have seen similar kind of code. That is why i am curious. But those
services are written in Java.

I have an other question,,,Can we add a namespace as the web reference.
So that i can use all the classes under that.
No. You can only add a web reference to a WSDL file, either directly or
indirectly.

John
Apr 23 '07 #4
Hi John,

I have these questions :

1)How to convert .cs file to wsdl file and viceversa.
2)Why two classes are not allowed in single asmx file?(As asked in the
example)

Thank you.
Apr 23 '07 #5
"kris" <kr**@discussions.microsoft.comwrote in message
news:F8**********************************@microsof t.com...
Hi John,

I have seen similar kind of code. That is why i am curious. But those
services are written in Java.

I have an other question,,,Can we add a namespace as the web reference.
So that i can use all the classes under that.
No. You can only add a web reference to a WSDL file, either directly or
indirectly.

John
Apr 24 '07 #6
"kris" <kr**@discussions.microsoft.comwrote in message
news:25**********************************@microsof t.com...
Hi John,

I have these questions :

1)How to convert .cs file to wsdl file and viceversa.
2)Why two classes are not allowed in single asmx file?(As asked in the
example)
Kris,

1) If you're referring to your .asmx.cs file, then .NET will use reflection
on your [WebService] classes within that file and will produce a WSDL for
you when someone makes a request for <yourFile>.asmx?WSDL
2) Two classes are _allowed_, I just happen to think they're not a good
idea. In general, for web services or any other kind of class, I think it
best to keep one class per file. It's easier to find them that way!
--

John Saunders [MVP]
Apr 24 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Benne Smith | last post by:
Hi, I have three enviroments; a development, a testing and a production enviroment. I'm making a big application (.exe), which uses alot of different webservices. I don't use the webservices...
1
by: PeterW | last post by:
On my machine I developed a WebService on localhost and if I browse the asmx file I get the usual page that defines the webmethods exposed by the webservice and the opportunity to get the wsdl file...
0
by: Peter Theill | last post by:
I have these two web services: namespace WebService1 { public class Service1 : System.Web.Services.WebService { public Service1() { } public string HelloWorld() {
6
by: John Glover | last post by:
I'm having a very strange problem with XML serialization. I'm writing web services which pass instances of various classes back and forth as parameters and return values of web methods. The...
5
2
by: Howard Postley | last post by:
This seems like it's probably a pretty basic question but is there a way to publish multiple classes from a single web service URL? Using VS.NET, I create a project, FOO and add a web service,...
3
by: Arpan | last post by:
Web Services make use of proxy classes whose methods & properties are accessed in exactly the same way as how a normal class' methods & properties are accessed. So what for does ASP.NET generate...
3
by: Joseph Geretz | last post by:
System.InvalidOperationException: WebServiceBindingAttribute is required on proxy classes. My environment: Visual Studio 2005, targeting FX 2.0; I've developed a Web Service which uses DIME to...
1
by: =?Utf-8?B?UEI=?= | last post by:
Hi I was investigating whether we could have a single entry-point (.asmx) to multiple Web Service classes instead of just one. Something like: <%@ WebService Language="C#" Class="Class1"...
5
by: =?Utf-8?B?a3Jpcw==?= | last post by:
I created a simple webservice .asmx on Visual Studio 2005. As I plan to deploy it to Sharepoint Portal 2003, I copied asmx to \web server extensions\60\ISAPI directory of the server, where all...
10
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
15
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.