Sunday, April 27, 2008

Write Web Service using .NET

What and Why Is Web Services
Web Services, as known as XML Web Services, are units of application logic that provide data and services to other applications using Internet (or Intra net). Applications access Web Services via different kinds of Web protocols and data formats such as XML, with no need to worry about how Web Services are implemented. They can be implemented for any operation system that supports communication over the Internet and Intranet. They are the cornerstones of the Microsoft .NET programming model.
Web Services can be accessed by any language, using any component model, and running on any operating system. They utilize HTTP as the underlying transport, which allows function requests to pass through corporate firewalls. XML is used to format the input and output parameters of the request, so the request is not tied to any particular component technology or object calling convention. The Microsoft .NET Framework makes Web Services easy to write components that communicate using HTTP and SOAP.
Web Services are similar to the regular services in our life. For example, if you have a car that needs gasoline to run, you do not need to have your own gas pump at home. All you need to do is drive to a nearby gas station, fill up the gas tank, and you are on your way. You have received a service from the gas station, Web Services are like this as well. Now, imagine that you are going to build a web site or a Internet system for you company, you can use Web Services' "services" to get a complicated application. That should lighten your workload.
Building Web Services
Before you start to create your Web Services, there are some of concepts you have to know. The two most important things are the Simple Object Access Protocol (SOAP) and XML. SOAP is a way for applications to communicate with one another over the Internet, independent of platforms. Unlike Http-Get and Http-Post, only can send name/value, but SOAP can send various rich data type, classes, objects, and others. XML is a pared-down version of SGML, designed especially for Web documents. It allows designers to create their own customized tags, enable the definitions, transmission, validation, and interpret data between applications and between organizations. SOAP relies on XML.

Web Services relies on XML-formatted messages to send data and receive commands. Web Services support three stardard protocols, Http-Get, Http-Post, and SOAP. In Web Services , the Http protocol only can be use the simple data. We do not discuss it here. All Web Services exmaples in this artical use SOAP communication.
Now let's explore how to build a Web Service at server. There are two ways to do so. If your Web Service is quite simple, you can directly save it as a .asmx file, such as TempConvertorCsharp.asmx. In some complicated applications, especially for database related applications, I prefer to use components. For instance, The DB Query1/2-Web Service at my .NET tutorial, I created the classes as component first, then created a .asmx Web Service file that called the component (to create a component, see my .NET tutorial for details.) The whole structure of the service is "UI-Component(Web Service classes)-Database" known as 3-tier architecture.

Understanding Web Services
Interconnectedness engendered by the World Wide Web has created a pressure to create applications that are interoperable and distributable over the network. The direction of effort is towards creating applications that connect to each other regardless of the language or platform in which the application was created.
Web services are externally exposed systems that allow applications to talk to each other and share information over a network. The web service standards are built upon other standards such as HTTP or XML and are not reliant upon any proprietary systems. The Web service is itself a collection of methods that can be called from a remote location so that these methods accept and return parameters and provide for a wide variety of functionalities that can be used internally in the application that is exposed to the public.
The concept behind web services is not new. The ad hoc methods of tying applications together have merely given place to organized methods of communications between applications. Standardized specifications have also lowered costs and shortened development timelines.
Prior to the emergence of Visual Studio.NET in the market a number of technologies attempted to cater to the needs of the Web based world. Let us briefly look at the various technologies that tried to address these issues.
SOAP
Simple Object Access Protocol (SOAP) is a protocol that uses the XML to describe the data and Hyper Text Transfer Protocol (HTTP) to transmit application data. The Web Service and the client application must agree upon a common protocol to facilitate communication. SOAP is a standard communication protocol for interchanging information in a structured format in a distributed environment. Messaging is an example of information exchange between a client and a web service. The calls made by a client application to a web method and the data returned by a web method to the client are the messages that are actually exchanged. A SOAP packet is created when a web client makes a call to the web method. This message contains the name of the web method and the parameters that are needed for making a call to the web method in XML format. The Web method is invoked based on the information available in the SOAP Packet
The System.Runtime.Serialization.Formatters.Soap namespace contains the System.Runtime.Serialization.Formatters.Soap.SoapFormatter class, which can be used to serialize and de-serialize objects in the SOAP format. When building applications that uses the types in this namespace, a reference must be made to the System.Runtime.Serialization.Formatters.Soap.dll assembly. The COM+ SOAP service permits the publishing of a component as a XML Web Service. Clients can continue to access the component using previous methods, but the component is also accessible using WSDL (Web Services Description Language) and SOAP. We will see more of SOAP usage later in the lesson.
Disco and UDDI
The Web Service Discovery Tool (DISCO) is used to discover the URLs of XML Web Services located on a Web server and saves documents related to each XML service on a local disk. The DISCO takes the URL and discovers and produce publishes discovery documents (.wsdl, .xsd, .disco and .dicomap files) as arguments. Some of the options available for use with this tool are:
/d[omain]:domain Specifies the domain name to use when connecting to a proxy server that requires authentication
/nosave Does not save the discovered document or results
/nologo Suppresses the Microsoft startup banner display
/o[ut]:directoryName Specifies the output directory in which to save the discovered documents. Current directory is the default one.
/p[assword]:password Specifies the password to use when connecting to a proxy server
/proxy:url Specifies the URL of the proxy server to use for HTTP requests.
The following command is an example of how the tool can be used to search a specified URL for the discovery of documents. The documents are then saved to the current directory. It will throw an error message if it cannot find discoverable documents at the URL specified.
disco http://www.vbdotnetlearning.com/selflearningservie.disco
To specify a directory to save the documents you can use the /out option as shown below:
disco /out:VBtutorial http://www.vbdotnetlearning.com
Universal Description, Discovery and Integration (UDDI) is a platform independent framework functioning like a directory that provides a mechanism to locate and register web services on the internet. The web service provider makes the web service available to the consumer by describing the web service using a WDSL document and then registering the Web service in the UDDI Directory. The UDDI Directory contains pointers to the Web service and the WDSL document for the Web service. After this is done the Client Applications can discover the Web service using the UDDI Directory. The UDDI specification calls for three elements as given below:
(1) White Pages -- These provide business contact information
(2) Yellow Pages -- These organize Web services into categories like usage billing service, authorization service and so on.
(3) Green Pages --These Pages provide detailed technical information about individual services.
WSDL
Web Service Discovery Language (WSDL) is a markup language that describes the web service. In order to use this Web service, the Client application developers need to know the methods exposed by the Web service and the parameters to be passed to these methods. It is imperative that access to these methodologies is available at development time and it is just this need that WSDL addresses. A typical WSDL document provides the following information to the developer:
v The Web service available for a given Web site
v The purpose for which these services can be used
v The types of parameters that need to be passed to a Web service
v The format used to access these Web services
v The URL at which a Web Service can be accessed

Thursday, April 10, 2008

"Unable to save orientation" - Capture Viewer

Problem: When trying to save the rotation on a faxed image, gives "Unable to save rotation" error.[FileNet Capture 4.1 and CE 3.0]
Solution: The error occurs because of unavailability of 'Rotation' tag on the image. Solution is to specify rotation value in DocProcessing component as 180 degree.[and then rotate the image again to 180 degree in source code incase of customize application].