{"id":7831,"date":"2015-01-13T10:58:08","date_gmt":"2015-01-13T16:58:08","guid":{"rendered":"http:\/\/www.mrc-productivity.com\/legacy\/?page_id=7831"},"modified":"2020-04-10T16:20:32","modified_gmt":"2020-04-10T21:20:32","slug":"using-web-services","status":"publish","type":"page","link":"https:\/\/www.mrc-productivity.com\/legacy\/general\/using-web-services","title":{"rendered":"Using Web Services"},"content":{"rendered":"<h1>m-Power Web Services<\/h1>\n<p>&nbsp;<\/p>\n<p><a href=\"#intro\">Intro<\/a><br \/>\n<a href=\"#setup\">Set Up<\/a><br \/>\n<a href=\"#data\">Getting Data<\/a><br \/>\n<a href=\"#crud\">CRUD Actions<\/a><br \/>\n<a href=\"#promote\">Promoting<\/a><br \/>\n<a href=\"#notes\">Notes<\/a><\/p>\n<h3 id=\"intro\">Introduction<\/h3>\n<p>A very common feature of modern web applications is an API that can be accessed from outside the framework for use in any architecture.  m-Power has implemented such an API using RESTful web services, now available in supported templates.  For more regarding REST, please see this <a href=\"http:\/\/rest.elkstein.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">link<\/a>.<\/p>\n<h3 id=\"setup\">Set Up<\/h3>\n<p>Applications are set up exactly the same for both web services and standard applications.  Apps must be compiled\/recompiled with the precompile option set to include web services.  In the screenshot below, this is one of the two options at the bottom of the Application Settings page.<\/p>\n<p><img decoding=\"async\" src=\"\/legacy\/images\/webservice1.png\"><\/p>\n<p><strong>Note:<\/strong> If you choose to include both, your application will run exactly as before as web services are called from a different <a href=\"#data\">URL<\/a>.<\/p>\n<p>Web services are only available in supported templates, which include:<\/p>\n<p><a href=\"\/legacy\/retrievals\/multiple-record-retrieval-template\">Web 2.0 Multiple Record Inquiry<\/a> (Bootstrap: Multiple Row Data List)<br \/>\n<a href=\"\/legacy\/retrievals\/single-record-retrieval\">Web 2.0 Single Record Inquiry<\/a> (Bootstrap: Single Row Data List)<br \/>\n<a href=\"\/legacy\/maint\/display-and-maintain-rows-maintenance-template\"> Display and Maintain Rows<\/a> (Bootstrap: Data List with Web Form)<\/p>\n<p>Once you have selected the desired output, you must then recompile the application.  Overwriting is not required to add web services to an existing application.<\/p>\n<p><strong>Note:<\/strong> In order to use web services in a specific data dictionary, a new entry must be made to the web.xml file.  m-Power will automatically make this entry, however, the first time a web service is made in a dictionary, you must restart Tomcat in order to use it.  This will only need to be done the first time a web service app is created in each data dictionary.<\/p>\n<h3 id=\"data\">Getting Data<\/h3>\n<p>For templates that support data read, use the following URL:<br \/>\n\/mrcjava\/rest\/DD\/IXXXXXs\/get<\/p>\n<p>\u2026where DD is your data dictionary and IXXXXXs is your app number.  Additionally, any parms you would normally pass to the application can also be passed to the webservice like so:<br \/>\n\/mrcjava\/rest\/DD\/IXXXXXs\/get?parm1=val1&amp;parm2=val2<\/p>\n<p><strong>Note:<\/strong> For a complete list of parms, please see the supporting documentation for each selected template.<\/p>\n<p>Once the URL call is made, a JSON string object will be returned as the response, similar to the screenshot below:<\/p>\n<p><img decoding=\"async\" src=\"\/legacy\/images\/webservice2.png\"><\/p>\n<p>As can be seen, every field value has both the display value (CNAME) and the original value (CNAME_o).  The raw data is the same, however the display value has some work done to it such as trimming leading\/trailing spaces, numbers formatted according to format codes, etc.<\/p>\n<p><strong>Note:<\/strong> The type and rtndata values can be ignored as they are not used in web services.<\/p>\n<h3 id=\"crud\">CRUD Actions<\/h3>\n<p>For templates that support CRUD actions (Create, Read, Update, Delete), use the following URL:<br \/>\n\/mrcjava\/rest\/DD\/MXXXXXs\/ACTION?key=val&amp;parm1=val1&amp;parm2=val2<\/p>\n<p>\u2026where DD is your data dictionary, MXXXXXs is your app number, and ACTION is the desired action as follows:<br \/>\nAdd \u2013 post i.e. \/mrcjava\/rest\/DD\/MXXXXXs\/post?key=val&amp;parm1=val1&amp;parm2=val2<br \/>\nUpdate \u2013 put i.e. \/mrcjava\/rest\/DD\/MXXXXXs\/put?key=val&amp;parm1=val1&amp;parm2=val2<br \/>\nDelete \u2013 delete i.e. \/mrcjava\/rest\/DD\/MXXXXXs\/delete?key=val<\/p>\n<p>If there were no errors, you will receive a JSON response similar to the following screenshot:<\/p>\n<p><img decoding=\"async\" src=\"\/legacy\/images\/webservice3.png\"><\/p>\n<p>Otherwise, the resulting error will be displayed:<\/p>\n<p><img decoding=\"async\" src=\"\/legacy\/images\/webservice4.png\"><\/p>\n<h3 id=\"promote\">Promoting<\/h3>\n<p>You can promote web service applications just like all other <a href=\"\/legacy\/utilities\/utilizing-the-promote-to-production-plugin\">applications<\/a>.  The only thing to note is that you will also need to promote the web.xml file the first time you promote a web service per each data dictionary.  Once this file has been promoted, Tomcat in production will need to be restarted in order to use the web services for that data dictionary.<\/p>\n<h3 id=\"notes\">Notes<\/h3>\n<p>All RESTful web services are stateless.  This means that every request is considered completely independent of requests before and after it.  Therefore, anything tied to previous requests (notably session and user information) cannot be used unless explicitly passed in your URL request.  Some common examples not available in web service applications include row level security, user name references, and session ID references.<\/p>\n<p><!-- End Content --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>m-Power Web Services &nbsp; Intro Set Up Getting Data CRUD Actions Promoting Notes Introduction A very common feature of modern web applications is an API that can be accessed from outside the framework for use in any architecture. m-Power has implemented such an API using RESTful web services, now available in supported templates. For more [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":3571,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-7831","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages\/7831","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/comments?post=7831"}],"version-history":[{"count":11,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages\/7831\/revisions"}],"predecessor-version":[{"id":9550,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages\/7831\/revisions\/9550"}],"up":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages\/3571"}],"wp:attachment":[{"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/media?parent=7831"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}