Showing posts with label web service. Show all posts
Showing posts with label web service. Show all posts

Friday, March 12, 2010

Writing CAML Queries For Retrieving List Items from a SharePoint

http://sharepointmagazine.net/technical/development/writing-caml-queries-for-retrieving-list-items-from-a-sharepoint-list

Introduction
The Collaborative Application Markup Language (better known as CAML) is an XML-based query language that helps you querying, building and customizing Web sites based on Windows SharePoint Services. The XML elements define various aspects of a WSS site.

In this first series of articles I will explain in detail how to build and execute CAML queries to retrieve list items from a SharePoint list. List items can be retrieved in several different ways: using the SharePoint object model, using the SharePoint Lists web service or even by using Powershell. Use the SharePoint object model when your code runs on the server (like f.e. when you’re developing a web part or an application page). Use the SharePoint Web Services when your code doesn’t run on the server where SharePointis installed, for example when you develop office clients or windows applications. Powershell, at the other side, can be used by administrators when they quickly need to retrieve some information. In any way the CAML query is the same.

Building the CAML
CAML is an XML-based query language. Its root element is Query. Within the Query element two other elements are possible but not required: the OrderBy element and the Where element.

The OrderBy element is the simplest one. It is used to sort the returning list items. You have to specify the field(s) on which you want to sort the items and the sort direction. The syntax looks as follows:

The OrderBy clause is not required and you can specify one or more fields on which you want to sort. If you omit the Ascending attribute, your resulting rows will be sorted in ascending order. If you want to order in descending order you have to specify Ascending=’False’.

The Where clause is used to specify one or more filter criteria. This clause can be very simple but can end up being rather complex. In its most simple form you specify an operator, a field name for which you want to specify a criterion, and a value.

Janssens OperatorsYou have different operators:

Eq Equals

Neq Not equal

Gt Greater than

Geq Greater than or equal

Lt Lower than

Leq Lower than

IsNull Is null

BeginsWith Begins with

Contains Contains

FieldsThe FieldRef element can be any field of the list on which you want to execute the CAML query. If you use the Name attribute you need to specify the internal name of the field. But you can also use the IDattribute to specify the Guid of the field.

ValueThe Valueelement specifies the value part of the criterion. The attribute Typeis optional and specifies the data type of the field you want to specify the criterion for. If omitted the data type is considered as being Text. In all other cases you have to specify the Type attribute. DateTime fields are a special case and will be described in more detail later in this article.

If the field type is a Lookup you need to specify the text value.For example you have an Employees list and the Country field is a lookup field referring to the Countries list. In that case an employee living in Belgium will have f.e. following value: #15;Belgium. If you have to query for the employees living in Belgium you will have to write your query as follows:

Belgium You can find this not good coding practice because the name of the country can change in time. In that case you can also query on the id of the country specifying the LookupId attribute in the FieldRef element:

15 If you want to specify two filter criteria you also have to specify a join operator And or Or.

Janssens 21 If you want to specify more filter criteria you have to nest them in a very specific way:

Janssens 21 60 For each extra criterion you have to add an extra join operator at the outside of the query and add the criterion at the end:

Janssens 21 60 Belgium Retrieving List Items with CAML using the SharePoint Object Model
If you need to retrieve items from a list when developing web parts, application pages or custom field types you can best use the SPQueryobject from the SharePoint object model. This object is located in the Microsoft.SharePoint namespace of the Microsoft.SharePoint.dll located in the Global Assembly Cache.

Instantiate the object as follows:

SPQuery qry = new SPQuery();The most important property is the Query property, which needs to be set to your CAML query:

string camlquery = "" + "Smith" + ";qry.Query = camlquery;At this point you can execute the query on your list:

SPListItemCollection listItemsCollection = list.GetItems(qry);A small remark with the GetItems method of the SPList instance: this method returns a collection of type SPListItemCollection. It is possible that it is easier working with a DataTable. In that case you can execute the query as follows:

DataTable listItemsTable = list.GetItems(qry).GetDataTable();The query will not only return all list items that have their last name set to Smith, but also all columns of each list item. In cases you work with large lists it can be important to retrieve a subset of list items containing only the columns you need. In that case you will have to set the ViewFields property of the SPQuery object. You can do this by specifying all columns you want to see returned:

