{"id":177,"date":"2016-02-26T14:17:19","date_gmt":"2016-02-26T19:17:19","guid":{"rendered":"http:\/\/salzlechner.com\/dev\/?p=177"},"modified":"2016-03-11T07:00:07","modified_gmt":"2016-03-11T12:00:07","slug":"interfacing-dataflex-soap-webservice-client","status":"publish","type":"post","link":"http:\/\/salzlechner.com\/dev\/2016\/02\/26\/interfacing-dataflex-soap-webservice-client\/","title":{"rendered":"Interfacing DataFlex &#8211; SOAP Webservice client"},"content":{"rendered":"<p>DataFlex allows the developer to consumer SOAP webservices. This tutorial will show how easy it is to do just that.<\/p>\n<p>In order to consume a web service of course we need one first. For this example we chose a publicly available service that returns the weather for a given city.<\/p>\n<p>A soap web service has an address, essentially a URL on the web or intranet that points to the web service<\/p>\n<p>in our example the address for the web service is<\/p>\n<p><em>http:\/\/www.webservicex.com\/globalweather.asmx<\/em><\/p>\n<p>a soap web service also has whats called a WSDL (Web Service Definition Language) which is an XML document that describes the web service interface.<\/p>\n<p>Most web services allow you to query the WSDL by appending ?WSDL to the URL for example<\/p>\n<p><em>http:\/\/www.webservicex.com\/globalweather.asmx?WSDL<\/em><\/p>\n<p>Now we can start with a new workspace in the DataFlex Studio.\u00a0After setting up a new workspace we need to also create a new project. Make it a Windows project, give it a name and save.<\/p>\n<p>In order to call a web service we need to create a client web service class in the Studio<\/p>\n<p>select File-&gt;New-&gt;Class<\/p>\n<p><a href=\"http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/newclass1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-207\" src=\"http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/newclass1.png\" alt=\"newclass\" width=\"731\" height=\"371\" srcset=\"http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/newclass1.png 731w, http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/newclass1-300x152.png 300w\" sizes=\"(max-width: 731px) 100vw, 731px\" \/><\/a><\/p>\n<p>select Client Web Service Class and click Ok<\/p>\n<p><a href=\"http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/wsclass.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-208\" src=\"http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/wsclass.png\" alt=\"wsclass\" width=\"850\" height=\"694\" srcset=\"http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/wsclass.png 850w, http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/wsclass-300x245.png 300w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><\/a><\/p>\n<p>enter the URL including the WSDL and click Parse. If the URL is correct and the web service is active the Studio will generate a class for the web service<\/p>\n<p>Also in case you run into problems with a web service that used to be working before you may want to come back and regenerate the class to see if the web service has changed.<\/p>\n<p>Whenever i regenerate web service classes i keep the old copy and compare them using Beyond Compare to see what has changed so i can determine if the changes will\u00a0have any effect on my code<\/p>\n<p>Once you click Generate Class you get more options and then\u00a0the class package is generated<\/p>\n<p>in our example you can see a function called wsGetWeather that accepts a city and country name and then returns the weather as a string<\/p>\n<p>In order to test our web service we create a simple view<\/p>\n<p>we need to use the package created earlier<\/p>\n<p><a href=\"http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/simpleview.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-209\" src=\"http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/simpleview.png\" alt=\"simpleview\" width=\"374\" height=\"239\" srcset=\"http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/simpleview.png 374w, http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/simpleview-300x192.png 300w\" sizes=\"(max-width: 374px) 100vw, 374px\" \/><\/a><\/p>\n<p>Then we add a form for the city and country and a button to call the service and a TextEdit control to show the result<\/p>\n<p>in addition we need to create the web service object. We can either drag and drop the web service object from the web service palette or simply create it in code<\/p>\n<p><a href=\"http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/wsobject.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-210\" src=\"http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/wsobject.png\" alt=\"wsobject\" width=\"533\" height=\"259\" srcset=\"http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/wsobject.png 533w, http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/wsobject-300x146.png 300w\" sizes=\"(max-width: 533px) 100vw, 533px\" \/><\/a><\/p>\n<p>We add a method to call the service called <em>RequestGetWeatherInfo<\/em><\/p>\n<p>from the button we call the method<\/p>\n<p><a href=\"http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/buttoncode.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-211\" src=\"http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/buttoncode.png\" alt=\"buttoncode\" width=\"634\" height=\"387\" srcset=\"http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/buttoncode.png 634w, http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/buttoncode-300x183.png 300w\" sizes=\"(max-width: 634px) 100vw, 634px\" \/><\/a><\/p>\n<p>First we get the value of the city and country entered and then call the wsGetWeather function. After calling the web service we show the data returned in the textedit control<\/p>\n<p><a href=\"http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/return.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-212\" src=\"http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/return.png\" alt=\"return\" width=\"543\" height=\"417\" srcset=\"http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/return.png 543w, http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/return-300x230.png 300w\" sizes=\"(max-width: 543px) 100vw, 543px\" \/><\/a><\/p>\n<p>You can see the service returns XML data containing the location information, time and weather information<\/p>\n<p>This shows how easy it is to call simple web services. It allows us to interface with a large variety of other systems out there<\/p>\n<p>In addition DataFlex Webapp also allows us to create server side web services. This can be used for example to communicate between multiple offices.<\/p>\n<p>We have used a large number of web services in our applications from banking, UPS, Fedex and USPS interfaces, and more and also our own custom web services with the server side either written in .NET or in DataFlex WebApp<\/p>\n<p>We have also used DataFlex WebAPP server side services and then consumed them from native iOS applications and native Windows Universal apps allowing them all to talk to the same DataFlex middle tier.<\/p>\n\n\t\t<div class='author-shortcodes'>\n\t\t\t<div class='author-inner'>\n\t\t\t\t<div class='author-image'>\n\t\t\t<img src='http:\/\/salzlechner.com\/dev\/wp-content\/uploads\/sites\/2\/2016\/02\/mike5crop-566174_60x60.jpg' alt='' \/>\n\t\t\t<div class='author-overlay'><\/div>\n\t\t<\/div> \n\t\t<div class='author-info'>\n\t\t\tMichael Salzlechner is the CEO of StarZen Technologies, Inc.<\/p>\n<p>He was part of the Windows Team at Data Access Worldwide that created the DataFlex for Windows Product before joining <a href=\"http:\/\/starzen.com\">StarZen Technologies<\/a>. StarZen Technologies provides consulting services as well as custom Application development and third party products specifically for DataFlex developers<\/p>\n\t\t<\/div>\n\t\t\t<\/div>\n\t\t<\/div>\n","protected":false},"excerpt":{"rendered":"<p>A tutorial to show how to call SOAP web services from a DataFlex application<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","ngg_post_thumbnail":0,"footnotes":""},"categories":[6,27,4],"tags":[],"class_list":["post-177","post","type-post","status-publish","format-standard","hentry","category-dataflex","category-dataflex-webapp","category-windows"],"_links":{"self":[{"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/posts\/177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/comments?post=177"}],"version-history":[{"count":6,"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/posts\/177\/revisions"}],"predecessor-version":[{"id":275,"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/posts\/177\/revisions\/275"}],"wp:attachment":[{"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/media?parent=177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/categories?post=177"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/tags?post=177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}