Presentasjon lastes. Vennligst vent

Presentasjon lastes. Vennligst vent

Web Services gjennom eksempler Johannes Brodwall.

Liknende presentasjoner


Presentasjon om: "Web Services gjennom eksempler Johannes Brodwall."— Utskrift av presentasjonen:

1 Web Services gjennom eksempler Johannes Brodwall

2 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 2 Innhold •Hvorfor – integrasjon, det tjenesteorienterte nettet •Hva – XML, SOAP, WSDL og HTTP •Hvordan – Visual Studio.NET, Axis, J2EE 1.4, Ruby

3 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 3 Viktige organisasjoner •OASIS (Organisation for the Advancement of Structured Information Standards) –Viktigste bidrag: ebXML •W3C (World Wide Web Consortium) •WS-I (Web-Services Interoperability) •IBM, Microsoft: –Utvikler de fleste delstandardene

4 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 4 Fra tcp til the semantic web Sockets FTP/telnet/ gopher Sockets FTP/telnet/ gopher Web Browser http/html Web Browser http/html The Semantic Web Integrasjon av bedriftens siloer 1980-tallet1990-19951995-20002000-2005Fremtiden Kommunikasjon Web Service http/soap Web Service http/soap Discovery Samarbeid med partnere Dynamisk transformasjon

5 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 5 Hva er Web Services ”A Web Service is application logic that is accessible using standard Internet protocols.” [ Keith Ballinger ] Like components, Web Services represent black-box functionality that can be used and reused without regard to how the service is implemented.

6 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 6 Fordeler •INTEGRASJON •Hetrogene parter •Debugbar protokol •Nettverksvennlig teknologi

7 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 7 To ting •Arkitektur •Komponentbasert •Distribuert •Åpen •Innkapslet •Tjenesteorientert •Teknologier •SOAP •WSDL •HTTP