qry.ViewFields = "";This will return the first name and the last name of the retrieved employees, but also the system fields like the ID and the Created date.

The major disadvantage of the SPQuery object is that you can query only one list. If you want to query more than one list you will have to use the SPSiteDataQuery. More on this object in a later article because it earns special attention.

It is common knowledge by now but let me remind you that it’s always a good idea to use SPQuery to retrieve a subset of list items. You can loop through the list item collection to find the list items that match your needs but this will have a serious negative impact on the performance of your work.

Retrieving List Items with CAML using the SharePoint Web Services
If you are developing office clients or any other application that will not run on the server where SharePoint is installed you will need to use the SharePoint Web Services to retrieve (or update) information from SharePoint. If you want to query a list you will need to execute the GetListItems method from the Lists.asmxSharePoint web service.

Working with the SharePoint web services is different in Visual Studio 2005 then in Visual Studio 2008.

Retrieving List Items from the Lists.asmx using Visual Studio 2005First you have to reference the web service in your Visual Studio project. If you work with Visual Studio 2005 you have to add a Web Reference to theLists.asmx.

Then you have to instantiate the web service and pass the url of the SharePoint site, plus the location and name of the SharePoint web service. The SharePoint web services are all located in the ISAPI directory of the SharePoint 12 hive but are accessible from outside via the _vti_bin directory.

Initialize the Lists.asmx web service:

ListService listsWs = new ListService.Lists();listsWs.Url = siteUrl + @"/_vti_bin/lists.asmx";Then you have to set the credentials. In case you don’t need to specify a username or password you can proceed as follows:

listsWs.Credentials = System.Net.CredentialCache.DefaultCredentials;If you have to specify a user name and password:

listsWs.Credentials = new System.Net.NetworkCredential(userName, password);If you also have to specify a domain, use the other overload:

listsWs.Credentials = new System.Net.NetworkCredential(userName, password, domain);Then you are ready to call the GetListItems method, which requires the following syntax:

resultNode = _sharepointSite.ListsWSS.GetListItems(listName, viewName, queryNode, viewFieldsNode, rowLimit, queryOptionsNode, webID);Not all arguments are required. Arguments like view name, row limit and web ID are optional.

The query node argument will contain the CAML query as explained in previous sections but need to be enclosed within a and tag:

XmlDocument camlDocument = new XmlDocument();XmlNode queryNode = camlDocument.CreateElement("Query");queryNode.InnerXml = "" + "Smith" + ";The same applies to the ViewFields node:

XmlNode viewFieldsNode = camlDocument.CreateElement("ViewFields");viewFieldsNode.InnerXml = "" + "";As you will have noticed, you also need a QueryOptions node. This node will be explained later in this series. If you have no QueryOptions to specify you can pass in an empty node:

XmlNode queryOptionsNode = camlDocument.CreateElement("QueryOptions");Retrieving List Items from the Lists.asmx using Visual Studio 2008But in case you are working with Visual Studio 2008 you will have to add a Service Reference to theLists.asmxweb service. If you don’t want to work asynchronously you have to uncheck the Generate Asynchronous Operations option in the Advanced dialog. When closing the dialog box Visual Studio automatically adds an app.config or web.config file. Open this file and locate the security section. The following XML is generated automatically:

Replace it with the following:

Return to your code and instantiate the web service:

ListsWS.ListsSoapClient ws = new ListsWS.ListsSoapClient();You also have to set the necessary credentials. If you can work with the default credentials you can write the following:

ws.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials; ws.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;If necessary you can also pass user name, password and domain:

ws.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("Administrator", "secret", "U2UCOURSE"); ws.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;If necessary you can set the URL to the web service dynamically:

ws.Endpoint.Address = new System.ServiceModel.EndpointAddress( "http://wss.u2ucourse.com/_vti_bin/lists.asmx");Now you are ready to call the GetListItems method of the web service. There is no difference in calling this method from within Visual Studio 2005:

