integrating php and abap using webservices

Upload: julianholgado

Post on 03-Jun-2018

237 views

Category:

Documents


3 download

TRANSCRIPT

  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    1/20

    Integrating PHP and ABAP Using Webservices

    Purpose

    One of the paradigms of modern architecture is service orientation(SOA) with it's SAP avour ESA (enterprise service architecture). Animportant principle of SOA is implementation transparency i.e. itdoesn't matter in which language a service is !eing implemented."his allows to com!ine services from di#erent specialisedenvironments into composite applications or processes.

    P$P is a scripting language with an always growing user!ase havingits strenghts in a num!er of areas in which it can complement A%APwell (e.g. &ml schema validation small footprint graphics

    manipulation cryptology ...) ntegrating P$P and A%AP thereforeadds a valua!le opportunity for those creating stateoftheartsolutions around the etweaver platform.

    n this we!log 'll give a simple tutorial to show how to ma*e use ofwe!services technologies to integrate P$P and A%AP. n my opinionthe features of we!services and SOAP ma*e the use of the good oldP$P+,- li!rary which did such a good o! for many years o!solet.One interface technology less.

    Prere/uisites

    "he e&amples shown here re/uire A%AP 0AS 1.234 and P$P 5.&."he soap li!raries in P$P are not ena!led !y default so we have toena!le them !y addinge&tension6php7soap.dllto the php.ini 8le. ,or development we don't want the 0S9:s to !ecached once downloaded so we have to setsoap.wsdl7cache7ena!led63in php.ini.

    -alling an A%AP we!service from P$P

    ,irst we have to create the we!service in A%AP. 0e create a verysimple we!service accepting one input parameter and returning aparameter !ased on it. So we create a function module ;"070S-"O ;"07,>%E(P7O>") "DPE S"+B?@

  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    2/20

    concatenate 'A%AP says= $ello' space p7in into p7out separated !yspace.concatenate p7out 'F' into p7out.

    E9,>-"O.

    "his is pro!a!ly the most simple function module to test thefunctionality. t e&pects a name say Sue and returns A%AP says=$ello SueF 0e remoteena!le save and activate it. e&t we create awe!service !ased on it. Since this is a !it di#erent for di#erentversions of A%AP 0AS please consult the documentation for it.+egardles of the version it's /uiet simple ust rightclic* the functionmodule and 8nd the appropriate action or create a new o!ect oftype we!service interface. 9o not forget to release the service forthe soap runtime. 0hen everything is set up we get the 0S9:(we!service description languageG 'the service description') at thefollowing address=

    http=HHtonysu!=I333HsapH!cHsrtHrfcHsapH;"070S

  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    3/20

    'password' 6 Npassword 'trace' 6 true 'e&ceptions' 6 true))G

    try

    echo Nclient;tw,u!

  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    4/20

    An the result showing the answer of the we!service

    -alling a P$P we!service from A%AP

    ,irst we create a we!service in P$P. "his is not so easy as one mighte&pect from P$P. "he reason for this is that using the standard SOAPfunctions you need a 0S9: 8rst to instanciate a we!service. "hereare li!raries on the internet allowing to autogenerate a 0S9: !asedon some P$P functions !ut those li!raries are not too ela!orate yet.One good solution is the one provided !y nusoap. >nfortunately thisli!rary collides with the standard li!raries since they use the samenames for SOAP classes. So we create the 0S9: ourselves. 0ealready have one template which ma*es this tutorial nicely

    symmetrical. 0e use the one created for the A%AP we!service andadopt it for our needs.MJ&ml version6@

  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    5/20

    element,orm9efault6@un/uali8ed@ attri!ute,orm9efault6@/uali8ed@ M&sd=element name6@;tw,u!

  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    6/20

    Msoap=addresslocation6@http=HHtonysu!HwsHsoapserver%

  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    7/20

    my7input type Wtw7Wtw7fu!"P>" 6 my7result.

    write= H my7resultpout.

    CoilX we end up with the following= An input screen to enter a name

    An the result showing the answer of the P$P we!service

    %asically thats it. Everything else is 8ddling around with morecomple& data structures (nested structures in A%AP and nested

    arrays in P$P). And of course ela!orating on more usefule&amples =),ollowup we!logs will cover such topics. Stay tuned.,urther documentation on the P$P SOAP li!raries can !e found here.

    Anton 0enWelhuemer is a solution architect wor*ing onetweaver solutions in the healthcare industry

    http://www.php.net/manual/en/ref.soap.phphttp://weblogs.sdn.sap.com/pub/u/14864http://sapmentors.sap.com/http://www.php.net/manual/en/ref.soap.phphttp://weblogs.sdn.sap.com/pub/u/14864
  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    8/20

    Turn any SAP remote-enabled function module into aWeb Service Part 1

    September 29, 2009 By Steve Park5 Comments

    It still amazes me that not a lot of developers know that yo !an trn any e"istin# S$P

    remote enable fn!tion modle into a %eb Servi!e& It may sond like a !hallen#in#

    task, bt it is 'st one of those thin#s that yo either know how to do it or yo don(t&

    $nd to know how to do it only takes )5min to nderstand&

    I have broken this down into 2 blo#s

    Part ) will show how to !reate the simple str!tred web servi!e

    Part 2 will show how to !onfi#re and test the web servi!e sin# S*$+$$-./

    and %S$

    1or this s!enario, I !reated a really simple fn!tion modle with one inpt and oneotpt that will send ba!k a response of /esponse s!!essfl from test3 4his will

    only !reate one operation for this servi!e& owever, if yo want to !reate mltiple

    operations for a Servi!e yo !an also #enerate the servi!e from a fn!tion #rop&

    6o will need to ensre that the attribte is set as /emote7enabled in the fn!tion

    modle&

    http://www.dataxstream.com/author/spark/http://www.dataxstream.com/2009/09/turn-any-sap-remote-enabled-function-module-into-a-web-service-%E2%80%93-part-1/#commentshttp://www.dataxstream.com/author/spark/http://www.dataxstream.com/2009/09/turn-any-sap-remote-enabled-function-module-into-a-web-service-%E2%80%93-part-1/#comments
  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    9/20

    ow #o to transa!tion S.80 and ri#ht7!li!k:Create:%eb Servi!e

    Sin!e S$P will be hostin# this web servi!e we will want to sele!t Servi!e Provider3

  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    10/20

    Sele!t the radio btton Existing ABAP Object(Inside Out)

    Sin!e we are bildin# this web servi!e from a 1n!tion +odle& 4he differen!e

    between and inside ot vs& an otside is approa!h is where the str!tre is bilt& 1rom

    a desi#n perspe!tive, it is re!ommended that yo se an *tside7in approa!h

    whenever possible& 4his means that yo wold bild ot the str!tre in the .S/ and

    then implement the !ode behind it in S$P&& owever, there will be !ases when yo

    will want to trn a Standard S$P remote enable fn!tion modle into a %eb Servi!e,

    ths sin# this approa!h, the Inside ot approa!h&&;

    -ive a name to what yo want to !all yor .nterprise servi!e and spe!ify that the

    endpoint will be a fn!tion modle&

  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    11/20

    .nter the name of the 1n!tion modle that the web servi!e will !all in the ba!kend&

    ere yo will have to spe!ify whi!h athenti!ation yo want this servi!e to have& 1or

    this e"ample I have set it to no athenti!ation&

  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    12/20

    ow yo are !omplete with bildin# this web servi!e& owever at this point yo

    have 'st bilt the %eb Servi!e bt yo will now need to !onfi#re it so that an

    e"ternal appli!ation !an !all this web servi!e&

  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    13/20

    4his will !ome in my ne"t Blo# for !onfi#rin# the newly !reated %eb Servi!e and as

    well as testin# this servi!e&

    Turn any SAP remote-enabled function module into aWeb Service Part

    *!tober ), 2009 BySteve Park< Comments

    In my previos blo# I showed the steps into trnin# a simple fn!tion modle into an.nterprise Servi!e& ow that we have the servi!e defined in .CC, or ne"t step is to

    !onfi#re it so an e"ternal appli!ation !an !all or newly !reated servi!e&

    I will show how to !onfi#re and test the %eb Servi!e on .CC with Servi!e pa!k )=

    and hi#her& Before Servi!e Pa!k )=, the !onfi#ration is !ompleted in .CC, however

    after SP)= the !onfi#ration is !ompleted on the >ava Sta!k&

    ow let(s #et started&

    ."e!te the followin# transa!tion?

    4ransa!tion? S*$+$$-./

    4his will initiate a %eb session and prompt yo to lo# into the %eb$S&

    *n!e yo have lo##ed in, the ne"t step is to lo!ate the .nterprise Servi!e that yo

    !reated earlier&

    4o lo!ate yor .nterprise Servi!e #o to

    Bsiness $dministrator 4ab : %eb Servi!e $dministration

    http://www.dataxstream.com/author/spark/http://www.dataxstream.com/author/spark/http://www.dataxstream.com/2009/10/turn-any-sap-remote-enabled-function-module-into-a-web-service-%E2%80%93-part-2/#commentshttp://www.dataxstream.com/2009/10/turn-any-sap-remote-enabled-function-module-into-a-web-service-%E2%80%93-part-2/#commentshttp://www.dataxstream.com/author/spark/http://www.dataxstream.com/2009/10/turn-any-sap-remote-enabled-function-module-into-a-web-service-%E2%80%93-part-2/#comments
  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    14/20

    1irst we will want to find the .nterprise Servi!e that we !reated& In or s!enario, we

    named or test servi!e as @4.S4%.BS./IC.3& $fter yo have fond yor

    servi!e, yo need to display it by pressin# the $pply Sele!tion3 btton&

    4his will display the !rrent settin#s for this servi!e& Sin!e we have not yet defined

    the !onfi#ration we will want to !reate a new servi!e& In the Confi#ration tab,

    sele!t Create Servi!e3&

    http://www.dataxstream.com/wp-content/uploads/2009/08/pic1.jpg
  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    15/20

    .nter a Servi!e ame and a Bindin# name that yo wold like& I sally pt a prefi"

    of S3 and B3 when definin# a Servi!e ame and a Bindin# name&

    ere yo will see all of the different type of rntime !onfi#ration options that are

    available& $s yo !an see yo !an !onfi#re other se!rity and athenti!ation

    options& *n!e yo are !omplete, press S$.3&

    http://www.dataxstream.com/wp-content/uploads/2009/08/pic3.jpghttp://www.dataxstream.com/wp-content/uploads/2009/08/pic2.jpg
  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    16/20

    ow yo are !omplete& 4he %eb Servi!e shold be p and rnnin# ready for an

    e"ternal appli!ation to !all it& *r ne"t step is to obtain the wsdl lo!ation and e"e!te

    a test a !all to the %eb Servi!e from an e"ternal appli!ation&&

    Testing the Web Service

    Before we !an test the servi!e we will first need to #et the wsdl lo!ations& %ith yor

    servi!e displayed, #o to the *verview tab&

    ere yo will want to !li!k on *pen wsdl do!ment for sele!ted bindin#3

    http://www.dataxstream.com/wp-content/uploads/2009/08/pic5.jpghttp://www.dataxstream.com/wp-content/uploads/2009/08/pic4.jpg
  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    17/20

    4his will display the wsdl in another web session& 4his is the A/ that needs to be

    #iven to the e"ternal appli!ation that is initiatin# the !all& In or !ase, we will be

    sin# the %S avi#ation tool to be doin# this !all& Copy this A/&

    ow we have the wsdl lo!ation, we will se the %S avi#ator to perform the test&

    In *verview tab, sele!t the followin# link?

    *pen %eb Servi!e navi#ator for sele!ted bindin#3

    ere yo will enter the wsdl A/ that yo !opied in the previos step&4hen press e"t(

    http://www.dataxstream.com/wp-content/uploads/2009/08/pic7.jpghttp://www.dataxstream.com/wp-content/uploads/2009/08/pic6.jpg
  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    18/20

    .nter a valid ser that will lo# into .CC when !allin# the %eb Servi!e

    ow press 4est(&

    ere is a list of available operations to !all this Servi!e& /emember sin!e we bilt it

    from 'st a fn!tion modle it will only !ontain one operation& If we want to bild an

    servi!e with mltiple operation we wold #enerate this servi!e from a fn!tion #rop&

    http://www.dataxstream.com/wp-content/uploads/2009/08/pic10.jpghttp://www.dataxstream.com/wp-content/uploads/2009/08/pic9.jpghttp://www.dataxstream.com/wp-content/uploads/2009/08/pic8.jpg
  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    19/20

    1or this simple e"ample, the servi!e will take any inpt and brin# ba!k a s!!essflresponse&

    http://www.dataxstream.com/wp-content/uploads/2009/08/pic11.jpg
  • 8/11/2019 Integrating PHP and ABAP Using Webservices

    20/20