{"id":38502,"date":"2022-01-27T11:26:10","date_gmt":"2022-01-27T11:26:10","guid":{"rendered":"https:\/\/arquiconsult.com\/?p=38502"},"modified":"2024-10-23T10:57:58","modified_gmt":"2024-10-23T09:57:58","slug":"debug-attach","status":"publish","type":"post","link":"https:\/\/arquiconsult.com\/en\/debug-attach\/","title":{"rendered":"#06 DEBUG &#038; ATTACH: HOW TO DEBUG WEB SERVICES AND JOB QUEUE"},"content":{"rendered":"<div class=\"services_vertical horizontal_services row\" style=\"background-color: #f7f7f7; padding: 25px; border-radius: 5px; text-align: justify;\">\n<p>Finding and fixing bugs or errors is part of our daily tasks. This process may take a lot of time if we do not use the debugger and, even more, if the error occurs in a Web Service or in a Job Queue task.<\/p>\n<p>In the older versions, the solution was to use the \u201cDebug Next\u201d functionality, but in Visual Studio Code that functionality is not present. No problem, we\u2019ll use Attach.<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p><strong>1 Create a basic Web Service Codeunit<\/strong><br \/>\nA new Codeunit was created with a method that returns a random color.<\/p>\n<p><img loading=\"lazy\" class=\"size-medium wp-image-25274 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2021\/10\/Create-a-basic-Web-Service-Codeunit_image019-452x480.png\" alt=\"Create a basic Web Service Codeunit_image#019\" width=\"452\" height=\"480\" srcset=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2021\/10\/Create-a-basic-Web-Service-Codeunit_image019-452x480.png 452w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2021\/10\/Create-a-basic-Web-Service-Codeunit_image019.png 489w\" sizes=\"(max-width: 452px) 100vw, 452px\" title=\"-\"><strong>2 Publish the Codeunit as a Web Service in Business Central<\/strong><br \/>\nAfter publishing, make sure you can access the SOAP URL.<\/p>\n<p><img loading=\"lazy\" class=\"size-full wp-image-25278 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2021\/10\/Publish-the-Codeunit_019.png\" alt=\"Publish the Codeunit_#019\" width=\"555\" height=\"108\" title=\"-\"><strong>3 In VS Code, add a new \u201cattach\u201d configuration in launch.json<\/strong><\/p>\n<p><img loading=\"lazy\" class=\"size-medium wp-image-25280 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2021\/10\/In-VS-Code-add-a-new-attach-configuration-in-launch.json_image019-427x480.png\" alt=\"In VS Code, add a new \u201cattach\u201d configuration in launch.json_image#019\" width=\"427\" height=\"480\" srcset=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2021\/10\/In-VS-Code-add-a-new-attach-configuration-in-launch.json_image019-427x480.png 427w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2021\/10\/In-VS-Code-add-a-new-attach-configuration-in-launch.json_image019.png 474w\" sizes=\"(max-width: 427px) 100vw, 427px\" title=\"-\"><strong>4 Set the Breakpoint in VS Code and start a Debug Session with \u201cDebug without publishing (Ctrl + Shift + F5)\u201d and select the \u201cAttach: BC180\u201d configuration<\/strong><br \/>\n<img loading=\"lazy\" class=\"size-full wp-image-25284 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2021\/10\/Set-the-Breakpoint-in-VS-Code-and-start-a-Debug-Session_image019.png\" alt=\"Set the Breakpoint in VS Code and start a Debug Session_image#019\" width=\"556\" height=\"240\" title=\"-\"><strong>5 Use SOAP UI (or Postman) to call the Method<\/strong><\/p>\n<p><img loading=\"lazy\" class=\"size-full wp-image-25287 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2021\/10\/Use-SOAP-UI-or-Postman-to-call-the-Method_image019.png\" alt=\"Use SOAP UI (or Postman) to call the Method_image#019\" width=\"556\" height=\"144\" title=\"-\"><strong>6 The debugger will break on the Breakpoint<\/strong><\/p>\n<p><img loading=\"lazy\" class=\"size-full wp-image-25290 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2021\/10\/The-debugger-will-break-on-the-Breakpoint_image019.png\" alt=\"The debugger will break on the Breakpoint_image#019\" width=\"555\" height=\"300\" title=\"-\"><\/p>\n<p><strong>Notes:<\/strong><\/p>\n<ol>\n<li>The example above will also work with Job Queue if you change the \u201cbreakOnNext\u201d property to \u201cBackground\u201d in the attach configuration in launch.json.<\/li>\n<li><img loading=\"lazy\" class=\"size-full wp-image-25293 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2021\/10\/Notes_image019.png\" alt=\"Notes_image#019\" width=\"440\" height=\"341\" title=\"-\"> To attach the app must be firstly published without debugging, before you start the debugging session <sup>(A)<\/sup>.<\/li>\n<\/ol>\n<table style=\"height: 31px;\" width=\"911\">\n<tbody>\n<tr>\n<td><sup>(A)<\/sup> <a href=\"https:\/\/docs.microsoft.com\/en-us\/dynamics365\/business-central\/dev-itpro\/developer\/devenv-attach-debug-next\" target=\"_blank\" rel=\"noopener\">https:\/\/docs.microsoft.com\/en-us\/dynamics365\/business-central\/dev-itpro\/developer\/devenv-attach-debug-next<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<!--themify_builder_content-->\n<div id=\"themify_builder_content-38502\" data-postid=\"38502\" class=\"themify_builder_content themify_builder_content-38502 themify_builder tf_clear\">\n    \t<!-- module_row -->\n\t<div  data-lazy=\"1\" class=\"module_row themify_builder_row tb_gpqz311 tb_first tf_clearfix\">\n\t    \t\t<div class=\"row_inner col_align_top col-count-1 tf_box tf_w tf_rel\">\n\t\t\t<div  data-lazy=\"1\" class=\"module_column tb-column col-full first tb_e8dl312 tf_box\">\n\t\t\t    \t        <div class=\"tb-column-inner tf_box tf_w\">\n\t\t    <!-- module text -->\n<div  class=\"module module-text tb_upmm204 arquitps-data  \" data-lazy=\"1\">\n        <div  class=\"tb_text_wrap\">\n    <p><script>\njQuery(\".tbp_post_month:contains(Janeiro)\").html(\"January\");\n\njQuery(\".tbp_post_month:contains(Fevereiro)\").html(\"February\");\n\n\njQuery(\".tbp_post_month:contains(Mar\u00e7o)\").html(\"March\");\n\n\njQuery(\".tbp_post_month:contains(Abril)\").html(\"April\");\n\n\njQuery(\".tbp_post_month:contains(Maio)\").html(\"May\");\n\n\njQuery(\".tbp_post_month:contains(Junho)\").html(\"June\");\n\n\njQuery(\".tbp_post_month:contains(Julho)\").html(\"July\");\n\njQuery(\".tbp_post_month:contains(Agosto)\").html(\"August\");\n\njQuery(\".tbp_post_month:contains(Setembro)\").html(\"September\");\n\njQuery(\".tbp_post_month:contains(Outubro)\").html(\"October\");\n\njQuery(\".tbp_post_month:contains(Novembro)\").html(\"November\");\n\njQuery(\".tbp_post_month:contains(Dezembro)\").html(\"December\");\t\n\n\n\n<\/script><\/p>    <\/div>\n<\/div>\n<!-- \/module text -->\t        <\/div>\n\t    \t<\/div>\n\t\t    <\/div>\n\t    <!-- \/row_inner -->\n\t<\/div>\n\t<!-- \/module_row -->\n\t\t<!-- module_row -->\n\t<div  data-anchor=\"sucesso\" data-hide-anchor=\"1\" data-lazy=\"1\" class=\"module_row themify_builder_row sucesso repeat tb_has_section tb_section-sucesso tb_7v52414 tf_clearfix\" >\n\t    \t\t<div class=\"row_inner col_align_top col-count-1 tf_box tf_w tf_rel\">\n\t\t\t<div  data-lazy=\"1\" class=\"module_column tb-column col-full first tb_8szw414 tf_box\">\n\t\t\t    \t        <div class=\"tb-column-inner tf_box tf_w\">\n\t\t    <!-- module buttons -->\n<div  class=\"module module-buttons tb_hnbg414 buttons-horizontal transparent popmake-24705 large circle tf_textc\" data-lazy=\"1\">\n    \t<div class=\"module-buttons-item tf_inline_b\">\n\t\t\t\t\t\t\t<a href=\"#\" class=\"ui builder_button tb_default_color\" >\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"tf_inline_b tf_vmiddle\">Give as a Feedback and Suggest Questions<\/span>\n\t\t\t\t\t\t\t\t\t\t\t<\/a>\n\t\t\t    \t<\/div>\n\t<\/div>\n<!-- \/module buttons -->\n\t        <\/div>\n\t    \t<\/div>\n\t\t    <\/div>\n\t    <!-- \/row_inner -->\n\t<\/div>\n\t<!-- \/module_row -->\n\t<\/div>\n<!--\/themify_builder_content-->\n","protected":false},"excerpt":{"rendered":"<p>Finding and fixing bugs or errors is part of our daily tasks. This process may take a lot of time if we do not use the debugger and, even more, if the error occurs in a Web Service or in a Job Queue task. In the older versions, the solution was to use the \u201cDebug [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":37966,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2099],"tags":[2076,2083,2082],"acf":[],"_links":{"self":[{"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/posts\/38502"}],"collection":[{"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/comments?post=38502"}],"version-history":[{"count":0,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/posts\/38502\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/media\/37966"}],"wp:attachment":[{"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/media?parent=38502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/categories?post=38502"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/tags?post=38502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}