You are on page 1of 26

|  




   

½   


|   
|   

    

    ’  


  
 

R 
   


G i
   | 
  
G ½ 



  |  
G ½
     
G |  
  
G !! 
 " !½   
G ½ 
   
G ½ 

—  x
½  #   $
G    "


"
   



 
% &

  
'½ ($)

   '*
  | ½ ((()
      
  
+          
 ! ,"
 "    
  
- 

   . 
 

G ½ 
      
 
    
  
""(

—  Ñ
|   

     '| )
Given some business logic, how do you make that as useful and reusable as possible?

G |   

     '| )  
|   !
 
 "
 


  
|  / 


|  | 

i
0
&  
 

üü    
    
     
   

 



   !"#$ 


 
% &
'((&
 

   !"#% )$%   
*

|
G |    1  '| ) ½

  
!  
  
 /! 
 
| 
  |  | 
 ! 

—  å
  |   |  $
G & # 2  
!
 
3

G i ! ,   "  


*,  
"4

#
 5   "
 
 
 

   
G i ! ,  "

 
!
"  
! 

 5   "
 
 


      
& "  
   2  3  

'&
 
!
6

"
&
1  
  
)

Accounts LogService
Service
(REST)

  
 Accounts x  



   Service


Accounts Directory
Service Service
(SOAP) (LDAP)

—  ]
7 | 8| *0*,


*09 9// ( (


/8
—9 9// ( ((/ / 
½ 9 9//((/ "/ 
J
| — 
9 !23
7½ 
| | 
o?php
G & # "1  
include 'SCA/SCA.php';

/**
G 4
 # | 
  * Service for sending emails
'   ) *
* @service
G +   
 "  * @binding.ws


  
 Ô  */
   
 class EmailService {
«


  /**
G —+|7  " * Send a simple text email
*
* @param string $to The "to" email address
* @param string $from The "from" email address
G i   
 1
: * @param string $subject The subject of the email
;    | 8|  * @param string $message The email message
*0 ,

  * @return boolean
*/
7
  ! 
  public function send($to, $from, $subject, $message) {
<  
*|   «
}
,     }

?>

—  ¦
 
 |  ! 
|

=  >=8|7?@ @A6
=! >=8|7?@!@A6
=1  >=8|7?@1  @A6
=  >=8|7?@  @A6


 @| /| ( @6

= 8  >| 99 |  '@*|  (@)6


=  >= 8  B
'= =!=1  =  )6

—  š
|  *C
G ½ 
|  


G *,   ½  
G 
  ½| 0
G 
  


EmailClient.php

79
C9

|1  9
Email Email
—  9
(SOAP) (SOAP)
Email

EmailService.php

email_form.html

—  È
No network version email_form.html


|  C  


/**
* Service for sending emails (supports shortnames)
* @service
*/
class ContactEmailService {

/**
* @reference
* @binding.ws ./EmailService.wsdl
*/
public $email_service;

/** « */
public function send($to, $from, $subject, $message) {
«
// a proxy to the service is µinjected¶ so we
// can just use it«
$this->email_service->
send($to, $from, $subject, $message);
...
}
}

—  3
 |  ½  |  % ! 
 

G ½ 
|  


G *,   0 
G    ! 
 * 
G 
  



EmailClient.php

79
C9

|1  9 Contact Email Email


—  9 Email
Email (SOAP) (SOAP)

ContactEmailService.php EmailService.php

email_form.html

—  33


    

G ;    , 
    :

G |  |    1    


  
   
G |  .   
!  
   

"D—0 
C  9

    

—  3x
oschema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.org/contacts">

  
!  oelement name="contact">
ocomplexType>
     osequence>
oelement name="shortname" type="string" />
oelement name="fullname" type="string" />
oelement name="email" type="string" />
o/sequence>
G 7     o/complexType>
o/element>

  
o/schema>
   , " 
/**
(    ! * Service for managing email contacts
* @service
     * @types http://example.org/contacts contacts.xsd
*/
(

   " class ContactService {


   "   
/**
E( 
  * Retrieve contact details
*
    * @param string $shortname Short name of the contact
E * @return contact http://example.org/contacts The contact
    "   */
  public function retrieve($shortname) {
$contact = SCA::createDataObject(
µhttp://example.org/contacts¶, µcontact¶);
«
return $contact;
} 3Ñ
— 
}
|   7 
 C
 
 "
G   

  
G 
        


G 
      
  
G % ! 
  
   ! 
 * 
G +     
 
 * 
Contacts DB

EmailClient.php
Contact 

79
C9 | !
|1  9

  ContactService.php
—  9
ContactEmail contacts.xsd

ContactEmailService.php Email Email


(SOAP) (SOAP)
Email
email_form.html

EmailService.php
—  3å
 

i


G ;         
  9!! 

'  )  ! 
 . !! 
  
G F
' / )F| 
'1
 )G

 9

    "
    
G H


Contact
0 (soap)
½|'| )
F|;% Contact
(json-rpc) Contact
D—0%
%*|7% Contact ContactService.php
(xml-rpc)
G &

    
—  ContactService.smd (formatted) 3]
F D  

|
G 1
 

  
 
*  
G      "! F  F D
  
1
 
Contacts DB

Contact
8
(  (JSON-RPC)
Contact 


79
C9 ContactService.php
|1  9
—  9

Email
(JSON-RPC) Email
DOJO
%
 8
( 
EmailService.php

—  3J
; 
 
 8
( 
  " !  
G ½   # 
  

 !  "   
G   "  ,     ."
%  
%*|7'RE  
 
S  T
! )

D—0'D)
|"
 
'  %||)
G

" G
G ; 
 ,
"/ 
" , 
9//(
 
"(
////E/%*|7½ |  
9//( 
 (/////   , /
9//I((/   /,/"/   /

—  3¦
%  
%*|7i

G
    " !  
½   

  

G 
  ½      


!%  ' ((½   )5     

; 
  
  
representations !states  

transferred   
' (( )

G 7 
     !½   
+%&
!"%  
 ½ 
77   
!"  %  

-TTP Method Operation


  
 %  
 + 
 

G %*|7"
 
    
 
'! )5    7—0
D—0F|; -  G
—  3š
|"
 
|  
G %||
     "   
 
! 

G    
 !   
  "  .    
 
 
 
G ; 1  "
 

! 
G 
   ! 
- 
%  
%*|7  

—  3È

 |"
 
'H*%<*D*%&—*;7 0)
G ½  !  "  

 "
 
  

Contact Contact
(Atom)
Feed

ContactFeed.php
Contact 


ContactService.php Contacts DB
Contact Contact
(RSS)
Channel

ContactChannel.php

—  x
 i


G —
"      ,

!!    



' (( i"    ()
G |      

 
 



—  x3
i"| 

 , 
G i"|  . 
   9
| i"' 
 .  )
oSOAP-ENV:Body>
oGetSearchResultsRequest...>
oVersion>495o/Version>
oQuery>ipodo/Query>
oPagination>
oEntriesPerPage>10o/EntriesPerPage>
o/Pagination>
o/GetSearchResultsRequest>
o/SOAP-ENV:Body>

|   '   "


! 
)
oSOAP-ENV:-eader>
oRequesterCredentials ...>
oeBayAuthToken>AgAAAA**AQAAA...ST+aWf1o/eBayAuthToken>
oCredentials>
oAppId>IBMUN...o/AppId>
oDevId>...o/DevId>
oAuthCert>...o/AuthCert>
o/Credentials>
o/RequesterCredentials>
o/SOAP-ENV:-eader>

+J "| 
 '! i"   .  )
POST /?callname=GetSearchResults&siteid=1&version=495&appid=«&Routing=default -TTP/1.1
-ost: api.sandbox.ebay.com

—  xx
i"| 

 , 
G | 
9  2 "3

 ,

 
23

    i" !
! 

Bindings_ebay_Proxy.php
eBayClient.php

Country: i
Currency: i

ItemID: KLKMEE eBay


Listing Details: i  eBayConsumer (SOAP)

eBayConsumer.php

Run eBayClient.php
/**
* eBay service reference
*
* @reference
* @binding.ebay eBaySvc.wsdl
* @config ebay.ini
*/
The output had I had a network eBayClient.php public $ebay;

—  xÑ
½    

 !  $

G   !    


|       
,
G |      
%+   ! 
G  


&  9 %||
; 9%  
%*|7   
< :
G

  
 

*, 
" 

    


   

—  xå
|"
G | ! 
       



    
 !/  
  !! 
 


!
 
  
(

G  

  

  
     


 
  


  !
 
! 
   " ,    (7 | ! 
 
  !  (

G "
  

4½   #
   
 "
 
   #
 (7 | !
 
   "
     
'½| 0
|— )!  
 .  (

—  x]
7C
 — G
G 7 *0*,


 *0
  !| | | 8| 
9// ( (
/  /8
G ½ |
  
! 

  —
    (
9//((/ "/ /| N N  
G —0
C
.  
!  (    
   |
9// ( (/ / 
G 
 
| 
| 
  
 !|
9//((/ "/—
/ 

—  xJ