Re: publishing Hello World to local IIS
- From: cj <cj@xxxxxxxxxxxxx>
- Date: Wed, 16 Jan 2008 08:46:59 -0500
I understand now. "Decorate" means to beautify to me and I was at a loss as to how that worked with web services. I was thinking it formatted the page pulled up by http://localhost/service1.asmx, like changing the colors etc.
Steven Cheng[MSFT] wrote:
Hi Cj,.
The "WebMethodAttribute" I mentioned is used to indicate that a certain class method of the webservice class should be exposed as "webmethod"(which can be called by client proxy as webservice method). Here is a typical HelloWorld webservice:
================
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class simpleservice
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
End Class
=================
in VB.NET the syntax for applying attribute is <WebMethod()> _
Therefore, to summarize, "<WebService>" is used at class level while <WebMethod> is used at function level, they're both used to decorate a webservice class.
Does this clarify a bit?
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Date: Tue, 15 Jan 2008 11:33:44 -0500
From: cj <cj@xxxxxxxxxxxxx>
User-Agent: Thunderbird 2.0.0.6 (Windows/20070728)
MIME-Version: 1.0
Subject: Re: publishing Hello World to local IIS
I'm sorry but what do you mean by:
Also, for each WebService method in it, you need to decorate it with
<WebMethodAttribute>
Can you give me an example of where I would add that? Am I right in that it is needed for remote access to the web service?
<System.Web.Services.WebService(Name:="CJ's Service", Description:="Testing 123")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1
_1)> _
<ToolboxItem(False)> _
Public Class Service1
Steven Cheng[MSFT] wrote:Hi Cj,add
Yes, you should keep one webservice class in each asmx. Also, you canmore than one classes in an asmx file(codebehind), however, the key point is that only one of them should be marked as a "WebService", this is done through the "WebServiceAttrribute"(the <WebService(....)> in VB.NET). e.g.rights.
<WebService("Name=.....")>
public class ServiceClass
{
}
Also, for each WebService method in it, you need to decorate it with <WebMethodAttribute>
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no--------------------<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1
Date: Mon, 14 Jan 2008 17:01:06 -0500
From: cj <cj@xxxxxxxxxxxxx>
Subject: Re: publishing Hello World to local IIS
If I create a second class inside Service1.asmx it doesn't show in http://localhost/Service1.asmx. I take it that is normal. I guess I'm only allowed 1 class inside service1.asmx that will show and that class must be named service1.asmx. Is this correct?
For instance in the below code http://localhost/Service1.asmx doesn't show any of the Goodbye services. It does show HelloWorld and HelloCJ.
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
_1)> _<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1
<ToolboxItem(False)> _
Public Class Service1
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
<WebMethod()> _
Public Function HelloCJ() As String
Return "Hello CJ"
End Function
End Class
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
_1)> _
<ToolboxItem(False)> _
Public Class Service2
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function GoodbyeWorld() As String
Return "Goodbye World"
End Function
<WebMethod()> _
Public Function GoodbyeCJ() As String
Return "Goodbye CJ"
End Function
End Class
But even if I create a new service Service2.asmx inside the project and put the goodbye code in it I can't get http://localhost/Service2.asmx to bring up anything. I would have thought that would work.
Steven Cheng[MSFT] wrote:Hi Cj,logic,
Glad that you've got progress. As for providing multiple webservices, I think it is up to you that how to arrange those webservice methods/endpoints.
If you have many service functions that belong to the same businessyou may group them in the same asmx service endpoint. Otherwise, you can separate them into multiple webservice asmx endpoint. And you can create separate webservice proxy classes for them.which
In addition, if you want to make your client consumers easy to visit and consume your service, I suggest you create a dedicated aspx web pagegrou p all the service's description page (...asmx?wsdl) on it (as hyperlink). Thus, your clients can just visit that page and lookup alltheservices you provided.rights.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no--------------------
Date: Thu, 10 Jan 2008 11:14:15 -0500
From: cj <cj@xxxxxxxxxxxxx>
User-Agent: Thunderbird 2.0.0.6 (Windows/20070728)
MIME-Version: 1.0
Subject: Re: publishing Hello World to local IIS
I got time this AM to look at this some more. My project is named MyTestWebService1 and saved it to the default web site on the local IIS. The WebMethod is HelloWorld. I was kind of surprised I had to type http://localhost/Service1.asmx into the browser. It did then show me that HelloWorld was there and I could test it.
I guess my question is if I want to make a couple of web services should I add another .asmx file to the project? Or should I add another WebMethod to Service1.asmx? Or should I start a new project for the second web service?
How is this generally done? I want to do it as simply as possible but also would like to do it the way most people are used to using them.
Eventually we have a couple business partners that will need to use the web services and I want it to be easy for them to use.
Thanks for your help.
Steven Cheng[MSFT] wrote:
- Follow-Ups:
- Re: publishing Hello World to local IIS
- From: Steven Cheng[MSFT]
- Re: publishing Hello World to local IIS
- References:
- publishing Hello World to local IIS
- From: cj
- RE: publishing Hello World to local IIS
- From: Steven Cheng[MSFT]
- Re: publishing Hello World to local IIS
- From: cj
- Re: publishing Hello World to local IIS
- From: Steven Cheng[MSFT]
- Re: publishing Hello World to local IIS
- From: cj
- Re: publishing Hello World to local IIS
- From: Steven Cheng[MSFT]
- Re: publishing Hello World to local IIS
- From: cj
- Re: publishing Hello World to local IIS
- From: Steven Cheng[MSFT]
- Re: publishing Hello World to local IIS
- From: cj
- Re: publishing Hello World to local IIS
- From: Steven Cheng[MSFT]
- publishing Hello World to local IIS
- Prev by Date: Re: Webservice running very slowly
- Next by Date: Re: namespace?
- Previous by thread: Re: publishing Hello World to local IIS
- Next by thread: Re: publishing Hello World to local IIS
- Index(es):
Relevant Pages
|