XmlDocument camlDocument = new XmlDocument(); XmlNode queryNode = camlDocument.CreateElement("Query");queryNode.InnerXml = "" + "Smith" + "; XmlNode viewFieldsNode = camlDocument.CreateElement("ViewFields");viewFieldsNode.InnerXml = "" + ""; XmlNode queryOptionsNode = camlDocument.CreateElement("QueryOptions"); resultNode = _sharepointSite.ListsWSS.GetListItems(listName, viewName, queryNode, viewFieldsNode, rowLimit, queryOptionsNode, webID);The returned XML is rather complex and needs some special attention. I will come back on this in a later article.

Query Options
Executing a query is not only about CAML. When working with the SPQuery object you can set different properties to influence the returned list items. When working with the SharePoint web services, these options are translated into CAML and are part of the QueryOptions element.

RowLimitSetting this property limits the number of rows returned in the result set.

When working with the SPQuery object:

qry.RowLimit = 10;When working with the GetListItems method of the Lists.asmx web service:

XmlNode queryOptionsNode = camlDocument.CreateElement("QueryOptions");queryOptionsNode.InnerXml = "10";IncludeMandatoryColumnsWhen this Boolean property is set to True, the result set will not only return the columns as defined in the ViewFields property, but also the columns that you defined in the list as required.

When working with the SPQuery object:

qry.IncludeMandatoryColumns = true;When working with the GetListItems method of the Lists.asmx web service:

XmlNode queryOptionsNode = camlDocument.CreateElement("QueryOptions");queryOptionsNode.InnerXml = "True";DatesInUtcSetting this Boolean property specifies whether the query returns dates in Coordinated Universal Time (UTC) format. The syntax is similar to that of the previously described property.

ExpandUserFieldWhen you omit this property or set it to false, user fields will return the login name of the user.

Setting this Boolean property to true (or include it in the QueryOptions node), user fields are returned as follows:

Karine Bosch,#U2UCOURSE\karine,#karine@U2UCOURSE.COM,#,#Karine BoschThe returned value includes the login name, e-mail address, Session Initiation Protocol (SIP) address, and title, when present, which causes a user field to behave as a multilookup field. The syntax is similar to that of the previously described property.

There are some other query options to set but they will be explained in detail in the next section.

Special Types of Queries
Some special types of lists require more specialized CAML queries. In some cases it only affects the CAML but in other cases you have to set extra SPQuery properties. If you execute this query against the Lists web service it will affect another argument of the GetListItems method, i.e. the QueryOptions argument.

Building queries for working with FoldersA first variant I will explain is how you can work with folders and sub folders. A folder is a special list item on a list or document library. If you execute a standard CAML query you will end up with list items from the root folder.

If you want to query all folders and sub folders of a list or document library, you have to define extra query options. If you are working with the object model you have to set the ViewAttributes property of the SPQuery object as follows:

qry.ViewAttributes = "Scope='Recursive'";If you work with GetListItems method of the Lists.asmx SharePoint web service, you have to define an extra node with the QueryOptions element:

XmlNode queryOptionsNode = camlDocument.CreateElement("QueryOptions");queryOptionsNode.InnerXml = "";If you want to query a specific sub folder using the SPQuery object, you have to set the Folder property:

qry.Folder = list.ParentWeb.GetFolder("Folders DocLib/2008");When working with the web services you have to do the following:

XmlNode queryOptionsNode = camlDocument.CreateElement("QueryOptions");queryOptionsNode.InnerXml = "Folders DocLib/2008";Building Queries for working with DateTime ValuesFiltering on DateTime fields also requires some extra attention. First of all when querying for a specific date, you have to use the SharePoint datetime notation:

2008-08-10T10:00:00Z But in this case the date is hard coded and the time part will not be taken into account. This query will return all list items with a start date as of 10 August 2008, also those starting before 10 o’clock. If you want your query to take into account the time part, you have to use a special attribute IncludeTimeValue that you can set on the FieldRef element:

2008-08-10T10:00:00Z This query will return all list items with a start date as of 10 August 10 o’clock.

As already said, this way the date is hard coded. If you want your query a bit more dynamic, you can always use the element Today.

Today will not take a time part into account. Unfortunately a Now element doesn’t exist.

You can also add or subtract a number of days from today’s date. In that case you have to add the Offset attribute to the Today element. The Offset attribute accepts a positive value for adding days and a negative value for subtracting days.

As all this is pure CAML, the query is the same whether you work with the object model or the SharePoint web services.

Building Queries for Calendar ListsCalendar lists also require a little more attention. A calendar list is based on the Event content type. Normal events can be retrieved with the usual CAML queries. It’s only when you start working with recurring events (events that occur once a day or twice a week or month) that you run into problems.

The Event content type defines a field named fRecurrence, which is set to 1 when a recurring event is created.


Defining a recurring event

When the Calendar view is rendered a recurring event is split into a number of event instances, one for each recurrence.


Calendar view showing event instances for recurring event

The definition of the recurrence is XML stored in another field defined by the Event content type, i.e. RecurrenceData. An example of such a definition looks as follows:

su FALSE Fortunately you don’t have to parse the XML yourself to get the actual instances of the recurring event. You can use a combination of CAML syntax and query options to achieve this.

When working with the SPQuery object you need to set the ExpandRecurrences property to true. You also have to specify a date in the CalendarDate property. This date will be used to compare the recurring event instances.

Next you have to add a DateRangesOverlap element to the Where clause of the CAML query. This element is used in queries to compare the dates in a recurring event with the date specified in the CalendarDateproperty to see whether they overlap. The CAML looks as follows:

The element is used to specify that all occurrences within a month need to be returned. You can also specify Day, Week or Year.

In case you need to work with the GetListItems method of the Lists.asmx web service, you translate the query options into XML:

XmlNode queryOptionsNode = camlDocument.CreateElement("QueryOptions");queryOptionsNode.InnerXml = "TRUE" + "2008-08-12T10:00:00Z";Read more about Calendar lists here: http://blogs.msdn.com/sharepoint/archive/2007/05/14/understanding-the-sharepoint-calendar-and-how-to-export-it-to-ical-format.aspx

This is it about retrieving List Items using CAML. Don’t hesitate to post your comments and questions below.

Thursday, March 11, 2010

Syntax for directly calling the Web Service using HTTP GET

The syntax for directly calling the Web Service using HTTP GET is

http://server/webServiceName.asmx/functionName?parameter=parameterValue

Therefore, the call for our Web Service will be

http://localhost/work/aspx/SampleService.asmx/GetSecurityInfo?Code=IBM

Creating a .NET Web Service

REF: http://www.15seconds.com/Issue/010430.htm



Microsoft .NET marketing has created a huge hype about its Web Services. This is the first of two articles on Web Services. Here we will create a .NET Web Service using C#. We will look closely at the Discovery protocol, UDDI, and the future of the Web Services. In the next article, we will concentrate on consuming existing Web Services on multiple platforms (i.e., Web, WAP-enabled mobile phones, and windows applications).


Why do we need Web Services?


After buying something over the Internet, you may have wondered about the delivery status. Calling the delivery company consumes your time, and it's also not a value-added activity for the delivery company. To eliminate this scenario the delivery company needs to expose the delivery information without compromising its security. Enterprise security architecture can be very sophisticated. What if we can just use port 80 (the Web server port) and expose the information through the Web server? Still, we have to build a whole new Web application to extract data from the core business applications. This will cost the delivery company money. All the company wants is to expose the delivery status and concentrate on its core business. This is where Web Services come in.


What is a Web Service?


Web Services are a very general model for building applications and can be implemented for any operation system that supports communication over the Internet. Web Services use the best of component-based development and the Web. Component-base object models like Distributed Component Object Model (DCOM), Remote Method Invocation (RMI), and Internet Inter-Orb Protocol (IIOP) have been around for some time. Unfortunately all these models depend on an object-model-specific protocol. Web Services extend these models a bit further to communicate with the Simple Object Access Protocol (SOAP) and Extensible Markup Language (XML) to eradicate the object-model-specific protocol barrier (see Figure 1).

