Web Services

424
-1

Published on

Apresentação sobre Web Services

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
424
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
16
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Web Services

  1. 1. Gustavo Loureiro dos ReisLeonardo César de Sousa CamposVictor da Silva Montalvão
  2. 2. • Componentes da Aplicação• utilizam Protocolos Abertos• Completo e Autodescrito• Disponibilizados através da Web para outras aplicações
  3. 3. Arquivo .asmx – extensão ASP.NET para XML Web Services<%@ WebService Language="VBScript" Class="TempConvert" %>Imports SystemImports System.Web.ServicesPublic Class TempConvert :Inherits WebService<WebMethod()> Public Function FahrenheitToCelsius(ByVal Fahrenheit As String) As String dim fahr fahr=trim(replace(Fahrenheit,",",".")) if fahr="" or IsNumeric(fahr)=false then return "Error" return ((((fahr) - 32) / 9) * 5)end function<WebMethod()> Public Function CelsiusToFahrenheit(ByVal Celsius As String) As String dim cel cel=trim(replace(Celsius,",",".")) if cel="" or IsNumeric(cel)=false then return "Error" return ((((cel) * 9) / 5) + 32)end functionend class http://www.w3schools.com/webservices/ws_example.asp
  4. 4. Transport Protocol• HTTP, FTP, SMTPMessaging Protocol• SOAP, WS-AddressingDescription Protocol• Public Interface• WSDLDiscovery Protocol• Available Services• UDDL*
  5. 5. • Protocolo baseado em XML• Troca de informações via HTTP Blocks Envelope Header Body Fault
  6. 6. POST /InStock HTTP/1.1Host: www.example.orgContent-Type: application/soap+xml; charset=utf-8Content-Length: nnn<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"><soap:Body xmlns:m="http://www.example.org/stock"> <m:GetStockPrice> HTTP/1.1 200 OK <m:StockName>IBM</m:StockName> Content-Type: application/soap+xml; charset=utf-8 </m:GetStockPrice> Content-Length: nnn</soap:Body> <?xml version="1.0"?></soap:Envelope> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap- encoding"> <soap:Body xmlns:m="http://www.example.org/stock"> <m:GetStockPriceResponse> <m:Price>34.5</m:Price> </m:GetStockPriceResponse> </soap:Body> </soap:Envelope>
  7. 7. public HTTPRequest() { try { HttpClient httpclient = new DefaultHttpClient(); String body="Data"; String bodyLength=new Integer(body.length()).toString(); System.out.println(bodyLength); URI uri=new URI("SOMEURL?Param1=1234&Param2=abcd"); HttpPost httpPost = new HttpPost(uri); httpPost.addHeader( "SOAPAction", strReferenceToSoapActionValue ); StringEntity entity = new StringEntity(body,"text/xml",HTTP.DEFAULT_CONTENT_CHARSET); httpPost.setEntity(entity); RequestWrapper requestWrapper=new RequestWrapper(httpPost); requestWrapper.setMethod("POST"); requestWrapper.setHeader( "SOAPAction", strReferenceToSoapActionValue ); requestWrapper.removeHeaders("Host"); requestWrapper.setHeader("Host", “..."); HttpResponse response = httpclient.execute(requestWrapper); } catch (Exception e) { e.printStackTrace(); } }
  8. 8. • XML-based Language for Locating and Describing Web Services
  9. 9. • JAX-WS é uma biblioteca de chamadas remotas de procedimento (RPC), que permite implementar serviços baseados nas normas XSD, WSDL e SOAP
  10. 10. ...Definir o mapeamento de WSDL para Java e vice-versa... implementar Web Services partindo de um contrato WSDL ou de código Java ...criar código cliente de invocação de Web Services
  11. 11. Chamadas remotas de procedimento, passo-a-passo:
  12. 12. OBS: Definição do acordo WSDL entre cliente e servidor
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×