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
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


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.




EndPointClass

URI - (Uniform Resource Identifier) represents the address
Identity - represents the security identitiy
Headers - (optional) - providing more detailed addressing information.


EndPoints provide clients with access to the service
If any of the following Address, Binding or Contrat are changed then a new proxy must be created.



EndPoint Specification in a Config File



EndPoint Specification in Code

This can be done using the EndPointAddress class
The URI can be a full path or a path relative to the service base address.
In order to use a WCF Service you need to create a WCF client proxy.
In Visual Studio this client proxy is created for you when you add the Service Reference.
If you don't want to add a service reference you can achieve the same result using svcutil.exe



Discovery File (.disco)

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



Launching a Web Page

System.Diagnostics.Process.Start("https://bettersolutions.com")




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.




Advanced

Where does this page come from ?
When asp.net intercepts a request for an .asmx page without anything on the query string, it used reflection to extract the attributes and the method names of the first class in the .asmx file.
It then synthesizes the HTML page for you automatically.
Only the first class in this file is visible in a browser.
The page that produces the output is just an .aspx page.
This file is the DefaultWsdlHelpGenerator.aspx file which can be customised if you want to.
Changing this file will affect all the XML web services running on this machine.




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