Web Services basically uses Hypertext Transfer Protocol (HTTP) and SOAP to make business data available on the Web. It exposes the business objects (COM objects, Java Beans, etc.) to SOAP calls over HTTP and executes remote function calls. The Web Service consumers are able to invoke method calls on remote objects by using SOAP and HTTP over the Web.


Figure 1. SOAP calls are remote function calls that invoke method executions on Web Service components at Location B. The output is rendered as XML and passed back to the user at Location A.

How is the user at Location A aware of the semantics of the Web Service at Location B? This question is answered by conforming to a common standard. Service Description Language (SDL), SOAP Contract Language (SCL) and Network Accessible Specification Language (NASSL) are some XML-like languages built for this purpose. However, IBM and Microsoft recently agreed on the Web Service Description Language (WSDL) as the Web Service standard.

The structure of the Web Service components is exposed using this Web Service Description Language. WSDL 1.1 is a XML document describing the attributes and interfaces of the Web Service. The new specification is available at msdn.microsoft.com/xml/general/wsdl.asp.


The task ahead


The best way to learn about Web Services is to create one. We all are familiar with stock quote services. The NASDAQ, Dow Jones, and Australian Stock Exchange are famous examples. All of them provide an interface to enter a company code and receive the latest stock price. We will try to replicate the same functionality.

The input parameters for our securities Web service will be a company code. The Web service will extract the price feed by executing middle-tier business logic functions. The business logic functions are kept to a bare minimum to concentrate on the Web service features.


Tools to create a Web Service


The core software component to implement this application will be MS .NET Framework SDK, which is currently in beta. You can download a version from Microsoft. I used Windows 2000 Advance Server on a Pentium III with 300 MB of RAM.

The preferred Integration Development Environment (IDE) to create Web Services is Visual Studio .NET. However, you can easily use any text editor (WordPad, Notepad, Visual Studio 6.0) to create a Web Service file.

I assume you are familiar with the following concepts:

Basic knowledge of .NET platform
Basic knowledge of C#
Basic knowledge of object-oriented concepts
Creating a Web Service


We are going to use C# to create a Web Service called "SecurityWebService." A Web Service file will have an .ASMX file extension. (as opposed to an .ASPX file extension of a ASP.NET file). The first line of the file will look like

<%@ WebService Language="C#" class="SecurityWebService" %>

This line will instruct the compiler to run on Web Service mode and the name of the C# class. We also need to access the Web Service namespace. It is also a good practice to add a reference to the System namespace.
using System;
using System.Web.Services;

The SecurityWebService class should inherit the functionality of the Web Services class. Therefore, we put the following line of code:
public class SecurityWebService : WebService

Now we can use our object-oriented programming skills to build a class. C# classes are very similar to C++ or Java classes. It will be a walk in the park to create a C# class for anyone with either language-coding skills.
Dot-net Web Services are intelligent enough to cast basic data types. Therefore, if we return "int," "float," or "string" data types, it can convert them to standard XML output. Unfortunately, in most cases we need get a collection of data regarding a single entity. Let's take an example.

Our SecurityWebService stock quotes service requires the user to enter a company code, and it will deliver the full company name and the current stock price. Therefore, we have three pieces of information for a single company:


Company code (data type - string)
Company name (data type - string)
Price (data type - Double)
We need to extract all this data when we are referring to a single stock quote. There are several ways of doing this. The best way could be to bundle them in an enumerated data type. We can use "structs" in C# to do this, which is very similar to C++ structs.
public struct SecurityInfo
{
public string Code;
public string CompanyName;
public double Price;
}

Now we have all the building blocks to create our Web Service. Therefore, our code will look like.

<%@ WebService Language="C#" class="SecurityWebService" %>

using System;
using System.Web.Services;

public struct SecurityInfo
{
public string Code;
public string CompanyName;
public double Price;
}

