Skip to Content

Introduction


   The purpose of this article is to help on how to implement logical ports and how to create an executable program in order to consume an abap proxy after creating a webservice in PHP and a service consumer in Enterprise Services. In order to start with this article it is necessary to first build the PHP webservice and define the service consumer in ES. This foundation is perfectly explained by Karthikeya Sastry in his great document: Creating Web service in PHP and consuming it in SAP  It is a very straightforward tutorial on how to consume PHP webservices and as always: the most complex solution is rarely the best one. After going through his document I was looking after a way to consume that service he created in an executable program. So, this tutorial is a complement to show how to configure the logical port in SOAMANAGER in a way to set it as default to be used in ABAP programs that consume the proxy developed.

Configuration of Consumer Proxies    


   The configuration of consumer proxies is implemented via logical ports. Consequently, a logical port is created based on the requirements of the provider. A logical port refers to a service endpoint that is available under a unique location in the provider system. A logical port additionally contains a runtime configuration for accessing the service endpoint. Furthermore, the port also contains the logon data that is required for calling the service methods. You can create multiple logical ports for each consumer proxy, but a logical port can only refer to one endpoint. You manage and configure consumer proxies via the SOA Management tool (Transaction SOAMANAGER). The below figure illustrates the relationship between logical ports and service endpoints. A service consumer establishes a connection by sending a call via a logical port. A logical port can send a call only to one service end- point, but a service endpoint can be called via various logical ports. 

/wp-content/uploads/2014/05/1_451867.png

After following the steps to develop the PHP webservice in Karthikeya Sastry tutorial you should have the below enterprise service:

/wp-content/uploads/2014/05/2_451934.jpg

PHP development


In my case the MySQL DB has the structure below and by providing the titel column as a key for the PHP report, it must return the entire row:

  /wp-content/uploads/2014/05/3_451935.jpg

– My adjusted PHP program according to the model form the tutorial:

<?php

class MyClass{

                  function test($val){

                                    $host = “xxxx”;                                  

     $user = “xxxx”;

                                    $senhabd = “xxxx”;

                                    $db = “cdcol”;

                                   

                                    $connection = mysql_connect($host, $user, $senhabd) or die(‘Não foi possivel conectar: ‘ . mysql_error());

                                    $db = mysql_select_db($db, $connection) or die(“erro database”);

                                   

                                    $sql = “SELECT * FROM CDS WHERE TITEL = ‘”.$val.”‘”;

                                   

                                    $result = mysql_query($sql) or die(mysql_error());

                                   

                                    $tbl = mysql_fetch_array($result);

                                   

                           $nome = $tbl[“interpret”];

                                   

                                    echo $nome;

                           return $nome;

                  }

}

$server = new SOAPServer(‘service.wsdl’);

$server->setClass(‘MyClass’);

$server->handle();

?>

–  The WSDL that I generated from the tutorial:

/wp-content/uploads/2014/05/wsdl_451940.jpg

Configuration of Logical Port


      Go to SOAMANAGER transaction and select the service administration tab. Then choose single service configuration and search for the consumer proxy you created. Then create the logical port with the URL of your generated PHP WSDL path. Until now you can only test your proxy but you are not able to use it in your ABAP program. So, the trick here is to define this logical port as the default for your consumer proxy by checking the box ‘Logical Port is default’ as in the pictures below. You could also do that in older versions with transaction LPCONFIG although it is not advisable since it must not be used to create logical ports for proxy classes generated in versions after SAP NetWeaver 2004s. SOAMANAGER override logical ports created in transaction LPCONFIG. This means that, when two logical ports with the same name exist, the logical port created in transaction SOAMANAGER will be used. This also applies to the behavior of default logical ports. If transaction SOAMANAGER is used to create a default logical port for a particular proxy class, the default logical port created for this class with transaction LPCONFIG is no longer used.

/wp-content/uploads/2014/05/soa1_451942.jpg

/wp-content/uploads/2014/05/soa2_451946.png

ABAP Proxy


    Finally,  after setting the logical port as default we can consume the service in an ABAP program. According to the parameters we defined for the webservice, we provide the input structure with the key for the for the records of the MySQL DB in order to retrieve the record from the output structure and display its columns.

REPORT  Z_PROXY_O_PHP.

DATA: o_proxy TYPE REF TO ZCONSCO_SERVICE,
o_ex1
TYPE REF TO CX_ROOT,
v_val
TYPE ZCONSTEST,
v_response
TYPE ZCONSTEST_RESPONSE,
v_text1
TYPE string.

STARTOFSELECTION.

v_valNEW_OPERATION_REQUEST = ‘Beauty’.

TRY.
CREATE OBJECT: o_proxy.

CALL METHOD o_proxy->test
EXPORTING
input = v_val
IMPORTING
output = v_response.

commit work.

CATCH CX_AI_SYSTEM_FAULT INTO O_EX1.
V_TEXT1
= O_EX1->GET_TEXT( ).
ENDTRY.

IF v_response IS NOT INITIAL.

WRITE: v_responseNEW_OPERATION_RESPONSE.

ENDIF.

Result


According to our PHP webservice it will be displayed the second column from MySQL DB table:

/wp-content/uploads/2014/05/result_451947.jpg

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Aabid A Majeed

    Hi I tried this but i am getting the following error any help you can offer would be appreciated.

    SOAP:1,007 SRT: Unsupported xstream found:
    (“HTTP Code 200 : OK”)


    Thanks

    (0) 
    1. Paulo Cesar de Biasi Vantini Post author

      Hi,

      this message means your local MySQL server´s socket is not correctly configured.

      Check if it is up and running in your xampp console or start it manually in your windows services. Otherwise, if it still doesn´t work, try to reinstall your xampp server and create the database and tables used in this tutorial again. Sorry for late response.

      Regards.

      (0) 

Leave a Reply