11.07.2015 Views

in PowerBuilder - sys-con.com's archive of magazines - SYS-CON ...

in PowerBuilder - sys-con.com's archive of magazines - SYS-CON ...

in PowerBuilder - sys-con.com's archive of magazines - SYS-CON ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

SOA != Web ServicesSOA (Service-Oriented Architecture):An architectural <strong>con</strong>cept <strong>in</strong>volv<strong>in</strong>g thecreation <strong>of</strong> loosely coupled servicesaccessible over a network <strong>in</strong> a standardizedfashion. Normally the <strong>con</strong>sumption<strong>of</strong> a service is not restricted to a specificlanguage or platform.Web Service: A service made accessiblevia the Internet or an <strong>in</strong>tranet. It typicallyuses HTTP as the transport protocolwith requests to and responses from theservice implemented us<strong>in</strong>g SOAP messagesor a REST approach.ComparisonA service-oriented architecture may beimplemented us<strong>in</strong>g Web services as themethod <strong>of</strong> expos<strong>in</strong>g and access<strong>in</strong>g theservices, but this is not the only way toachieve SOA. Other possible implementationscould <strong>in</strong>volve messag<strong>in</strong>g <strong>sys</strong>tems(JMS: Java Messag<strong>in</strong>g Service), CORBAcommunicat<strong>in</strong>g over IIOP, or any othermessag<strong>in</strong>g protocol (STOMP: Stream<strong>in</strong>gText Orientated Messag<strong>in</strong>g Protocol,XMPP: Extensible Messag<strong>in</strong>g and PresenceProtocol).6. Click Next and select a library andname for the proxy object. Click Nextand <strong>con</strong>firm the proxy sett<strong>in</strong>gs andclick F<strong>in</strong>ish (see Figure 3).Now you should have a proxy objectpresent <strong>in</strong> your library that can bedeployed to create all <strong>of</strong> the objectsneeded to access the Amazon Web service.To use the new objects, you willneed to create a SoapClient <strong>con</strong>nection(to use the SoapClient object you willneed to add either pbsoapclient90.pbd(<strong>PowerBuilder</strong> 9) or pbsoapclient100.pbd(<strong>PowerBuilder</strong> 10) to your library list).If you exam<strong>in</strong>e the awseCommerce-ServicePort object, you will see it has anItemSearch function that takes variousarguments. We can call this function tosend a request to our Web service andcapture the response.This is very similar to how you wouldmake a call to a remote object us<strong>in</strong>gCORBA from with<strong>in</strong> <strong>PowerBuilder</strong> (seeList<strong>in</strong>g 4).ComparisonWe have covered three techniques formak<strong>in</strong>g requests aga<strong>in</strong>st a Web service.There are various pros and <strong>con</strong>s for themethods demonstrated. Table 1 summarizesthe differences among theseoptions.ConclusionThe three methods presented heredemonstrate the options available to the<strong>PowerBuilder</strong> developer with regard toWeb services <strong>in</strong> the new SOA paradigm(for more <strong>in</strong>formation on SOA and Webservices, see the sidebar SOA != Web Services).Those <strong>of</strong> you on older versionscan use the GetURL/PostURL functionsand the XmlHttp object, while the developerson supported versions can takeadvantage <strong>of</strong> the new Web Service Proxyobject. The Web Service Proxy does afantastic job <strong>of</strong> abstract<strong>in</strong>g away Webservices to the level <strong>of</strong> distributedmethod calls. This alone is worth theprice <strong>of</strong> an upgrade if you are go<strong>in</strong>g to bework<strong>in</strong>g frequently with Web services.Remember, sh<strong>in</strong>y new <strong>PowerBuilder</strong> CDsare the gift that keeps on giv<strong>in</strong>g.Resources• SOA: http://en.wikipedia.org/wiki/Service-oriented_architecture• Web Service: http://en.wikipedia.org/wiki/Web_service• REST: http://en.wikipedia.org/wiki/REST• SOAP: http://en.wikipedia.org/wiki/SOAP• Amazon Web Services:http://aws.amazon.com• Micros<strong>of</strong>t MSXML Download:http://www.micros<strong>of</strong>t.com/downloads/details.aspx?familyid=3144b72b-b4f2-46da-b4b6-c5d7485f2b42&displaylang=en#filelist ▼dhp@acm.orgList<strong>in</strong>g 1nvo_<strong>in</strong>ternet_result lnvo_<strong>in</strong>ternet_result<strong>in</strong>et l<strong>in</strong>et_base<strong>in</strong>teger li_retvalStr<strong>in</strong>g ls_url, ls_args//Initialize InternetResult object and//Get Internet service referencelnvo_<strong>in</strong>ternet_result = create nvo_<strong>in</strong>ternet_resultli_retval = GetContextService(“Internet”, l<strong>in</strong>et_base)//Web Service URL, note the question mark <strong>in</strong>cluded//on the end. Don’t forget thisls_url=”http://webservices.amazon.com/onca/xml?”//Argument list <strong>of</strong> name/value pairs <strong>in</strong> the format//=&ls_args=”Service=AWSECommerceService&” + &“AWSAccessKeyId=[YourAccessKey]&” + &“Operation=ItemSearch&” + &“SearchIndex=Music&” + &“Keywords=Butch Walker”//Concatenate URL with Arguments and call GetURL method.//The response from the web service will be sent to the//InternetData method <strong>in</strong> the lnvo_<strong>in</strong>ternet_result object//and execute the code there (popp<strong>in</strong>g up a MessageBox)li_retval = l<strong>in</strong>et_base.GetURL(ls_url + ls_args, &lnvo_<strong>in</strong>ternet_result)//Clean updestroy l<strong>in</strong>et_basedestroy lnvo_<strong>in</strong>ternet_resultList<strong>in</strong>g 2nvo_<strong>in</strong>ternet_result lnvo_<strong>in</strong>ternet_result<strong>in</strong>et l<strong>in</strong>et_base<strong>in</strong>teger li_retvallong ll_<strong>con</strong>tent_length, long ll_portStr<strong>in</strong>g ls_url, ls_args, ls_headersblob lblb_args//Initialize InternetResult object and//Get Internet service referencelnvo_<strong>in</strong>ternet_result = create nvo_<strong>in</strong>ternet_resultli_retval = GetContextService(“Internet”, l<strong>in</strong>et_base)//Web Service URL, note the question mark <strong>in</strong>cluded//on the end. Don’t forget thisls_url=”http://webservices.amazon.com/onca/xml?”//Server Port Number, typically 80 or 0 for default//Note putt<strong>in</strong>g 443 here does not give you HTTPSll_port = 80//Argument list <strong>of</strong> name/value pairs <strong>in</strong> the format//=&ls_args=”Service=AWSECommerceService&” + &“AWSAccessKeyId=[YourAccessKey]&” + &“Operation=ItemSearch&” + &“SearchIndex=Music&” + &“Keywords=Butch Walker”//For PostURL we will <strong>con</strong>vert our argument list//from a str<strong>in</strong>g to a blob and get the length <strong>of</strong>//our result<strong>in</strong>g bloblblb_args = blob(ls_args)ll_<strong>con</strong>tent_length = Len(lblb_args)//For PostURL we also have to set two HTML headers//Content-Length and Content-Type separated by two//newl<strong>in</strong>e charactersls_headers = “Content-Length: “ + &Str<strong>in</strong>g(ll_<strong>con</strong>tent_length) + “~n~n” + &“Content-Type: “ + &“application/x-www-form-urlencoded”32 PBDJ volume12 issue11pbdj.<strong>sys</strong>-<strong>con</strong>.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!