Creaing Web service in PHP and consuming it in SAP
Introduction
This Document explains how to create web service using PHP, how to create proxy and Consuming the web service in SAP.
Prerequisites
To create a web service you need
1. WSDL editor like (Eclipse or Zend server or Altova).
2. Xampp/Wamp/Apache server with MySQL connections
3. SAP user id with all authorizations
Creating SOAP Web service in PHP
This section explains how to create a web service using php code. To create a WSDL file:
1. Open Zend Studio >> File menu >> New >> Other >> Web services >> WSDL.
2. Click next and name your wsdl file (let us name it as service.Wsdl) and select any parent directory to save this file.
3. In Target Namespace, type http://localhost/service/
4. Check Create WSDL Skelton and select SOAP for protocol drop down list, select rpc literal radio button and click finish.
5. Now you will see xml code. At the lower left corner of this xml, there are two tabs Design and Source. Click on the design tab.
6. In Service Soap box, type http://localhost/service.php
7. Rename New Operation to your function name in the above class (test)
8. Rename the input parameter from parameters to Val (this step is optional)
9. Save the wsdl file and move it from the project directory to /var/www(in xampp c:/xampp/htdocs/service)
10. As a test for your web-service, you can use something like this
Simple server.php code as follows
URL for your web service looks like: http://localhost/service/server.php?wsdl
“Note: When your consuming web service in SAP replace localhost with your system IP otherwise sap system will not recognize the web service URL like http://10.137.72.134/service/service.php?wsdl ”
Consuming Web service in SAP
This Section explains how to consume web service in SAP.
1. Login into sap
2. Goto transaction SE80
3. Right click on enterprise services -> Service Consume -> Right click and select Create
4. Opens popup in that select external wsdl click continue button.
5. Then select URL radio button and click continue
6. Give your web service URL and click continue.
7. Mention package and request/Task id click continue.
8. Popup open click enter
9. Final step click complete.
10. Save and activate the web service.
11. Now copy proxy name from proxy tab on right hand side.
12. Go to SOAMANAGER transaction it opens browser.
13. In the browser select web service configuration link
14. Search you web service by selecting Consumer Proxy from search by drop down menu.
15. In Search pattern give your proxy name which is copies in step 11.
16. Below it shows search results select and click apply selection button.
17. Below select Configuration tab
18. Click Create button in the pop up window fill all the details.
Like Logical port name description and give webservice URL.
19. Then save and activate the proxy. Copy the logical port name and come back to your SAP screen.
20. Then excute the web serivice
21. Give logical port and execute.
22. You will get xml screen. Click xml editor(cntrl+F2)
23. Replace string 1 with username it gives firstname.
Hi,
Nice post.
I could not find service consumer under enterprise service. what can is do.
Regards,
John.
Hi John,
thank you.
Please right click on enterprise service and select create.
then popup comes in that object type comes select radio button service consumer
then follow the next steps.
Thanks & Regards
Karthikeya
Hi,
I am trying to create a service consumer but I got stuck as I couldn't proceed to proxy editor due to this error as shown in the screenshot below:
Do you have any idea how to fix this issue?
TIA!
N
hello,
Can you tell me the steps your following.
Regards
Karthikeya
To maintain the credentials for proxy, go to SM59 ->Extras Menu -> HTTP Proxy Configuration-> HTTP Log -> Enter the proxy username and password there.
Another way is to go to SICF->F8->Client Menu-> Proxy Settings-> HTTP Log -> Enter the proxy username and password there.
Please note that this will be at a global level and for http web services.
I did as you instructed but i dont understand why you give the service URL as below:
.......service.php?wsdl
if I do this I get an error as below:
Incorrect value: Entity (1 /0 ). unexpected end-of-file
any idea ?