Web Services

A web service is an application that exposes a Web accesible API. That means you can invoke the application programmatically over the web. Applications invoking this Web Service are referred to as clients.
An XML web service is a .NET component that replies to HTTP requests that are formatted using the SOAP syntax.
Web services allow a degree of interoperability among applications over the Internet.
XML web services are just ASP.NET applications that intercept requests for .asmx files.


These are application components
They communicate using open protocols
They are self contained and self describing
They can be discovered using UDDI
A basic web service is XML plus HTTP



You construct a web page that takes parameters in the query string and returns the relevant data. The client then sends an HTTP Get request with the appropriate URL.


These allow access to software components through standard web protocols such as HTTP and SMTP.
Web services allow us to use the Internet and XML to create software components that communicate with each other regardless of language or platform.


XML - This is used to structure the data
SOAP - This is used to transfer the data
This stands for Simple Object Access Protocol.
SOAP is an XML based protocol that allows applications to exchange information over http.
It is a communication protocol
It is platform independent
It is based on XML, HTTP and SMTP
It is language independent


WSDL - This is used to describe the web service, the description of the methods provided (Web Service Description Language)
UDDI - This is used to get a list of services available. This is a directory service where companies can register and search for web services. This stands for Universal Description, Discovery and Integration.
SMTP -


Relevant Namespaces

System.Web.Services 
System.Web.Services.Protocols
System.Net
System.Threading
System.Web.Security
System.IO


Accessing

Any remote client that knows where to look for this service and what arguments to pass can call this method remotely by posting an HTTP Get request.
This is just one of three protocols that you can use to access this web service through the Internet.
The other two being HTTP Post and SOAP.


Any client that can post an HTTP request can be a client of the XML web service.


Windows Application

Add a Web Reference
This dialog box lets you select a web service from those registered in a Universal Description, Discovery and Integration directory.
UDDI directories are a bit like the web services yellow pages in that they list XML web services distributed across the Internet.
Visit www.uddi.org for more details.
Type the path to your .asmx file on your local machine amd press Enter.
The left pane will display a description page associated with the web service.
The right pane contains additional links to view the WSDL contract.
Go ahead and add the reference.


After any changes to the web service you should rebuild the proxy class.
The easiest way is to select the service and select "Update Reference".


3 Web Service Protocols

You should use SOAP in all your applications and only use the other two for testing purposes.
HTTP GET
This method lets you type in the whole query string directly into a browser.
When you invoke this method the text will be automatically sent to the .asmx page.


HTTP POST
Similar to the HTTP GET except that the arguments are passed in the HTML body rather than the query string.


HTTP SOAP
This uses SOAP messages for both the input arguments and for the return value.
The root node of any SOAP message is the message envelope which contains the message body
In turn the body contains an XML tag named after the target method and all arguments are sent inside this block.



Any soap message can contain an optional header, which might contain additional information not strictly related to the method being called.
For example a client might use the header to send its credentials so that the web service can record who accessed its methods and when.
SOAP is the only protocol that support objects and structures.
The only requirement for an object fed to (or returned) is that it must be serializable.
SOAP is also the only protocol that supports output arguments using ByRef.


web.config Changes

All three protocols are enabled by default although you can disable one or more of them by editing your local web.config file.
In a production web service you might want to drop all the add tags except the SOAP one.

<configuration> 
   <system.web>
      <webServices>
         <protocols>
            <add name="HttpSoap" />
            <add name="HttpPost" />
            <add name="HttpGet" />
            <add name="Documentation" />
         </protocols>
      </webServices>
   </system.web>
</configuration>

references.vb

This file holds the proxy class for the client side component of the web service and is generated automatically.



Different types of web interaction




Web Queries



Discovery File (.disco)

This provides information to help browsers determine the URLs at any websites which web services are available.




Async Calls

When you fire off multiple async web calls maintain an arraylist of all the calls we are waiting for - need a consistent naming convention
May be nicer to have an event that fires when they have all been returned.



Proxy Class



Fiddler

This is free Microsoft Web Services debugging tool




© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopNext