Embed
Email

web service

Document Sample

Shared by: niusheng11
Categories
Tags
Stats
views:
0
posted:
11/26/2011
language:
English
pages:
2
http://tempuri.org

Each XML Web Service needs a unique namespace in order for client applications to distinguish it from other services on the Web. By

default, ASP.Net Web Services use http://tempuri.org/ for this purpose. While this suitable for XML Web Services under development,

published services should use a unique, permanent namespace.



Your XML Web Service should be identified by a namespace that you control. For example, you can use your company's Internet

domain name as part of the namespace. Although many namespaces look like URLs, they need not point to actual resources on the

Web.



For XML Web Services creating using ASP.NET, the default namespace can be changed using the WebService attribute's Namespace

property. The WebService attribute is applied to the class that contains the XML Web Service methods. Below is a code example that

sets the namespace to "http://microsoft.com/webservices/":



C#





[WebService(Namespace="http://microsoft.com/webservices/")]

public class MyWebService {

// implementation

}





Introduction





We can now use ASP.NET to create Web Service that is based on industrial standards included XML, SOAP and

WSDL.





ASP.NET Web Services support clients using HTTP-POST, HTTP-GET and SOAP protocols to invoke methods

exposed, depends on your specific requirement you choose one method over the others. The main difference

between HTTP-GET or HTTP-POST and SOAP is the data types supported by SOAP is much richer because SOAP

used XSD schema to represent complex data types.





Here are samples codes I use to test the building of ASP.NET Web Service:





Step 1: Create the ASP.NET Web Service Source File



ASP.NET Web Service file name has extension asmx and my file is

named MyWebService.asmx, source is listed as follows:



File: MyWebService.asmx

Collapse







using System.Web.Services ;



public class MyClass

{

[WebMethod()]

public int Add ( int a, int b)

{

return a + b ;

}

}

The page directive WebService is required and class is the name of the .NET Class to

expose the Web Service, each method exposes as Web Service Class Method need to have a

declarative attribute statement [WebMethod()] in front of it. Here the .NET Class

implementation is included in the same file with ASP.NET Web Service file but it is not

mandatory and we can choose to include an external .NET Assembly to implement the

service as the following example:



Related docs
Other docs by niusheng11
TEXAS ADVANCED COMPUTING CENTER Safe Travels
Views: 0  |  Downloads: 0
The Trek
Views: 3  |  Downloads: 0
article-240637
Views: 0  |  Downloads: 0
work presentation 2A
Views: 2  |  Downloads: 0
snort_configure.docx - NEOHAPSIS
Views: 1  |  Downloads: 0
Southern Maine Dressage Association
Views: 1  |  Downloads: 0
Checklists for buying a used car
Views: 17  |  Downloads: 0
mis is riin The Office of Business Services
Views: 4  |  Downloads: 0
Assisted Living_6_
Views: 2  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!