What Is Meant By SOAP API And Its Advantages In PHP

admin_img Posted By Bajarangi soft , Posted On 16-09-2020

SOAP API

soap api

SOAP API
  What is SOAP?

  • SOAP stands for Simple Object Access protocol. SOAP is an xml-protocol for accessing web services over HTTP. SOAp is an application communication protocol.Sending and receving message.simple object protocol, but in later times was just shortened to SOAP.
  • Today it’s mostly used to expose web services and transmit data over HTTP/HTTPS.But it’s not limited to them. SOAP unlike the REST pattern, supports the XML data formate only & strongly follows present standerdssuch as messaging structure.SOAP was developed as intermediate language so that applications built on various program language could talk easy to each other avoid extreme development effort.
  • While more ppuler in large enterprises, organizations of all size produce and consume SOAP APIs. A FInal advantages to SOAP is its extensibility . The extansibility model with in SOAP Specification Provides for Customizations.

Advantages of SOAP
  • SOAP is the protocol used for data interchange between applications.
  • Languges, platform, and transport independent(REST required use of HTTP)
  • Work distributed enterprise environments(assumes direct point-to-point)
  • Buit-in error handling
  • SOAP is Standardized
  • Automation used with certain language products


SOAP Building blocks
  • SOAP message is an ordinary XML document containing the follow elements:

    1. An Envelope element that identifies the XML document as a SOAP message 
       - Containing part
        - Used encapsulate all the details
        - Root element
2. A Header element that contains header information
        - authentication credentials which can be used calling application.
        - Contain the definition of complex types
        - Contain parameters simple types such as string and numbers,  but can also be complex object type.

 


How to call a SOAP API
  • Most likely need to include a SOAP library with your programming language
  • Although it’s possible to make SOAP API call without SOAP libraries.
  • Verbose, mainly due to reliance on XML.

Let’s look at an example of simple SOAP message
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
  <soap:Header>
  </soap:Header>
  <soap:Body>
    <m:GetUser>
      <m:UserId>123</m:UserId>
    </m:GetUser>
  </soap:Body>
</soap:Envelope>

The response might look something like this:
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<soap:Body>
  <m:GetUserResponse>
    <m:Username>Tony Stark</m:Username>
  </m:GetUserResponse>
</soap:Body>
</soap:Envelope>

SOAP Envelope
  • Separate it form other XML documents.
  • Mechanism to identify the XMl a SOAP
  • Tag requires a  namespace attribute
  • Optionally supply an encodingstyle attribute

SOAP Header 
  • Earlier sections, the header was empty
  • Extensibility via SOAP Modules.
  • Modules can either be required or optional.
  • Include the mustUnderstand attribute set to true

SOAP BODY
  • The required SOAP Body element contains the actual SOAP message intended for the ultimate endpoint of the message.
  • Namespace can be used to describe what data to expact with in the body, but are not required.
  • Procedure, parameters, and data all come through the SOAP BODY

SOAP Fault
  • SOAP:Body tag for error messages when a SOAP API call is not able to complete.
  • Inaccurate SOAP formatting process error on the server.
  • Indicate error message.

    Code – identifying the fault
    String – A human readable explanation of the fault
    Actor – Information about who caused the fault to happen
    Detail – Appication specific error information related to the Body elemet

Related Post