Hi guys,
now i have read many an article on using Webservices and using SOAP but my these articles usually focus on the "client" side of the service. I am trying to figure out how to create the "server" for recieving the rquest.
The request are recieved as RAW XML Content streamed to me but my my concept of "HOW" to capture the content into a variable is what i can't understand.
The concept isn't obivously one where i can usually do a $_POST or $_GET and i get the information. So what do i do? I have been researching on a PHP defined variable called HTTP_RAW_POST_DATA but there has been "mixed" theories on how to "access" it. However if this does exist is it a "safe" and trusted approach to developing a web service "server"...
Also....can any of you direct me to any articles that explain the approaches in developing a "handler" for a web service because I want to be aware of what ever steps i need to take to ensure a safe environment and proper execution of the process...
thanks
Kendall
Creating a Web Service (Server)
Moderator: General Moderators
Re: Creating a Web Service (Server)
The proper way to access HTTP_RAW_POST_DATA is reading from the php://input stream
I made such services several times. Of course, if you are looking for a SOAP service, you can use SoapServer
Keep in mind that good web service always returns XML. This means that you have to register a shutdown function, which will output XML in any case. You have to register error handler and exception handler, so you can output XML too. You don't want a PHP notice or warning to break the XML you are outputting, do you
And, if you are sending data to the service on yourself, please keep in mind that you need the proper Content-Length header... otherwise you won't be able to read the data from php://input. I've lost 30 minutes figuring out why I can't read from php://input, and I just was missing the Content-Length header (actually it was misspelled) in the client code.
I made such services several times. Of course, if you are looking for a SOAP service, you can use SoapServer
Keep in mind that good web service always returns XML. This means that you have to register a shutdown function, which will output XML in any case. You have to register error handler and exception handler, so you can output XML too. You don't want a PHP notice or warning to break the XML you are outputting, do you
And, if you are sending data to the service on yourself, please keep in mind that you need the proper Content-Length header... otherwise you won't be able to read the data from php://input. I've lost 30 minutes figuring out why I can't read from php://input, and I just was missing the Content-Length header (actually it was misspelled) in the client code.
-
mrjameswong
- Forum Newbie
- Posts: 6
- Joined: Thu Aug 13, 2009 10:14 pm
Re: Creating a Web Service (Server)
Thanks Darhazer.
-James
-James