Title: Getting in a lather Ian Pearce Sybase Professional Services ipearcesybase'com
1Getting in a latherIan PearceSybase
Professional Servicesipearce_at_sybase.com
2Agenda
- What is it
- What does it do
- Why do I need to use it
- How can I use it
3What is it
- SOAP means
- Simple Object Access Protocol
- Rationale ?
- Invented as a language-independent method for
invoking business methods by wrapping them up as
XML documents
4What is it (cont.) ?
- Operates across process boundaries
- Uses HTTP as its transport protocol
- Quite a popular protocol !!!
- Allows us to do Remote Procedure Calls
- (Get someone else to do the work !)
5XML again ???
- All we hear about these days is XML !!!
- Good point !
- Is it any use to me ?
6Any old data, any old data, any, any, any old
data
Your/Data/0xCC
Your Enterprise (but Legacy format) Application
That you always have to make the changes to
because youre the last one left from the team
that originally wrote it
7XML cont.
- OK, good point
- Why do I need XML when I can just throw an
Integer or a Blob across the wire ? - Portability
- Byte-swapping
8Why do I need to use it ?
- OK, but I dont need that if Im talking to
EAServer from PowerBuilder, or Java ! - Agreed, but what if someone chose another
Application Server ? - What if someone has already written some code
that you can just invoke, with a minimum of
effort ?
9eGP Demo
10eGP Demo
11How does it do it ?
- At its most simple level SOAP works like this
Wrap request as XML and dispatch
Invoke Service
SOAP Container
Java Class
Decode
Collect results
Convert to XML and dispatch
12How does it do it ?
- The client wraps up a request and sends it to the
SOAP container - The SOAP container then
- unwraps the request
- calls the required service
- wraps up the result and dispatches it
- The client then unwraps it
13What we really do
- To make the call to the SOAP container, we need
to pass across an ENVELOPE - This contains a BODY, which itself contains
- the request
- the parameters
14And the SOAP container is ?
- The SOAP container can be anything
- But well use the Apache SOAP server from
http//xml.apache.org/dist/soap/ - Easy to install
- See http//my.sybase.com/detail?id1013352
15And the SOAP container does ?
- Once installed, the SOAP service deals with all
your requests - We can easily administer it by using the
SOAPAdmin web application - We can easily define our own services
16How can I use it ?
- Here comes the science part
17Using SOAP with PowerBuilder
- In order to use SOAP, you need to establish an
HTTP connection with the SOAP server - Luckily, we have that facility, using the GetUrl
function
18Using SOAP with PowerBuilder
- Or do we ????
- SOAP complains when you use the GET HTTP method
- it wants you to use the POST HTTP method
19GET/POST whats the difference ?
- Brief reminder ..
- The GET method is used when you want to pass
parameters over to an HTTP server - but these parameters are appended to the URL
- i.e. http//my.sybase.com/detail?id1013352
- The id parameter is appended
20GET/POST whats the difference ?
- Remember, SOAP wants you to POST parameters
- Why cant we use GET
- Because what would happen if were passing a HUGE
amount of information across to the SOAP Server - Overloaded anyone ?
21GET/POST whats the difference ?
- We therefore need to use the POST method
- Internet banking ever seen you UID/PWD in the
URL ? - Unlikely -)
- So we need to use the POST HTTP method
22PowerBuilder to the rescue !!
- Luckily, PowerBuilder has the posturl method
- Its been there since version 6.0 actually !
- The postURL method is a method in the inet system
object
Actually, it might have been an addition to
Version 5 whos counting -)
23The inet System object
- The postURL method works like this
- Where linet_base is an instance of the inet
object - lblob_data is a BLOB that contains the XML
- ls_headers is the HTTP header set
- lnv_id is an instance of the internetresult object
24Catching the response
- After dispatching the request to the server, we
just lie back and think of ltinsert_applicable_coun
trygt - When the server responds, we see the response as
a STRING argument to the internetdata event in
the internetresult object - Et voila !
25Building a generic PBSoapService
- If we want to call PB Components from a SOAP
client, we can do one of two things - 1. Wait for the PBWebServices addition to EAS
- 2. Roll our own !!!!
26Rolling our own
- Things to remember
- 1. We need a skeleton service on the SOAP
container to handle our requests - 2. We only ever want strings passed back
27Rolling our own
- Steps
- Create a PB component that retrieves a row based
on an argument - Generate Java stubs (and compile)
- Create a Java wrapper which will pass-through any
requests - Create a deployment descriptor for the wrapper
- Deploy it (using the sample that comes with the
SOAP service from Apache)
28More information
- For more information, please feel free to contact
me - ian.pearce_at_sybase.com
- 01628 597395
- 07977 257395
29Getting in a latherIan PearceSybase
Professional Servicesipearce_at_sybase.com