public class SecurityWebService : WebService
{
private SecurityInfo Security;

public SecurityWebService()
{
Security.Code = "";
Security.CompanyName = "";
Security.Price = 0;
}

private void AssignValues(string Code)
{
// This is where you use your business components.
// Method calls on Business components are used to populate the data.
// For demonstration purposes, I will add a string to the Code and
// use a random number generator to create the price feed.

Security.Code = Code;
Security.CompanyName = Code + " Pty Ltd";
Random RandomNumber = new System.Random();
Security.Price = double.Parse(new System.Random(RandomNumber.Next(1,10)).NextDouble().ToString("##.##"));
}


[WebMethod(Description="This method call will get the company name and the price for a given security code.",EnableSession=false)]
public SecurityInfo GetSecurityInfo(string Code)
{
AssignValues(Code);
SecurityInfo SecurityDetails = new SecurityInfo();
SecurityDetails.Code = Security.Code;
SecurityDetails.CompanyName = Security.CompanyName;
SecurityDetails.Price = Security.Price;
return SecurityDetails;
}

}


Remember, this Web Service can be accessed through HTTP for any use. We may be referring to sensitive business data in the code and wouldn't want it to fall into the wrong hands. The solution is to protect the business logic function and only have access to the presentation functions. This is achieved by using the keyword "[Web Method]" in C#. Let's look at the function headers of our code.
[WebMethod(Description="This......",EnableSession=false)]
public SecurityInfo GetSecurityInfo(string Code)

This function is exposed to the public. The "description" tag can be used to describe the Web Service functionality. Since we will not be storing any session data, we will disable the session state.
private void AssignValues(string Code)

This is a business logic function that should not be publicly available. We do not want our sensitive business information publicly available on the Web. (Note:- Even if you change the "private" keyword to "public," it will still not be publicly available. You guessed it, the keyword "[Web Method]" is not used.)
We can use the business logic in this function to get the newest stock price quote. For the purpose of this article I have added some text to the company code to create the company name. The price value is generated using a random number generator.

We may save this file as "SampleService.asmx" under an Internet Information Service (IIS)-controlled directory. I have saved it under a virtual directory called "/work/aspx." I'll bring it up on a Web browser.



This is a Web page rendered by the .NET Framework. We did not create this page. (The page is generated automatically by the system. I did not write any code to render it on the browser. This graphic is a by-product of the previous code.) This ready-to-use functionality is quite adequate for a simple Web Service. The presentation of this page can be changed very easily by using ASP.NET pagelets and config.web files. A very good example can be found at http://www.ibuyspy.com/store/InstantOrder.asmx.

Notice a link to "SDL Contract." (Even if we are using WSDL, .NET Beta still refers to SDL. Hopefully this will be rectified in the next version). This is the description of the Web Service to create a proxy object. (I will explain this in the next article.) This basically gives an overview of the Web Service and it's public interface. If you look closely, you will only see the "Web-only" methods being illustrated. All the private functions and attributes are not described in the SDL contract. The SDL contract for the SecurityWebService can be found in Appendix A.


view demo of SecurityWebService

How do we use a Web Service?


Now we can use this Web Service. Let's enter some values to get a bogus price feed.



By clicking the Invoke button a new window will appear with the following XML document



This is how the Web Service releases information. We need to write clients to extract the information from the XML document. Theses clients could be

A Web page
A console / Windows application
A Wireless Markup Language (WML) / WMLScript to interact with mobile phones
A Palm / Win CE application to use on Personal Digital Assistants (PDAs).
I will explain this process in the next article.
You can also call the Web Service directly using the HTTP GET method. In this case we will not be going through the above Web page and clicking the Invoke button. The syntax for directly calling the Web Service using HTTP GET is

http://server/webServiceName.asmx/functionName?parameter=parameterValue

Therefore, the call for our Web Service will be

http://localhost/work/aspx/SampleService.asmx/GetSecurityInfo?Code=IBM

This will produce the same result as clicking the Invoke button.

Now we know how to create a Web Service and use it. But the work is half done. How will our clients find our Web Service? Is there any way to search for our Web Service on the Internet? Is there a Web crawler or a Yahoo search engine for Web Services? In order to answer these questions we need to create a "discovery" file for our Web Service.


Creating a Discovery file


Web Service discovery is the process of locating and interrogating Web Service descriptions, which is a preliminary step for accessing a Web Service. It is through the discovery process that Web Service clients learn that a Web Service exists, what its capabilities are, and how to properly interact with it. Discovery file is a XML document with a .DISCO extension. It is not compulsory to create a discovery file for each Web Service. Here is a sample discovery file for our securities Web Service.






