Advertise with us
ASP.NET 4.5 & SQL 2012 Hosting
Web Services For Beginer .net coder with fast example
Visual Studio 2005
Tips & Tricks
Submit Resource or code snippet
... and get
Win Digital camera, ASP.NET Books, Free softwares!!
Web Services For Beginer .net coder with fast example
15 Jul, 2010
In this article i try show the most simply way to lern web service quick and easy
.NET Classes used :
The services of WWW are the not only universal technology of the transport between any computer systems, but they let also differently approach to the construction of applications themselves. They make possible creating true Smart Clients - the application which offer the user rich interface, offline work and simple mechanisms to the transport with the server layer.
The service of WWW this fashionable subject since several years. They have to facilitate the integration of systems, folding them from blocks delivered by various manufacturers, but the programmer has a bit work despite the defined well communication layer continually.
The service of WWW is usual accessible function for the mediation of internet minutes. More exactly, the demand of the development is sent using minutes HTTP (applied in applications WWW to the transport of the server with the browser). Second connected from Web Services minutes - SOAP - he is the standard defining, to code in XML how the demand, parameters passed on to the procedure and as to take back the result (.SOAP operates NET 2.0 1.1 and 1.2). The large advantage of the services of WWW this in the principle the general agreement relating to standards. One can use the service working in Windows from the level of the application written in Javie, application working in the system of Unix can co-operate with the code .THE itp. NET Unfortunately, this agreement as yet relates to so-called Basic Profiles, that is the basic heap of the services of WWW, defining in the principle the only transport (this and so a lot of in the comparison with different technologies). More advanced mechanisms (e.g. digital signatures) they are accessible as the packets of add-ins.
The services of WWW have still one very useful tag. The language of the Web Service Description Language which describes the requirements of the given service was defined i.e. he defines exactly what data you should pass to call out the definite function and as the result will be saved. W.The of WWW accessible service is THE NET for the mediation of the file .asmx. If we call out him with the parameter WSDL: localhost / WSPayment / Service.asmx?WSDL, then we will see the description of all services (methods) available for the mediation of the given address of the URL. The the same mechanism lets automatically generate so-called classes proxy, necessary to calling out the services of WWW.
There are also the mechanisms of finding, e.g. servers UDDI or in the simpler version files .disco which let find necessary services on the basis of descriptions, names or required e.g. form WSDL. The application kliencka may not even theoretically be connected with the definite address the URL, under which there is the service of WWW, but to find the cheapest offer of the realization of the given task on the example dynamically, and this under the condition, that the service has the dostepowy interface itself.
IN VS.THE NET is the special project about the name of ASP.THE NET of Web Service. After the addition of the new project (THE NAME of the brochure let is WSPayment) the file Service will be generated automatically.asmx and the skeleton of the the main class of the service.
In the file .asmx is only information, that the code operating the side is in the separate file:
<%@ WebService Language =C #
CodeBehind =~/ App _ Code / Service.cs
Class =Service %>
However the skeleton of service WWWW this simply the class with suitable attributes. You should obligatorily add the attribute WebService, and the sensible space of the names which he will identify the service, and qualify the agreement with the profile is also passing worth - in this basic incident.
After pressing [F5] he will become started internet browser with the test side, letting to call out the function of WWW - here about the name Add - and to give two parameters.
One can equally easily use such service, but she is first making accessible under the solid address of the URL worth, e.g. on the local server IIS (the server of WWW delivered from Visual Studio starts on various postages and you should very often change the address which the customer calls out).
Click the powiekszycDodanie of the reference to the published service of WWW on the local server IIS. One using the button next to the field Target Location can choose the option Publish, for what, after the compilation of the project, create the new application IIS about the name WSPayment, choose her then and wgrac the there given service of WWW (one can accept the default setting in the window Publish Web Site after choosing the URL).
One can already add the reference to the service of WWW in this moment (similarly how in the incident of usual references to system libraries or different packets .THE NET). We choose Add Web Reference why we give the address of the URL of the given service - here: localhost / Service.asmx (because we published the service under this address).
When we add such URL, the suitable configurational parameter of the application comes into being - component about the name WSClientWin is added in Settings automatically _ localhost _ Service.
Addition of the reference to the service of WWW this in the reality the generating complex object proxy, the intermediary in the construction packet SOAP. One in the application klienckiej can write thanks to this: it
Is knowing that one can also generate proxy without creators worth - using the tools of the disco.exe and wsdl.exe (to finding services and generating suitable classes). One can also use API, e.g. WebClientProtocol.
Simple programme using the service of WWW came into being in this way. Basic mechanisms were showed.NET and Visual Studio, and czytelnik saw the probably worst possible way of utilization of the services of WWW near the opportunity. So one is not to write allowed!
Analysing the possibilities of the technology of Web Services, perceive oneself many similarities to the classic mechanism RPC (remote calling out the procedures), he is holds for the mediation of internet minutes so much that calling out, and not the quick binary minutes. If they to add e.g. to want numbers in the loop, then the sumaryczny overhead on the transport would be huge.
The services of WWW are connected with the conception SOA (Service Oriented Architecture)inseparably. The foundation is such that Web Service makes accessible certain service whose working and the principles of utilization are defined for the help of the so-called contract. This is not the service in the sense of the development of the function, rather certain business operation, e.g. the party of the order of the extradition of goods, the message of the trade order or the updating of the group of contact information in the system of CRM. The development of the service of WWW more resembles the message of the message to the different system then (or the modules) than the development of the function.
It is the different example looking on worth (which you should not also copy). Put, that we construct the interface to the addition of invoices, where we send the headline (as one message) first, and in next demands individual positions. Does first problem appear in such situation where from it - is known, how many positions there will be on the invoice? One adding the meter of the position to the headline can solve him, , but it is known from the mountain not necessarily, how many position the user will add to the invoice.
There is no also good method to get to know if the user application works farther or if she fell also e.g. unexpectedly and sends not the the rest of the position. Maybe timeout? But as to choose his size? At last third problem. The developments of services are served WWW so samo, how the messages of internet browser (sides HTML) - the server receives the demand, he executes the operations, the result sends back i... he leaves behind about the customer. And you should identify next messages coming to the service of WWW as the draught of the broadcast from one customer in the example system to invoices. One can use the mechanism of the session (the same, what at ASP.THE NET normally one - can apply the object Session in the service of WWW after the addition of the suitable attribute) or add to every message the name tag publicly the defining unambiguously draught of information sent by the given customer. However all these solutions only complicate application and service itself.
There is the considerably better solution. Let's put that the message was defined differently - as the whole consisting from headline and position. The set of information is sent to the service then and it is more considerably easily to process him. One can additionally establish the conduct in the incident, when the price of some goods or service changes. If he is e.g. lower, then the given position on the invoice will be corrected and the invoice will receive status accepted, and when he grows up he only is sent back to the customer with the information which are positions dearer. The all this type the so-called contract should define information.
Feedbacks about this page from members:
Sorry, I found this article difficult to follow as English is my main and only language. I assume I can create a Web Service from inside Visual Studio 2005 and upon clicking publish would have a skeleton of a web service. How do I communicate with this service? can this service store data or should it be used to transfer data from client (eg. web page) to server (eg. database)? And in either case, how would I go about this?
(06 Feb 2012)
View All Feedbacks
Average new registrations per day (in last 7 days):
Talk to Webmaster
SpiderWorks Technologies Pvt Ltd.
All Rights Reserved.