0xDEADBEEF
0xDEADBEEF

Reputation: 3431

RESTful WebService Client in PHP

lets say i have a Restful webservice (for my record-class) on a GlassFish, accessable on

http://localhost:8080/MyWS/entities.Records/

i want to use this Webservice in PHP to read and write records.

how do i use a RESTful Webservice out of PHP?

how to set the action (GET, POST, PUT, DELETE)?

how to set the user/password data in the header (glassfish is parsing the header of the HttpRequest to authentificate a user)?

and how to serialize my PHP Record-Class objects to XML (for sending: PUT, POST, DELETE) and to deserialize XML to Record-Class objects (for reading the glassfish/ws-output) easily? is there a php-builtin-method or do i have to write my own XML-Parser?

thank you

Upvotes: 1

Views: 1292

Answers (1)

radmen
radmen

Reputation: 1624

how do i use a RESTful Webservice out of PHP? how to set the action (GET, POST, PUT, DELETE)?

You can use CURL for that. Recently I've put a simple class for this. You can check it at my Github page

how to set the user/password data in the header (glassfish is parsing the header of the HttpRequest to authentificate a user)?

Simply set a header with curl_setopt. See comment #80271

is there a php-builtin-method or do i have to write my own XML-Parser?

There're some bultin extensions for that. Maybe some will be useful:

  • SimpleXML
  • DOM Document

Upvotes: 5

Related Questions