We can name this file "SampleService.disco" and save it to the same directory as the Web Service. If we are creating any other Web Services under the "/work/aspx" directory, it is wise to enable "dynamic discovery." Dynamic discovery will scan for all the *.DISCO files in all the subdirectories of "/work/aspx" automatically.




An example of an active discovery file can be found at http://services3.xmethods.net/dotnet/default.disco. By analyzing the discovery file we can find where the Web Services reside in the system. Unfortunately both these methods require you to know the exact URL of the discovery file. If we cannot find the discovery file, we will not be able to locate the Web Services. Universal Description, Discovery, and Integration (UDDI) describes mechanisms to advertise existing Web Services. This technology is still at the infant stage. UDDI is an open, Internet-based specification designed to be the building block that will enable businesses to quickly, easily, and dynamically find and transact business with one another using their preferred applications. A reference site for UDDI is http://uddi.microsoft.com.
There have been a lot of Web Services written by developers. www.xmethods.com is one of the sites that has an index of Web Services. Some developers are building WSDL search engines to find Web Services on the Web.


Deploying a Web Service


Deploying the Web Services from development to staging or production is very simple. Similar to ASP.NET applications, just copy the .ASMX file and the .DISCO files to the appropriate directories, and you are in business.

The future of the Web Services

The future looks bright for the Web Service technology. Microsoft is not alone in the race for Web Service technology. Sun and IBM are very interested. There are SOAP toolkits available for Apache and Java Web servers. I believe Web Services needs a bit of work, especially the Web Service discovery process. It is still very primitive.

On a positive note, Web Services have the potential to introduce new concepts to the Web. One I refer to as "pay per view" architecture. Similar to pay-TV, we can build Web sites that can generate revenue for each request a user sends (as opposed to a flat, monthly subscription). In order to get some data, we can sometimes pay a small fee. Commercially this could be handy for a lot of people.


Examples


Online newspaper sites can publish a 10-year-old article with a $2 "pay per view" structure.
Stock market portals can itemize every user portfolio for every single stock quote and build pricing and discount structures.
And the list goes on ...
On a very optimistic note, Web Services can be described as the "plug and play" building blocks of enterprise Business to Business (B2B) Web solutions.

Appendix A




xmlns="urn:schemas-xmlsoap-org:sdl.2000-01-25">








This method call will get the company name and the price for a given security code.














This method call will get the company name and the price for a given security code.












This method call will get the company name and the price for a given security code.



elementFormDefault="qualified" xmlns="http://www.w3.org/1999/XMLSchema">























Some handy web services

REF: http://www.actionscript.org/forums/showthread.php3?t=70742

Scientific Web Services

http://www.webservicex.net/ConvertAc...tion.asmx?WSDL - Convert acceleration
http://www.webservicex.net/CovertPressure.asmx?WSDL - Convert Pressure
http://www.webservicex.net/ConvertDensity.asmx?WSDL - Convert Density
http://www.webservicex.net/ConverPower.asmx?WSDL - Convert Power
http://www.webservicex.net/ConvertAngle.asmx?WSDL - Convert Angles
http://www.webservicex.net/ConvertTorque.asmx?WSDL - Convert Torque
http://www.webservicex.net/convertMe...ight.asmx?WSDL - Convert Weight
http://www.webservicex.net/convertVolume.asmx?WSDL - Convert Volume
http://www.webservicex.net/ConvertTemperature.asmx?WSDL - Convert Temperature
http://www.webservicex.net/convertFrequency.asmx?WSDL - Convert Frequency
http://www.webservicex.net/Astronomical.asmx?WSDL - Convert Astronomical Values (i.e. - the speed of light)
http://www.webservicex.net/ConvertForec.asmx?WSDL - Convert Force
http://www.webservicex.net/ConvertEnergy.asmx?WSDL - Convert Energy
http://www.webservicex.net/ConvertArea.asmx?WSDL - Convert Area
http://www.webservicex.net/ConvertCooking.asmx?WSDL - Convert Cooking units
http://www.webservicex.net/ConvertComputer.asmx?WSDL - Convert Computer units (i.e. - megabytes)
http://www.webservicex.net/ConvertWeight.asmx?WSDL - Convert Weights
http://www.webservicex.net/ConvertSpeed.asmx?WSDL - Convert Speeds
http://www.webservicex.net/length.asmx?WSDL - Convert Distances
http://www.webservicex.net/periodictable.asmx?WSDL - Periodic Table (i.e. - find atomic weight of Oxygen)

