Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Testando Web Services

Testando Web Services

talles

July 22, 2015
Tweet

More Decks by talles

Other Decks in Programming

Transcript

  1. ‘’ “A Web service is a method of communication between

    two electronic devices over a network.” — Wikipédia
  2. O que interessa para nós SOAP (Service Oriented Architecture Protocol)

    ▣ Protocolo de mensagens que utiliza XML ▣ Possui metadados (WSDL) e a comunicação é feita de acordo com estes ▣ Utiliza o protocolo HTTP apenas como meio de transporte REST (Representational State Transfer) ▣ É uma arquitetura que utiliza o protocolo HTTP e não um protocolo propriamente dito ▣ Não possui metadados, a comunicação é feita de acordo com a documentação da API ▣ Utiliza o protocolo HTTP por completo (cabeçalho, verbo, paramêtro, status de retorno)
  3. Cliente & servidor Um cliente envia uma requisição a um

    servidor. E o servidor responde com uma resposta.
  4. Requisição HTTP Um requisição HTTP possui: ▣ Um método (ou

    verbo) ▣ Uma URL ▣ Paramêtros* ▣ Cabeçalhos ▣ Corpo* * Para alguns verbos (GET, HEAD, …) os paramêtros são incluídos na URL (query string) e a requisição não possui corpo
  5. Exemplo GET https://www.google.com/search?q=data+de+hoje User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36

    (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Language: en-US,en;q=0.5
  6. Exemplo 200 OK Content-Type: text/html; charset=UTF-8 Date: Mon, 22 Jun

    2015 20:51:03 GMT <!doctype html><html itemscope="" itemtype="http://schema.org/SearchResultsPage" lang="pt" ><head><meta content="/images/google_favicon_128.png" itemprop="image"><title>data de hoje - Pesquisa Google</title> (...)
  7. Verbos ACL, BASELINE-CONTROL, BIND, CHECKIN, CONNECT, COPY, DELETE, GET, HEAD,

    LABEL, LINK, LOCK, MERGE, MKACTIVITY, MKCALENDAR, MKCOL, MKREDIRECTREF, MKWORKSPACE, MOVE, OPTIONS, ORDERPATCH, PATCH, POST, PRI, PROPFIND, PROPPATCH, PUT, REBIND, REPORT, SEARCH, TRACE, UNBIND, UNCHECKOUT, UNLINK, UNLOCK, UPDATE, UPDATEREDIRECTREF, VERSION- CONTROL
  8. Verbos ACL, BASELINE-CONTROL, BIND, CHECKIN, CONNECT, COPY, DELETE, GET, HEAD,

    LABEL, LINK, LOCK, MERGE, MKACTIVITY, MKCALENDAR, MKCOL, MKREDIRECTREF, MKWORKSPACE, MOVE, OPTIONS, ORDERPATCH, PATCH, POST, PRI, PROPFIND, PROPPATCH, PUT, REBIND, REPORT, SEARCH, TRACE, UNBIND, UNCHECKOUT, UNLINK, UNLOCK, UPDATE, UPDATEREDIRECTREF, VERSION- CONTROL
  9. Verbos ▣ Create: POST* ▣ Retrieve: GET ▣ Update: PUT*

    ▣ Delete: DELETE * Dependendo da idempotência da operação
  10. Códigos de status 100 (Continue), 101 (Switching Protocols), 200 (OK),

    201 (Created), 202 (Accepted), 203 (Non-Authoritative Information), 204 (No Content), 205 (Reset Content), 206 (Partial Content), 300 (Multiple Choices), 301 (Moved Permanently), 302 (Found), 303 (See Other), 304 (Not Modified), 305 (Use Proxy), 307 (Temporary Redirect), 400 (Bad Request), 401 (Unauthorized), 402 (Payment Required), 403 (Forbidden), 404 (Not Found), 405 (Method Not Allowed), 406 (Not Acceptable), 407 (Proxy Authentication Required), 408 (Request Timeout), 409 (Conflict), 410 (Gone), 411 (Length Required), 412 (Precondition Failed), 413 (Payload Too Large), 414 (URI Too Long), 415 (Unsupported Media Type), 416 (Range Not Satisfiable), 417 (Expectation Failed), 426 (Upgrade Required), 500 (Internal Server Error), 501 (Not Implemented), 502 (Bad Gateway), 503 (Service Unavailable), 504 (Gateway Timeout), 505 (HTTP Version Not Supported).
  11. Códigos de status 100 (Continue), 101 (Switching Protocols), 200 (OK),

    201 (Created), 202 (Accepted), 203 (Non-Authoritative Information), 204 (No Content), 205 (Reset Content), 206 (Partial Content), 300 (Multiple Choices), 301 (Moved Permanently), 302 (Found), 303 (See Other), 304 (Not Modified), 305 (Use Proxy), 307 (Temporary Redirect), 400 (Bad Request), 401 (Unauthorized), 402 (Payment Required), 403 (Forbidden), 404 (Not Found), 405 (Method Not Allowed), 406 (Not Acceptable), 407 (Proxy Authentication Required), 408 (Request Timeout), 409 (Conflict), 410 (Gone), 411 (Length Required), 412 (Precondition Failed), 413 (Payload Too Large), 414 (URI Too Long), 415 (Unsupported Media Type), 416 (Range Not Satisfiable), 417 (Expectation Failed), 426 (Upgrade Required), 500 (Internal Server Error), 501 (Not Implemented), 502 (Bad Gateway), 503 (Service Unavailable), 504 (Gateway Timeout), 505 (HTTP Version Not Supported).
  12. Códigos de status ▣ 1XX: Informativa ninguém usa... ▣ 2XX:

    Sucesso funcionou :) ▣ 3XX: Redirecionamento não é aqui! ▣ 4XX: Erro do cliente erro na requisição :( ▣ 5XX: Erro do servidor deu erro no servidor :(
  13. ?