Tải bản đầy đủ (.pdf) (22 trang)

aspnet information technology

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.18 MB, 22 trang )

<span class='text_page_counter'>(1)</span><div class='page_container' data-page=1>

Session 17



</div>
<span class='text_page_counter'>(2)</span><div class='page_container' data-page=2>

Review



 Controls help in reusability of visual as well as functional capabilities.


 Custom web controls can be created in two ways:


 Pagelets


 Web Controls using C#


 Pagelets are custom controls that look like an asp page, and have the


extension .ascx.


 Web Controls render HTML automatically.


 Custom Controls, which compose of other controls as well, are known


as composite controls.


 The <b>System.Web.UI.INamingContainer</b> interface has no methods;


</div>
<span class='text_page_counter'>(3)</span><div class='page_container' data-page=3>

Objectives



Explain Web Services


Create Web Services using ASP.net


Consume Web Services using various protocols


Create proxies for Web Services


</div>
<span class='text_page_counter'>(4)</span><div class='page_container' data-page=4></div>
<span class='text_page_counter'>(5)</span><div class='page_container' data-page=5>

Service


Service has


to be


</div>
<span class='text_page_counter'>(6)</span><div class='page_container' data-page=6>

Internet with Web Services



Web Server


Web Server


Web Server
Constellation


Sites, services,
and devices


collaborate


</div>
<span class='text_page_counter'>(7)</span><div class='page_container' data-page=7>

Create a Web service


Define service interface and invocation methods
for Web services


Publish Web services on Intranet or Internet
Find Web service in order to use it


Invoke the web service in order to use it



</div>
<span class='text_page_counter'>(8)</span><div class='page_container' data-page=8>

Accessed over the web
Called using its Interface


Registered in a service registry


Standard Web protocols to communicate
Loose coupling


An important aspect of loose coupling is that Web


services are integrated <b>just-in-time</b> when they


are necessary.


</div>
<span class='text_page_counter'>(9)</span><div class='page_container' data-page=9>

Cross business integration
Improved efficiency


Closer customer relationships


Facilitation of just-in-time integration
Complexity reduction


Legacy applications


</div>
<span class='text_page_counter'>(10)</span><div class='page_container' data-page=10>

Potential risk of security in exposing the
application assets of an organization


XML support is inevitable



Cost of deploying the Web service technology is
slightly high


</div>
<span class='text_page_counter'>(11)</span><div class='page_container' data-page=11>

<%@ <b>WebService</b> <b>Language</b>="C#" <b>class</b>="TestWS" %>


<b>using System.Web.Services</b>;
class TestWS


{


<b>[WebMethod]</b>


public string SayHello(string name)
{


return "Hello " + name;
}


}


<b>Save the file with .asmx extension </b>


<b>Specifies that this asp page is a web service </b>


<b>Language in which the Web service is written </b>
<b>Class containing Web methods </b>


<b>Import namespace </b>


</div>
<span class='text_page_counter'>(12)</span><div class='page_container' data-page=12>

Methods using which a web service can be


consumed are listed below:


HTTP-GET
HTTP-POST
SOAP


Using Web Service Proxies


</div>
<span class='text_page_counter'>(13)</span><div class='page_container' data-page=13></div>
<span class='text_page_counter'>(14)</span><div class='page_container' data-page=14>

<html><body>


<p>Calling a web service using the POST method </p>
<form name="form1" <b>method="POST" </b>


<b>action="http://localhost/test1.asmx/SayHello"</b>>
<p> Enter your name :


<input type="text" name="name">
</p>
<p>
<input type="submit">
</p>
</form>
</body>
</html>


</div>
<span class='text_page_counter'>(15)</span><div class='page_container' data-page=15>

Lightweight protocol used to exchange
information in a decentralized, distributed
computing environment.


Helps to access objects, services, and


servers in a platform independent way.


Provides the extensibility required by HTTP
with the help of XML.


HTTP/XML based protocol that is capable of
invoking a method with specific values.


<b>SOAP – Simple Object Access Protocol </b>


</div>
<span class='text_page_counter'>(16)</span><div class='page_container' data-page=16>



Information about the web service, such as
the methods it contains, and the parameters
that need to be passed to these methods,
are described through WSDL language


Based on XML


Uses tags to define attributes of the service


</div>
<span class='text_page_counter'>(17)</span><div class='page_container' data-page=17>

<b>WSDL http://localhost/aspex/CH17/WebServiceDemo.asmx /n:FirstWS</b>

Web Service Proxies



The file TestWS.cs created is converted into a .dll file using command:


</div>
<span class='text_page_counter'>(18)</span><div class='page_container' data-page=18>

<script language="C#" runat=server>


public void Page_Load(Object Sender, EventArgs e)


{


<b> FirstWS.TestWS WSObj = new FirstWS.TestWS();</b>
<b> Text1.Text = WSObj.SayHello("Scooby");</b>


}


</script>
<form>


<asp:TextBox id=Text1 runat=server/>
</form>


</div>
<span class='text_page_counter'>(19)</span><div class='page_container' data-page=19>

UDDI is used to locate:


Information on Web services offered by a business partner
List of providers for a particular Web service


Technical details about exposing a particular Web service
Companies offering a particular Web service


Helps to <b>register services</b> provided by the service
providers, so that they can be shared


Helps the <b>service consumers</b> or <b>Web users</b> to locate
the Web services


</div>
<span class='text_page_counter'>(20)</span><div class='page_container' data-page=20>

UDDI
API
Schema



UDDI
Services
UDDI


Specifications
(Business
Registrations)


</div>
<span class='text_page_counter'>(21)</span><div class='page_container' data-page=21>

Summary 1-2



 <b>A service has two characteristics: </b>Interface and Registration.


 Web services reduce the “communication-gap” among the Web applications,


enhancing interactivity. Web sites thereby group together to form a
constellation, providing users with a rich user experience


 Advantages of Web Services


 Cross business integration
 Improved efficiency


 Closer customer relationships


 Facilitation of just-in-time integration


 The extension of a Web service file in .NET is <b>.asmx</b>.


 The [WebMethod] tag notifies the ASP.NET compiler that the method to follow



should be a Web method, which is to be exported onto the Web.


 A Web service could be called from a browser, an ASP page or even another


</div>
<span class='text_page_counter'>(22)</span><div class='page_container' data-page=22>

Summary 2-2



 WSDL is the short form for <b>Web Services Description Language</b>.


WSDL is the grammar for a Web service, or moreover, could be
thought of as a language that describes or portrays a Web service.


 The proxy class does not contain any application logic. Instead, it


contains the transporting logic as to how the parameters would be
passed and the result retrieved.


 The proxy class will also contain a list of all the methods that are


present in the Web service and their prototypes.


 A proxy class can be created from any WSDL file.


 UDDI is the abbreviation for <b>Universal Description, Discovery and </b>


<b>Integration</b>.


 UDDI helps in registering the services provided by the service providers


</div>


<!--links-->

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×