Validation Web Services

http://www.webservicex.net/CreditCard.asmx?WSDL - validate a credit card number
http://www.webservicex.net/ValidateEmail.asmx?WSDL - validate email address
http://www.tpisoft.com/smartpayments/validate.asmx?WSDL - validate credit card number
http://ws.cdyne.com/emailverify/Emai...mail.asmx?wsdl - validate email
http://ws.cdyne.com/phoneverify/phoneverify.asmx?wsdl - validate phone number

Business Web Services

http://www.webservicex.net/stockquote.asmx?WSDL - get stock quote of a particular company

Geographic Web Services

http://www.webservicex.net/uklocation.asmx?WSDL - get location of place in the UK
http://www.webservicex.net/AustralianPostCode.asmx?WSDL - get location in Austrailia of a certain Post code
http://www.webservicex.net/uszip.asmx?WSDL - find location in US based on the ZIP code
http://www.webservicex.net/country.asmx?WSDL - Get country details (i.e. - the currency)
http://www.webservicex.net/geoipservice.asmx?WSDL - get IP address of the persons computer
http://www.webservicex.net/whois.asmx?WSDL - a WHOIS domain lookup
http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl - find geo location on earth based on Zip code
http://www.innergears.com/WebService...yZip.asmx?WSDL - Get City and state based on ZIP
http://www.innergears.com/WebService...Zips.asmx?WSDL - Calculate distance between 2 zip codes
http://www.innergears.com/WebService...tate.asmx?WSDL - get a list of ZIP codes in a City
http://www.innergears.com/WebService...ords.asmx?WSDL - calculate distance between Lat/Long

Communication Web Services

http://demo.wsabi.org/axis/services/...ngService?wsdl - check and see if a Yahoo! user is online/offline
http://ws.acrosscommunications.com/Fax.asmx?WSDL - send a FAX to someone
http://www.abysal.com/soap/AbysalEmail.wsdl - send an email (this does add a small ad at the bottom of the outgoing email, but it's just text. It looks like the ad at the bottom of Hotmail emails)
http://ws.strikeiron.com/ReversePhoneLookup?WSDL - reverse Phone number lookup/validator

Weather Web Services

http://www.ejse.com/WeatherService/Service.asmx?WSDL - get the weather based on Zip code/City Name
http://www.innergears.com/WebService...yZip.asmx?WSDL - get the weather based on ZIP
http://www.innergears.com/WebService...yZip.asmx?WSDL - get a 9 day forecast
http://www.innergears.com/WebService...ICAO.asmx?WSDL - get the weather forecast based on ICAO code
http://www.innergears.com/WebService...ings.asmx?WSDL - Get state weather warnings
http://www.innergears.com/WebService...ICAO.asmx?WSDL - get weather around an airport
http://weather.terrapin.com/soap/HurricaneService.wsdl - get information on current storms/hurricanes

Miscellaneous Web Services

http://www.27seconds.com/Holidays/US...ates.asmx?WSDL - Get the date of a certain Holiday
http://www.27seconds.com/Holidays/US...vice.asmx?WSDL - the other half of the Holdiay Web Service above, now includes Great Britain Holidays. (Documentation)
http://webservices.codingtheweb.com/bin/qotd.wsdl - Quote of the day
http://www.boyzoid.com/comp/randomQuote.cfc?wsdl - a random Quote
http://www.swanandmokashi.com/HomePa...cope.asmx?WSDL - get the Horoscope reading
http://www.hlrs.de/quiz/quiz.wsdl - a quiz webservice, returns a question, 4 options, and the correct answer