SOAP

From BC$ MobileTV Wiki
Jump to: navigation, search
Unofficial SOAP Web Service icon

SOAP (Simple Object Access Protocol) is a lightweight platform and language neutral communication protocol that allows programs to communicate via standard Internet HTTP. SOAP is standardized by the W3C.[1]


Specifications

SOAP message structure

SOAP 1.1


SOAP 1.2




Format

SOAP 1.1

Fictional Web Service call to a "Stock lookup" Web Service using SOAP 1.1 (must occur via POST with URL-escaped SOAP as message body):

REQUEST:

POST /StockQuote HTTP/1.1
Host: www.stockquoteserver.com
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn
SOAPAction: "Some-URI"
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body>
      <STOCKS:GetLastTradePrice xmlns:STOCKS="http://www.webservicex.net/stocks.dtd">
          <STOCKS:symbol>DIS</STOCKS:symbol>
      </STOCKS:GetLastTradePrice>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

RESPONSE

HTTP/1.1 200 OK
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  <SOAP-ENV:Body>
      <STOCKS:GetLastTradePriceResponse xmlns:STOCKS="http://www.webservicex.net/stocks.dtd">
          <STOCKS:Price>34.5</STOCKS:Price>
      </STOCKS:GetLastTradePriceResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

NOTE: SOAP1.1 in most cases accepts POST requests only, must send SOAP XML inside Body of request message or it will fail and produce an error since it forces validation.


SOAP 1.2

Fictional Web Service call to a "Recommendation Engine" Web Service using SOAP 1.2 (could be done over GET or POST, as long as authentication/configuration permits it):

REQUEST:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.openrecommender.org/">
  <soapenv:Header/>
  <soapenv:Body>
     <ws:GetRecommendations>
         <ws:lastViewed>Video #1</ws:lastViewed>
         <ws:nowViewing>Video #11203</ws:nowViewing>
         <ws:type>org.openrecommender.Video</ws:type>
     </ws:GetRecommendations>
  </soapenv:Body>
</soapenv:Envelope>


RESPONSE

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://openrecommender.org/schema/" xmlns:openrec="http://openrecommender.org/schema/recommendations.xsd">
  <soap:Body>
     <ws:getRecommendationsResponse>
        <openrec:recommendations>
            <openrec:recommendation>
               <openrec:title>Video #345</video:title>              
               <openrec:image>http://example.com/images/345.jpg</video:image>
               <openrec:link>http://example.com/video/345</video:link>
               <openrec:description>Awesome video which is similar to #11203</video:description>
            </openrec:recommendation>
        </openrec:recommendations>
     </ws:getRecommendationsResponse>
  </soap:Body>
</soap:Envelope>

NOTE: SOAP1.2 endpoints can be invoked more similar to REST Web Services, via parameters in the URL (i.e. HTTP Request testing tool or even Web Browser address bar)


What is SOAP?

SOAP High-level overview

The basic Web services platform is XML plus HTTP.

   * SOAP stands for Simple Object Access Protocol
   * SOAP is a communication protocol
   * SOAP is for communication between applications
   * SOAP is a format for sending messages
   * SOAP is designed to communicate via Internet
   * SOAP is platform independent
   * SOAP is language independent
   * SOAP is based on XML
   * SOAP is simple and extensible
   * SOAP allows you to get around firewalls
   * SOAP will be developed as a W3C standard

[2]


This diagram shows a system-level flow diagram for an example SOAP Request/Response:

SOAP basics 4 2.gif

EXAMPLES

There aren't many valid, up-to-date and properly maintained WSDLs or SOAP endpoints left, and with the failure of UDDI to provide a single repository of Web Services, it has left a vaccuum sensation similar to the end of a shower when the rest of your SOAP (and water) gets sucked down the drain.

Still, for historical purposes and for testing if ever having the misfortune of needing to use SOAP exclusively, here I will collect the last few commercial or enterprise-grade SOAP Web Service Endpoints for preservation's sake (since the leading aggregator Seekda has gone down[3]).


Tools

JAVA

JavaScript

[9]

PHP

[11] [12] [13] [14]


Python

Objective-C/Swift


Resources


Tutorials

[17]




External Links


References

  1. What are Web Services http://w3schools.com/ngws/ngws_webservices.asp
  2. W3Schools on Web Services and SOAP: http://w3schools.com/webservices/ws_platform.asp
  3. Seekda - Public SOAP Web Service (UDDI) directory and search engine: http://webservices.seekda.com/browse
  4. JIRA SOAP Lib: https://bobswift.atlassian.net/wiki/display/JSOAPLIB/JIRA+SOAP+Library
  5. Apache CXF: Interview with Dan Diephouse and Paul Brown: http://www.oreillynet.com/onjava/blog/2007/07/apache_cxf_interview_with_dan.html
  6. Difference between Apache CXF and Axis: http://stackoverflow.com/questions/1243247/difference-between-apache-cxf-and-axis
  7. http://www.slideshare.net/itemis/axis2-vs-cxf-high-noon-apache-presentation
  8. Simplest SOAP example using Javascript: http://stackoverflow.com/questions/124269/simplest-soap-example-using-javascript
  9. Easily consume SOAP Web services with JavaScript: http://www.techrepublic.com/article/easily-consume-soap-web-services-with-javascript/5887775
  10. Check if SOAP is enabled in PHP and if not enable it: http://stackoverflow.com/a/29694015/335867
  11. How to fix Fatal error: Class 'SoapClient' not found error (install SOAP client/server in "php.ini", separate from base "SOAP" lib): https://stackoverflow.com/questions/11391442/fatal-error-class-soapclient-not-found
  12. SoapServer returns Internal Server Error (no log) in Laravel 5.2: https://github.com/laravel/framework/issues/13672
  13. The SoapServer class: https://www.php.net/manual/en/class.soapserver.php
  14. The SoapClient class: https://www.php.net/manual/en/class.soapclient.php
  15. Convert SOAP response to SOAP XmL string using JAX-WS : https://coderanch.com/t/549539/java/Convert-SOAP-response-SOAP-XmL
  16. Troubleshooting JAX-WS applications with the WebSphere Application Server V6.1 Feature Pack for Web Services: https://www.ibm.com/developerworks/websphere/library/techarticles/0803_adams/0803_adams.html
  17. Web Services and PHP – SOAP vs XML-RPC vs REST: http://roshanbh.com.np/2008/07/web-services-php-soap-vs-xml-rpc-vs-rest.html
  18. JavaScript SOAP Client tutorial: www.codeproject.com/Articles/12816/JavaScript-SOAP-Client
  19. Clean up your wire protocol with SOAP, Part 1: http://www.javaworld.com/article/2075167/soa/clean-up-your-wire-protocol-with-soap--part-1.html
  20. Binding WCF to jQuery: http://channel9.msdn.com/Shows/Devs4Devs/WCF-and-jQuery-A-Perfect-Couple


See Also

Web Services | SOA | WSDL | UDDI | REST | XML