Tag Archives: SOAP

Web Services

A web service is a software system designed for interoperable interaction over a network.

A web service is defined with a WSDL (Web Services Description Language) document, and other systems interact with the web service using SOAP messages, transferred using HTTP with an XML serialization.

A web service is an abstract resource that provides a set of functions and is implemented by an agent, which sends and receives messages.

A provider entity provides the functionality of a web service with a provider agent and a requester entity uses the web service functionality with a requester agent.

Web services implement various technologies, some of which are XML, SOAP, and WSDL. XML is a standard format for data exchange.

Web service requests and responses are sent as XML messages.

The elements and attributes that may be specified in an XML document are specified in an XML Schema.

SOAP provides a standard framework for packaging and exchanging XML messages. WSDL is an XML document in the http://schemas.xmlsoap.org/wsdl/ namespace for describing a web service as a set of endpoints operating on messages. A WSDL document specifies the operations (methods) provided by a web service and the format of the XML messages.

Installing the PHP Web Services Extensions

The SOAP and XML-RPC extensions are packaged with the PHP 5 installation. The SOAP extension and the XML-RPC extension are not enabled by default in a PHP installation. To enable the SOAP and XML-RPC extensions add the following extension directives in the php.ini configuration file.

extension=php_xmlrpc.dll
extension=php_soap.dll

REST

REST stands for “REpresentational State Transfer”. It is a concept or architecture for managing information over the internet. REST concepts are referred to as resources. A representation of a resource must be stateless. It is usually represented by JSON.

API stands for “Application Programming Interface”. It is a set or rules that allows one piece of software application to talk to another. Those “rules” can include create, read, update and delete operations.

Client-Server: This constraint operates on the concept that the client and the server should be separate from each other and allowed to evolve individually.

Stateless: REST APIs are stateless, meaning that calls can be made independently of one another, and each call contains all of the data necessary to complete itself successfully.

Cache: Because a stateless API can increase request overhead by handling large loads of incoming and outbound calls, a REST API should be designed to encourage the storage of cacheable data.

Uniform Interface: The key to the decoupling client from server is having a uniform interface that allows independent evolution of the application without having the application’s services, or models and actions, tightly coupled to the API layer itself.

Layered System: REST APIs have different layers of their architecture working together to build a hierarchy that helps create a more scalable and modular application.

Code on Demand: Code on Demand allows for code or applets to be transmitted via the API for use within the application.

Unlike SOAP, REST is not constrained to XML, but instead can return XML, JSON, YAML or any other format depending on what the client requests. And unlike RPC, users aren’t required to know procedure names or specific parameters in a specific order.

One of the disadvantages of RESTful APIs is that you can lose the ability to maintain state in REST, such as within sessions. It can also be more difficult for newer developers to use.

is_soap_fault

This function is useful to check if the SOAP call failed, but without using exceptions. To use it, create a SoapClient object with the exceptions option set to zero or FALSE. In this case, the SOAP method will return a special SoapFault object which encapsulates the fault details (faultcode, faultstring, faultactor and faultdetails).

If exceptions is not set then SOAP call will throw an exception on error. is_soap_fault() checks if the given parameter is a SoapFault object.

use_soap_error_handler

This function sets whether or not to use the SOAP error handler in the SOAP server. It will return the previous value. If set to TRUE, details of errors in a SoapServer application will be sent to the client as a SOAP fault message. If FALSE, the standard PHP error handler is used. The default is to send error to the client as SOAP fault message.

SOAP

It is important for web applications to be able to communicate over the Internet.

The best way to communicate between applications is over HTTP, because HTTP is supported by all Internet browsers and servers. SOAP was created to accomplish this.

SOAP provides a way to communicate between applications running on different operating systems, with different technologies and programming languages.

  • SOAP stands for Simple Object Access Protocol
  • SOAP is an application communication protocol
  • SOAP is a format for sending and receiving messages
  • SOAP is platform independent
  • SOAP is based on XML
  • SOAP is a W3C recommendation
  • SOAP is also a request-/response-based protocol.
  • SOAP can be transported using SMTP, HTTP and other protocols.
  • SOAP traffic via HTTP can be encrypted and compressed just like other HTTP requests.
  • Requires the LIBXML extension (Enabled by default in PHP)
  • SOAP Clients in PHP are hiding the complexity of sending
    a request to a remote SOAP Server and processing the
    response