473,791 Members | 3,229 Online
Bytes | Software Development & Data Engineering Community
+ 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.Serv ices.WebService
{
public Service1()
{
InitializeCompo nent();
}
private IContainer components = null;

private void InitializeCompo nent()
{
}

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

#endregion

[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
public class newClass : System.Web.Serv ices.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 2239
"kris" <kr**@discussio ns.microsoft.co mwrote in message
news:20******** *************** ***********@mic rosoft.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.Serv ices.WebService
{
public Service1()
{
InitializeCompo nent();
}
private IContainer components = null;

private void InitializeCompo nent()
{
}

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

#endregion

[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
public class newClass : System.Web.Serv ices.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**@discussio ns.microsoft.co mwrote in message
news:F8******** *************** ***********@mic rosoft.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**@discussio ns.microsoft.co mwrote in message
news:F8******** *************** ***********@mic rosoft.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**@discussio ns.microsoft.co mwrote in message
news:25******** *************** ***********@mic rosoft.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
3487
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 by adding a WebReference, since it does not allow me to keep state (cookiecontainer) or to specify functions on the classes (like if i want to override the ToString() function on a class from my webservice). So the only way i can see how i can get...
1
3303
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 using the Service Description link. This is saved into SourceSafe and then another person in the team gets latest from sourceSafe onto his system to try to run the webService on his localhost, all of the solution builds properly, but any...
0
1545
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
6056
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 problem is that in my derived classes, the XML that is automatically generated is lacking the properties of the base class. For example: public class MyBaseClass { public MyBaseClass ( ) { } private string myVariable;
2
3221
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, BAR, to it with one function, baz(). Then, I create a second project to consume the service. I add a web reference to http://webserver/FOO/BAR.asmx and call that, BAR_Service. In the code, if I do something like: dim ws as new BAR_Service.BAR...
3
5403
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 proxy classes (using WSDL) which consume more hard disk space & resources? For e.g. consider the following code which exists in a user-defined class file: Imports System Imports System.Data
3
14226
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 transfer file attachments to and from the server. I'm using WSE 2.0 SP3 which is supposed to support FX 2.0, as far as I know. (We will soon move on to MTOM, however I'm stuck with DIME for now; the solution was originally written for FX 1.1, and I...
1
3732
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" "Class2" "Class3" %> My goal is to minimize the number of .asmx files (and as such, the number of Web proxy references on the client side).
5
70514
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 other general webservices reside. Everything is just fine - i can access the service with the browser, method list is displayed as well as help texts for them. my question is - how do I generate .wsdl and .disco files for the service? I read...
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9512
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10201
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7531
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6770
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5424
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4100
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 we have to send another system
3
2910
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.