views:

55

answers:

2

I created a separate web service project using VS 2005.

  1. My first question is can I add more than 1 service (asmx) files and use them in single webservice project?
  2. How can I publish them and use/call/consume them from different websites? (I know how to use them when they are in same project but different project is bit confusing)
  3. How can I secure them to make them available by authenticated users/apps?

Using VS 2005, .net 2.0, VB.NET (and I cannot use WCF)

+3  A: 
  1. Yes, that's perfectly possible. As long as it logically makes sense for them to go in the same web service project, that will be fine.
  2. Just publish them as you would a normal website. XCOPY deployment or Publish from within VS.NET. You create client proxies by 'Adding web reference' in your project that you want to consume the web service and then browse to/select the local .asmx endpoint over HTTP. Under the hood it will generate a SOAP client proxy class for you with the relevant datatypes (by calling wsdl.exe).
  3. For securing these, check out the MSDN docs here.
Wim Hollebrandse
Ah web references, I couldn't remember how to link to web services in .NET.
James McMahon
Yep, though there's nothing stopping you using the wsdl.exe command line util direct and import the output into your project.
Wim Hollebrandse
A: 

My first question is can I add more than 1 service (asmx) files and use them in single webservice project?

You can add multiple entry points to your webservice, such that calling different URLs will call different behaviors. You can do this by adding

[WebMethod]

In front of public methods inside your Service.cs file.

How can I publish them and use/call/consume them from different websites? (I know how to use them when they are in same project but different project is bit confusing)

You can generate code to interact with the webservice based on the WSDL file. I am not sure how you do this in .NET, but in Java there is a command line tool to generate class to interact with the SOAP service from another applications. This is, after all the entire point of web services.

How can I secure them to make them available by authenticated users/apps?

You probably want to manage this on the IIS side of things. While it is probably possible to some basic authentication to your web service but checking the username, it may be more efficient to handle this before you reach your web service.

You can also configure basic authentication using the Web.config file's authentication attribute.

James McMahon