| 7. März 2007 | PHP & SAP | Martin Probst PHP talking to SAP Martin Probst.

10
| 7. März 2007 | PHP & SAP | Martin Probst PHP talking to SAP Martin Probst

Transcript of | 7. März 2007 | PHP & SAP | Martin Probst PHP talking to SAP Martin Probst.

Page 1: | 7. März 2007 | PHP & SAP | Martin Probst PHP talking to SAP Martin Probst.

| 7. März 2007 | PHP & SAP | Martin Probst

PHP talking to SAP

Martin Probst

Page 2: | 7. März 2007 | PHP & SAP | Martin Probst PHP talking to SAP Martin Probst.

PHP & SAP | Martin Probst | 7. März 2007

PHP / Outline

■ demo of leave request

■ desktop integration via Atom & iCalendar

■ consuming web services in PHP

■ feedback (technical, documentation, missing functionality)

Page 3: | 7. März 2007 | PHP & SAP | Martin Probst PHP talking to SAP Martin Probst.

PHP & SAP | Martin Probst | 7. März 2007

3

demo

Page 4: | 7. März 2007 | PHP & SAP | Martin Probst PHP talking to SAP Martin Probst.

PHP & SAP | Martin Probst | 7. März 2007

PHP / consuming web services /

iCalendar & Atom

■ Web interfaces are location independent, lightweight etc.

■ But users prefer rich clients sometimes

□ Better interface

□ Integrate with other tools

□ Aggregate data from many sources

■ Support open iCalendar and Atom formats

□ easy to produce and consume

□ wide range of applications

□ open standards (RFCs)

■ Implementation read only, but not necessarily (WebCAL, APP)

Page 5: | 7. März 2007 | PHP & SAP | Martin Probst PHP talking to SAP Martin Probst.

PHP & SAP | Martin Probst | 7. März 2007

PHP / consuming web services /

the basic code

■ No real type system

■ Create SOAP client, dynamic methods on it added

■ Everything done at run time, but cached

$wsdl = 'http://www.sap.com/.../ECC_EMPLEAVEREQBYIDQR.wsdl';$soapclient = new SoapClient($wsdl);$message = array (

'EmployeeLeaveRequestSelectionByID' => array ('EmployeeLeaveRequestID' => $ID

));$response = $soapclient->EmployeeLeaveRequestByIDQueryResponse_In($message);

Page 6: | 7. März 2007 | PHP & SAP | Martin Probst PHP talking to SAP Martin Probst.

PHP & SAP | Martin Probst | 7. März 2007

PHP / consuming web services /

dynamic types

■ PHP has a dynamic (or no?) type system

□ Classes are constructed from WSDL/Schema on the fly

□ Can supply user implemented classes

■ Use hash maps/arrays to construct messages

■ Consume result types directly, no declaration

■ This is all the code necessary to query services

■ minimal LOC, but no static type check

$leaverequest = $response->EmployeeLeaveRequest;echo $leaverequest->LifeCycleStatusCode, $leaverequest->StartDate;

Page 7: | 7. März 2007 | PHP & SAP | Martin Probst PHP talking to SAP Martin Probst.

PHP & SAP | Martin Probst | 7. März 2007

PHP / consuming web services /

problems

■ Automatic type conversion error proneis it a number, a string, a bird?

■ Unstable language

□ 5.1 → 5.2: _toString semantics change, Datetime class added

□ backwards incompatible changes, break code

■ Object oriented system strange at best

□ Field visibility not enforced

□ Types sometimes case insensitive

Page 8: | 7. März 2007 | PHP & SAP | Martin Probst PHP talking to SAP Martin Probst.

PHP & SAP | Martin Probst | 7. März 2007

PHP / consuming web services /

soap issues

■ SOAP API added in PHP5

■ Hash map syntax for messages⇒ no support for namespaces in messages

■ Serialization into XML overly liberal

□ fails to detect many bugs

□ easy to send non-WSDL-conforming messages

□ „Fehler bei der Konvertierung XML => ABAP (; FehlerId: ; ( ) )“

$message = array ('EmployeeLeaveRequestSelectionByID' => array (

'EmployeeLeaveRequestID' => $ID)

);

Page 9: | 7. März 2007 | PHP & SAP | Martin Probst PHP talking to SAP Martin Probst.

PHP & SAP | Martin Probst | 7. März 2007

PHP / consuming web services /

soap issues

■ Arrays weird - if it‘s only one element, it‘s not an array⇒ need special case code everywhere

■ Difficult to manage types in non typed system

□ „EmployeeLeaveRequest“ type different in services

□ PHP has no way to handle this

□ Create messages as hashmaps for each request

$elr = $res->EmployeeLeaveRequest;if (is_array($elr)) { $elr = array ($elr);}

Page 10: | 7. März 2007 | PHP & SAP | Martin Probst PHP talking to SAP Martin Probst.

PHP & SAP | Martin Probst | 7. März 2007

10

conclusion

■ PHP

□ small server footprint

□ low complexity (~2000 LOC, zipped ~60KB)

□ quick development cycle

□ bad programming language

□ rather go for Ruby / Python

■ Services

□ see other feedback

□ last modified for service would be nice