PWB523 Pocket PB, PocketSOAP & Web Services - PowerPoint PPT Presentation

aggie
pwb523 pocket pb pocketsoap web services l.
Skip this Video
Loading SlideShow in 5 Seconds..
PWB523 Pocket PB, PocketSOAP & Web Services PowerPoint Presentation
Download Presentation
PWB523 Pocket PB, PocketSOAP & Web Services

play fullscreen
1 / 57
Download Presentation
PWB523 Pocket PB, PocketSOAP & Web Services
854 Views
Download Presentation

PWB523 Pocket PB, PocketSOAP & Web Services

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. PWB523 Pocket PB, PocketSOAP & Web Services Ian ThainTechnical Evangelistian.thain@sybase.comAugust 2003

  2. Introduction – Ian Thain • Technical Evangelist / Software Engineer in the Infrastructure Platform Group of Sybase, Inc • Involved with the design, production and testing of Enterprise class e-Business Solutions, that have been implemented using Sybase’s e-Business Platform for Sybase customers around the globe. • In addition, continually working with Sybase’s key partners and clients to enhance the capabilities of the e-business solutions that Sybase can offer to its customers. • EAServer, EP, PowerBuilder, Pocket PowerBuilder, PowerJ & OEM products

  3. Agenda • PPB Overview • Problem to address • Technologies 101 • What is Sybase doing ? • Solution • Demonstration • Futures • Q &A

  4. Pocket PowerBuilder Overview "Don't think big…Think Small!!" • PowerBuilder is now coming to aid corporate development of Pocket PC applications, brining all the benefits I have mentioned above - RAD 4 GL and even the DataWindow technology. • So we really can now say, DataWindows EVERYWHERE!!!!

  5. How does it differ from PowerBuilder? Unsupported Functions • OLE • DDE • CORBA • Profiling • Printing • Rich Text and a few more Unsupported Events • help() • closequery() • anything to do with remote (example remoteexec()), hotlinkalarm() and toolbarmoved().

  6. How does it differ from PowerBuilder? Unsupported Features • MDI applications, • EAServer connections, • Web and JSP targets, • and Automation server. NO PFC !

  7. Problem to address Components • So you may have diverse components in your enterprise and need to access them • Some of these components may access other data and or perform complex processing Application Client • Pocket PowerBuilder v1.0 Unlike PowerBuilder v9.0, Pocket PowerBuilder v1.0 does not have Initial Context Object or EJB Client

  8. Solution Components • So you may have diverse components in your enterprise and need to access them • Some of these components may access other data and or perform complex processing Application Client • Pocket PowerBuilder v1.0 Web Services & SOAP

  9. Technologies 101 • What are Web services ? • Made up of standards that describe business processes • Self describing • Searchable in a registry of services • Sync or Async • Loosely coupled and cross platform • Reusable

  10. Technologies 101 • Web services benefits • RAD • Neutral • Architecture & language • Leverage current investment • Accessed through many different client types

  11. Registry Provider Service Technologies 101 High Level Architecture • Provider creates and publishes service • A client searches a registry for that service • The client is able to connect and call the service Client

  12. Technologies 101 • Protocols involved – Web Services Stack WSFL UDDI WSDL SOAP XML TCP/IP, HTTP etc Emerging Layers Core Layers

  13. Technologies 101 • TCP/IP, HTTP • Common Internet Transport Protocols • Web services not tied to any one protocol

  14. Technologies 101 • XML • Extensible Markup Language • Widely accepted format to exchange data & semantics • Core building block for every layer in the Web services stack

  15. Technologies 101 • SOAP • Simple Object Access Protocol, • Represents a • light-weight, • wire-level protocol • for messaging & RPC communications • Based on XML

  16. Technologies 101 • SOAP Message • Envelope comprised of • Header • Body • Body comprised of • Requests • Responses • Status • Attachments Envelope Header Body Requests Response Status Attachments

  17. Technologies 101 • WSDL • Web Services Definition Language • Based on XML • Defines • Functionality of a Web service • Supported protocols • Message formats • Location of Web service

  18. Technologies 101 • WSDL Document • Comprised of • Data types • Message/method • Port • Binding • Service Document Data Types Message Interface Port Binding Implementation Service

  19. Technologies 101 • UDDI • Universal Description, Discovery and Integration • SOAP-based Web service • Allows • Providers to register services • Clients to lookup services • Uses WSDL to describe services

  20. Technologies 101 Client UDDI Provider Lookup Register Service

  21. What is Sybase doing ? • EAServer 4.x includes the Web Services Toolkit • WST is a utility that allows users to take their existing business components and make them available as a Web services. • The Web Services Toolkit provides support for the latest standards: SOAP, WSDL and UDDI. • FYI • EAServer 5.0 – AXIS Implementation • UDDI Server

  22. Web Services Toolkit • The Toolkit provides a full SOAP engine, supporting SOAP request/response. • In addition, the toolkit offers a utility that can be run against a component in EAServer, to determine its “soapability”. • The utility scans the component, chooses any methods that meet the soap criteria (all in/out parameters are supported by the SOAP standard) • Only Synchronous Components – i.e. not MDB’s • WST Generates the WSDL document that describes that method. - Bottom up approach • Once the WSDL is generated, it can be posted to a UDDI repository, making the Web service publicly available.

  23. Web Services Toolkit EAS Components Client Application WEB WEB Client Proxy SOAP Component WSDL Listener X WS UDDI HOST Manager • Gen WSDL, Proxy WS • Register User - Defined Types GUI

  24. Solution Components • So you may have diverse components in your enterprise and need to access them • Some of these components may access other data and or perform complex processing Application Client • Pocket PowerBuilder v1.0 Web Services & SOAP PocketSOAP

  25. Mobile & Wireless • Pocket PowerBuilder is the ideal tool to produce application that can mobilize your field workers. • Capture data electronically at source, minimizing data capture & improve the quality of your data. • Data can then be synchronized back to Enterprise systems with minimal impact, improving turn around time and increasing the effectiveness of the field workers. • With newer PocketPC devices this synchronization can be via dialup or wireless connection. • HP's iPAQ 5450, which has integrated Bluetooth and WiFi 802.11b • Toshiba's e740, which has integrated WiFi 802.11b. • Both can be used within the range of a Wireless Access Point and the iPAQ 5450 can use Bluetooth to connect to cell phones for dialup connection or via GPRS.

  26. PocketSOAP • Open Source SOAP client Component Object Model (COM) component. • Distributed under the Mozila Public License (MPL). • Developed by Simon Fell • Originally targeted for the PocketPC • now developed for PocketPC and Windows 95, 98, Me, NT4.0 and 2000. • smaller footprint, the total footprint including the support library (expat xml parser and zlib) weights in at 680k. • PocketSOAP also uses a sax style parser for perf & memory load reasons, whilst other toolkits still use an intermediate DOM representation.

  27. PocketSOAP • Includes the following features SOAP Section 5 encoding support, support for document/literal style SOAP services (such as ASP.NET), attachments support via both DIME and SOAP with Attachments, Support for SOAP, HTTP 1.1 support including persistent connections, SSL, proxies, authentication, proxy authentication, redirects, cookies and compression.

  28. PocketSOAP • Can make remote procedure calls to SOAP servers implemented with • 4s4c • ROPE • Apache SOAP • SOAP::Lite • DM's SOAP/Perl • XMethods SOAP Server • The package includes a Hypertext Transfer Protocol (HTTP) client for making HTTP based SOAP requests, but other transports can be added. • There are more features & information that can be viewed at http://www.pocketsoap.com

  29. Pocket PowerBuilder v1.0 & PocketSOAP • Pocket PowerBuilder & PocketSOAP interact through an Interface / external DLL wrapper, which provides a simple access to the PocketSOAP package, via its COM Interface. • Pocket PowerBuilder does not have a COM object, aka OleObject at the moment! • This wrapper will still exist and work when the OleObject does appear in the next version of Pocket PowerBuilder, but the recommended way to use PocketSOAP will be via the OleObject. • So eventually code will have to be changed, as we will be programming directly to the PocketSOAP interface rather than the wrapper. • Until then, lets enjoy using the wrapper and find out what we need to do.

  30. Pocket PowerBuilder v1.0 & PocketSOAP • Model for the API • First the service object is created and that returns the access handle. • Then you can set the various attributes in whatever order you desire. • Internally, the attributes are simply stored for later use. Then you make the SOAP call. • This uses the previously set attributes. • Finally, you destroy the service object, which cuts away all the previously created COM objects.

  31. Pocket PowerBuilder v1.0 & PocketSOAP • All this is built on top of the PocketSOAP system. • So to run with PocketSOAP, retrieve the installs from http://www.pocketsoap.com • Install them on both the desktop and Pocket PC device. • These installs contain the API documentation, which will be useful in the future, when we will code directly to the PocketSOAP COM object, via the OleObject

  32. Pocket PowerBuilder v1.0 & PocketSOAP • The PocketSOAP wrapper can be found on the CodeXchange website, http://pocketpb.codexchange.sybase.com with other examples etc

  33. Pocket PowerBuilder v1.0 & PocketSOAP • The wrapper functions can be made accessible from Pocket PowerBuilder as a global external function. • In the "Application object“ • select "(Declare)" • and the "Global External Functions".

  34. Pocket PowerBuilder v1.0 & PocketSOAP // External Functions all in library "PKSoapif.DLL" FUNCTION integer PocketSoap_Create( boolean fInProc, REF long lHandle ) library "PKSoapif.dll" FUNCTION integer PocketSoap_Destroy( long lHandle ) library "PKSoapif.dll" FUNCTION integer PocketSoap_SetProxy( long lHandle, readonly string pszProxyServer, long iProxyPort ) library "PKSoapif.dll" FUNCTION integer PocketSoap_SetProxyAuthentication( long lHandle, readonly string pszUsername, readonly string pszPassword ) library "PKSoapif.dll" FUNCTION integer PocketSoap_SetAuthentication( long lHandle, readonly string pszUsername, readonly string pszPassword ) library "PKSoapif.dll" FUNCTION integer PocketSoap_SetMaxRedirects( long lHandle, long cRedirects ) library "PKSoapif.dll" FUNCTION integer PocketSoap_SetTimeout( long lHandle, long cSeconds ) library "PKSoapif.dll" FUNCTION integer PocketSoap_SetEndPoint( long lHandle, readonly string pszEndPointURL ) library "PKSoapif.dll" FUNCTION integer PocketSoap_GetHTTPStatus( long lHandle, REF long lStatus ) library "PKSoapif.dll" // Actually make the SOAP call FUNCTION integer PocketSoap_SimpleCall( long lHandle, & readonly string pszNameSpaceURI, & readonly string pszMethodName, & readonly string pszArgName, & readonly string pszArgValue ) library "PKSoapif.dll" FUNCTION integer PocketSoap_Call( long lHandle, & readonly string pszNameSpaceURI, & readonly string pszMethodName, & readonly string pszArgString ) library "PKSoapif.dll" // All the get result calls have a caller (PB) allocated buffer. FUNCTION integer PocketSoap_GetResult( long lHandle, & long cRetBufLen, REF string pszReturnValue ) library "PKSoapif.dll" FUNCTION integer PocketSoap_GetResults( long lHandle, & long cRetBufLen, REF string pszReturnValue ) library "PKSoapif.dll"

  35. Pocket PowerBuilder v1.0 & PocketSOAP • PocketSoap_Create • Create a PocketSoap interface object and lay the groundwork for future use. • This must be matched with the "PocketSoap_Destroy". • PocketSoap_Destroy • Close this connection and destroy all internal references. • PocketSoap_GetHTTPStatus • Ask the transport layer what the last HTTP status was. Will return a value like 200 or 404 or ... • PocketSoap_SetProxy • This enables the use of a proxy server for outgoing HTTP(S) connections.

  36. Pocket PowerBuilder v1.0 & PocketSOAP • PocketSoap_SetProxyAuthentication • Sets the username/password for BASIC authentication to the Proxy server. • PocketSoap_SetAuthentication • Sets the username/password for BASIC authentication to the EndPoint server. • PocketSoap_SetMaxRedirects • Sets the maximum number of redirects the HTTP transport will follow for a single request. • PocketSoap_SetTimeout • Sets the timeout (in seconds) for a single request.

  37. Pocket PowerBuilder v1.0 & PocketSOAP • PocketSoap_SetEncodingStyle • Sets the "Encoding Style" used in the SOAP message. • PocketSoap_SetParameterNameSpace • Sets the NameSpace for the parameters (arguments) used in the SOAP message. • PocketSoap_SetEndPoint • The endpoint URL, e.g. http://services.xmethods.net/soap • PocketSoap_SimpleCall • Execute a synchronous call to the previously specified EndPoint URL. • This version takes a single parameter and returns a single value.

  38. Pocket PowerBuilder v1.0 & PocketSOAP • PocketSoap_Call • Execute a synchronous call to the previously specified EndPoint URL. This general call is for an argument list with arbitrary number of name/value pairs. • PocketSoap_GetResult • Retrieve the single result (or the first if many) from the previous call. • PocketSoap_GetResults • Retrieve the (possibly multiple) results from the previous call into a DataWindow friendly string. • PocketSoap_SetSoapAction • Sets the SoapAction used in the SOAP message.

  39. Pocket PowerBuilder v1.0 & PocketSOAP • The 3 important things we need to set are the • EndPoint, • Namespace • Method. • The EndPoint indicates a specific location for accessing a service using a specific protocol and data format. • The Namespace indicates the specific Web Service • The method is that method which we want to call within that Web Service. • For example we can use the method PocketSoap_SimpleCall which executes a synchronous call to the EndPoint URL with a single argument. • This argument is a name/value pair and is optional.

  40. Pocket PowerBuilder v1.0 & PocketSOAP Method string sMethod = "getPFShareList" string sEndPoint = "http://localhost:10000/WEB SERVICES/SOAP" string sNameSpace = "PFShareListAll/PFShareList" String sSoapAction = ="PFShareListAll/PFShareList.getPFShareList return,java.lang.String[],return" int cRetBufLen = 128 string sArgs string sResult long lHandle int iRet // create & set attributes on for the soap call iRet = PocketSoap_Create( true, REF lHandle ) wf_message( iRet, "PocketSoap_Create") iRet = PocketSoap_SetEndPoint( lHandle, sEndPoint ) wf_message( iRet, "PocketSoap_SetEndPoint") iRet = PocketSoap_SetSoapAction( lHandle, sSoapAction ) wf_message( iRet, "PocketSoap_SetSoapAction") // preallocate the result string sResult = Space( cRetBufLen ) // make a "simple call" iRet = PocketSoap_SimpleCall( lHandle, sNameSpace, sMethod, "", "" ) wf_message( iRet, "PocketSoap_SimpleCall”) // get the Result iRet = PocketSoap_GetResult( lHandle, cRetBufLen, REF sResult ) wf_message( iRet, "PocketSoap_GetResult") // clean up iRet = PocketSoap_Destroy( lHandle ) wf_message( iRet, "PocketSoap_Destroy") //Separate window function wf_message (integer ai_ret, string as_method) If ai_ret <> 0 Then MessageBox("Return code", String(ai_ret) + " " + as_method) End if Endpoint NameSpace #1 #2 #3 #4 #5 #6

  41. Pocket PowerBuilder v1.0 & PocketSOAP • For a more complex call there is another method called PocketSoap_Call, which takes arguments as name/value pairs, but represented as a single DataWindow friendly string.   Name1 ~t value1 ~t data-type1 ~r~n Name2 ~t value2 ~t data-type2 ~r~n Name3 ~t value1 ~t data-type1 ~r~n Etc • PocketSOAP will take care of generating the SOAP message & parsing the response.

  42. Pocket PowerBuilder v1.0 & PocketSOAP • The SOAP call and the response from the server can be viewed by using the SOAP Util tool from Apache (http://www.apache.org) This is started by using the command line java org.apache.soap.util.net.TcpTunnelGui 10000 ithain-home 8080 • This allows the tool to intercept all requests that are made to localhost:10000, display them then reroute them to ithain-home:8080. • Like wise the tool intercepts the response from ithain-home:8080, display them and reroute them back to the caller.

  43. Pocket PowerBuilder v1.0 & PocketSOAP

  44. Pocket PowerBuilder v1.0 & PocketSOAP • For EAServer 4.x we need to set the SoapAction attribute. • This is due to that fact that in EAServer 4.x we are using the SoapAction attribute, within our proprietary implementation of Web Services, though this is compatible with other implementations such as Apache. • That being said other implementations also require SoapAction.

  45. Demonstrations • Pocket PowerBuilder calling a Web Service on EAServer via PocketSOAP. Web Service is an EJB • Pocket PowerBuilder calling a Web Service from XMethods via PocketSOAP

  46. Demonstration #1

  47. Demonstration #1 public String[] getPFShareList() throws javax.ejb.EJBException { String[] ShareList …. try { javax.naming.Context ctx = new javax.naming.InitialContext(); javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup("java:comp/env/jdbc/Portfolio"); con = ds.getConnection(); stmt = con.createStatement(); rs = stmt.executeQuery("SELECT * FROM DBA.SYMBOL SYMBOL ORDER BY symbol_cd"); while (rs.next()) { ShareList[row] = rs.getString("symbol_cd") + ","; ShareList[row] += rs.getString("symbol_ln") + ","; ShareList[row] += rs.getString("symbol_current_price"); row += 1; } } catch (Exception e) { System.out.println("getPFShareList Exception" + e.toString()); } finally { try { if ( rs != null ) rs.close(); if ( stmt != null ) stmt.close(); if ( con != null ) con.close(); } catch (SQLException e) { System.out.println("getPFShareList SQLException" + e.toString()); } } return ShareList; }

  48. Demonstration #1

  49. Demonstration #1 EAS Components PPB Application WEB WEB PocketSOAP SOAP Component WSDL Listener X WS UDDI HOST Manager • Gen WSDL, Proxy WS • Register User - Defined Types GUI

  50. Demonstration #2 • Against a Web Service on XMethods • Shows use of more complex data type string sMethod = "BabelFish" string sEndPoint = "http://services.xmethods.net:80/perl/soaplite.cgi" string sNameSpace = "urn:xmethodsBabelFish" string sResult int cRetBufLen = 2048 long lHandle int iRet string sArgs //en_fr, en_es, en_de, en_it sArgs = "translationmode~t"+ ddlb_language.text sArgs += "~r~nsourcedata~t" + sle_xlat_src.text iRet = PocketSoap_Create( true, REF lHandle ) iRet = PocketSoap_SetEndPoint( lHandle, sEndPoint ) iRet = PocketSoap_Call( lHandle, sNameSpace, sMethod, sArgs ) sResult = Space( cRetBufLen ) iRet = PocketSoap_GetResult( lHandle, cRetBufLen, REF sResult) mle_xlat.text = mle_xlat.text + "~r~n---------" + "Result: " + sResult iRet = PocketSoap_Destroy( lHandle )