• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Web Services
 

Web Services

on

  • 582 views

Apresentação sobre Web Services

Apresentação sobre Web Services

Statistics

Views

Total Views
582
Views on SlideShare
582
Embed Views
0

Actions

Likes
0
Downloads
10
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Web Services Web Services Presentation Transcript

    • Gustavo Loureiro dos ReisLeonardo César de Sousa CamposVictor da Silva Montalvão
    • • Componentes da Aplicação• utilizam Protocolos Abertos• Completo e Autodescrito• Disponibilizados através da Web para outras aplicações
    • 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
    • Transport Protocol• HTTP, FTP, SMTPMessaging Protocol• SOAP, WS-AddressingDescription Protocol• Public Interface• WSDLDiscovery Protocol• Available Services• UDDL*
    • • Protocolo baseado em XML• Troca de informações via HTTP Blocks Envelope Header Body Fault
    • 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>
    • 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(); } }
    • • XML-based Language for Locating and Describing Web Services
    • • JAX-WS é uma biblioteca de chamadas remotas de procedimento (RPC), que permite implementar serviços baseados nas normas XSD, WSDL e SOAP
    • ...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
    • Chamadas remotas de procedimento, passo-a-passo:
    • OBS: Definição do acordo WSDL entre cliente e servidor