8 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 8 Tjenesteorientert • Grovkornet • Verdi til ”kunder” • Standardisert grensesnitt In an SOA, resources are made available to other participants in the network as independent services that are accessed in a standardized way. This provides for more flexible loose coupling of resources than in traditional systems architectures. [ http://looselycoupled.com ]http://looselycoupled.com

9 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 9 Bokstavsuppe •XML – eXtensible Markup Language –Standard for å strukturere tekst-dokumenter –Presenterer en hierarkisk struktur •SOAP – Simple Object Access Protocol –XML standards for metodekall –Data som utveksles mellom tjenestene •WSDL – Web Services Definition Language –XML standard for tjenestebeskrivelse –Brukes for å finne ut hvordan en tjeneste skal kalles

10 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 10 Eksempel.NET klient.NET server J2EE Server Ruby Server J2EE klient Ruby klient

11 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 11 Web Service Servere •Støtte i utviklingsmiljø tar hånd om det meste – nesten som å skrive vanlige klasser •Utvikles som stateless klasser eller metoder i språket •Publiseres automatisk, via en descriptor, eller programmatisk •Normalt vil servermiljøet generere WSDL automatisk

12 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 12 Arkitektur (Axis) HTTP applikasjonsserver (Tomcat) Web Service Container (Axis) Our Service Marshall/ unmarshal Management WSDL generation Transport Custom handlers

13 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 13 Java Server // HelloWebService.jws // is placed in axis webapp directory // Axis autocompiles JWS-files public class HelloWebService { public String sayHelloTo(String name) { System.out.println("Hello web services says hello to " + name); return "Hello from Axis, " + name; }

14 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 14.NET Server using System; using System.Diagnostics; using System.Web.Services; namespace KompisDotNetService { [WebService(Namespace=" http://brodwall.no/demo/kompis2004-01-20/ ")] public class HelloService : WebService { [WebMethod] public string sayHelloTo(string name) { Debug.WriteLine ("Hello web services says hello to " + name); return "Hello from.NET, " + name; }

15 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 15 Ruby Server require 'soap/rpc/standaloneServer' class HelloWorldServer < SOAP::RPC::StandaloneServer def on_init add_method(self, 'hello_world', 'from') end def hello_world(from) puts "Hello web services says hello to " + from "Hello from Ruby, #{ from }" end

16 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 16 Web Service klienter •Automatisk genererte ”stubs” for enklere bruk –Nesten som vanlig bruk av klasser •Dynamisk kall •Dynamisk ”discovery” – ikke vist

17 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 17.NET Client... private void buttonExec_Click(object sender, System.EventArgs e) { HelloAxis.HelloWebServiceService service = new HelloAxis.HelloWebServiceService(); textBoxResponse.Text = service.sayHelloTo(textBoxName.Text); }...

18 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 18 Java Client (JAX-RPC style) // Generated with the Axis WSDL2Java tool import no.brodwall.demo.kompis2004_01_20.HelloServiceLocator; import no.brodwall.demo.kompis2004_01_20.HelloServiceSoap; public class JavaClientOfDotNet { public static void main(String[] args) throws Exception { HelloServiceLocator locator = new HelloServiceLocator(); HelloServiceSoap service = locator.getHelloServiceSoap(); System.out.println(service.sayHelloTo("JAX-RPC client")); }

19 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 19 Java Client import java.rmi.RemoteException; import javax.xml.rpc.ServiceException; import org.apache.axis.client.Call; import org.apache.axis.client.Service; public class LowLevelClient { public static void main(String[] args) throws Exception { Service service = new Service(); Call call = (Call)service.createCall(); call.setTargetEndpointAddress( "http://localhost:1234/axis/HelloWebService.jws"); call.setOperationName("sayHelloTo"); String result = (String)call.invoke(new Object[] { "Simple Axis client" }); System.out.println("Result: " + result); }

20 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 20 Ruby Clients # HelloWebService stub is created by wsdl2ruby require 'defaultDriver.rb' service = HelloWebService.new() puts service.sayHelloTo("Ruby") # Manual calling require 'soap/rpc/driver' endpoint = "http://localhost:8080/axis/HelloWebService.jws" service = SOAP::RPC::Driver.new(endpoint, nil) service.add_method("sayHelloTo", "name") service.sayHelloTo("Ruby")

21 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 21 Invocation Framework •I praksis er den manuelle metoden vanskelig å bruke –Forskjellige servere trenger forskjellig informasjon –Det kan være tidkrevende å sette opp •WSIF (http://ws.apache.org/wsif) løser dette ved å dynamisk generere kall- objekter fra WSDLhttp://ws.apache.org/wsif

22 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 22 Første inntrykk •Enkel integrasjon av homogene miljøer •Blir mer problematisk med: –Utveksling av komplekse datastrukturer –Bruk av standard typer i forskjellige språk –Exceptions fra serveren

23 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 23 SOAP

24 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 24 SOAP - request Ruby

25 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 25 SOAP - response Hello from Axis, Ruby

26 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 26 SOAP meldinger •Består av Envelope, Header og Body •Header kan inneholde protokollutvidelser –Transaksjoner –Sikkerhet –Logging –Kryptering •Body inneholder selve meldingen –Kan også inneholde Faults •Multipart – kan inneholde flere deler

27 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 27 Web Services Definition Language •Beskriver tjenester, dataformater og endepunkt •Skal definere ”alt som trengs” for å kunne kommuniserer med tjenesten

28 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 28 WSDL - outline

29 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 29 WSDL - interface

30 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 30 WSDL - implementation

31 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 31 WSDL

32 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 32 UDDI •Universal Discovery, Directory Integration •Tenkt som ”gule sider” for web services •Forutsetter standardisering på WSDL-nivå •http://www.ibm.com/developerworks/w ebservices/library/ws-eight/http://www.ibm.com/developerworks/w ebservices/library/ws-eight/

33 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 33 Begrensninger •Datainnhold –Struktur –Spesifikke typer –Standardiserte grensesnitt •Request-response-basert –Ingen callbacks (WS-Callback) –(Normalt) Synkront (S070-S071) •Standarder sent og ikke generelt implementert –Sikkerhet (WS-Security) –Transaksjoner (WS-Transactions, WS-Coordination) –Se http://www.w3.org/TR/ws-arch-scenarios/http://www.w3.org/TR/ws-arch-scenarios/

34 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 34 Fremtiden slik jeg ser den •WS-Security, WS-Transactions får bredere implementasjoner •UDDI forblir en kuriositet –Bransjestandarder lar vente på seg •Semantic web forblir en drøm

35 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 35 Diskusjon •Når er SOAP verd overheaden? •Vil det fungere i våre situasjoner? •Hvordan komme i gang? •Kommer det til å bli standardisering av tjenester? •I hvilken grad ønsker vi dynamisk discovery? –Stoler vi på at programmet velger riktig leverandør? –Vil automatiske ”meglere” krasje ”det frie marked”?

36 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 36 Konklusjon •Web services integrerer hetrogene tjenester •Fungere bra for enkle tjenester •Krever mer jobb med komplekse tjenester •Web Services er ment til å være en del av dynamisk discovery

37 Copyright 2004 – Brodwall IT Services (BITS) johannes@brodwall.com Slide 37 •Axis – Apache Web Service rammeverk •JAX-RPC – Java API for XML Remote Procedure Calls •J2EE 1.4 – viktige forbedringer i JAX-RPC •WS-I, WS-Security •The Semantic Web Stikkord


Laste ned ppt "Web Services gjennom eksempler Johannes Brodwall."

Liknende presentasjoner


Annonser fra Google