SOAP IS BEAUTIFUL

Asmir Mustafic

(AGAIN)

WHO AM I?

Asmir Mustafic

Work

Software architect and consultant
(mainly PHP [symfony?])

Helping companies deal with their tech stack

Open source

  • Doctrine (occasional contributor)
  • JMS Serializer  (maintainer)
  • HTML5-PHP (core dev)
  • XSD2PHP (author)
  • Twital (author)
  • Many SOAP-related packages...

contributed/contributing to:

jms/serializer 1.4 released

What to expect?

  1. Short intro & theory
     
  2. Live demo

What is SOAP

SOAP (Simple Object Access Protocol) is a protocol specification for exchanging structured information in the implementation of web services in computer networks.

Its purpose is to induce extensibility, neutrality and independence.
It uses XML Information Set for its message format, and relies on application layer protocols, most often Hypertext Transfer Protocol (HTTP) or Simple Mail Transfer Protocol (SMTP), for message negotiation and transmission.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions  xmlns:tns="http://x.com" name="test"
  targetNamespace="http://x.com" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <wsdl:types> <!-- data types -->
    <xsd:schema targetNamespace="http://x.com">
      <xsd:element name="doSomething">
        <xsd:complexType>
          <xsd:sequence><xsd:element name="in" type="xsd:string"/></xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="doSomethingResponse">
        <xsd:complexType>
          <xsd:sequence><xsd:element name="out" type="xsd:string"/></xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </wsdl:types>
  
  <wsdl:message name="doSomethingRequest"> 
    <wsdl:part element="tns:doSomething" name="parameters"/>
  </wsdl:message>
  <wsdl:message name="doSomethingResponse">
    <wsdl:part element="tns:doSomethingResponse" name="parameters"/>
  </wsdl:message>
  
  <wsdl:portType name="test"> <!-- definition -->
    <wsdl:operation name="doSomething">
      <wsdl:input message="tns:doSomethingRequest"/>
      <wsdl:output message="tns:doSomethingResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  
  <wsdl:binding name="testSOAP" type="tns:test"> <!-- implementation definition -->
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="doSomething">
      <soap:operation soapAction="http://x.com/doSomething"/>
      <wsdl:input><soap:body use="literal"/></wsdl:input>
      <wsdl:output><soap:body use="literal"/> </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  
  <wsdl:service name="test"> <!-- service -->
    <wsdl:port binding="tns:testSOAP" name="testSOAP"> <!-- service implementation -->
      <soap:address location="http://www.example.org/"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

SOAP (WSDL/XML representation)

Text

SOAP (graphical representation)

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions  xmlns:tns="http://x.com" name="test"
  targetNamespace="http://x.com" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <wsdl:types> <!-- data types -->
    <xsd:schema targetNamespace="http://x.com">
      <xsd:element name="doSomething">
        <xsd:complexType>
          <xsd:sequence><xsd:element name="in" type="xsd:string"/></xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="doSomethingResponse">
        <xsd:complexType>
          <xsd:sequence><xsd:element name="out" type="xsd:string"/></xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </wsdl:types>
  
  <wsdl:message name="doSomethingRequest"> 
    <wsdl:part element="tns:doSomething" name="parameters"/>
  </wsdl:message>
  <wsdl:message name="doSomethingResponse">
    <wsdl:part element="tns:doSomethingResponse" name="parameters"/>
  </wsdl:message>
  
  <wsdl:portType name="test"> <!-- definition -->
    <wsdl:operation name="doSomething">
      <wsdl:input message="tns:doSomethingRequest"/>
      <wsdl:output message="tns:doSomethingResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  
  <wsdl:binding name="testSOAP" type="tns:test"> <!-- implementation definition -->
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="doSomething">
      <soap:operation soapAction="http://x.com/doSomething"/>
      <wsdl:input><soap:body use="literal"/></wsdl:input>
      <wsdl:output><soap:body use="literal"/> </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  
  <wsdl:service name="test"> <!-- service -->
    <wsdl:port binding="tns:testSOAP" name="testSOAP"> <!-- service implementation -->
      <soap:address location="http://www.example.org/"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

Now is LEGACY

Replaced by REST

(or/and GraphQL?)

Why replaced?

  • No clear caching strategy
  • Ignoring HTTP
  • Over structured
  • Period of uncertainty (rpc...)
  • Slow
  • Strongly typed
  • Complex
    • Not all languages have a good support
  • XML ...

What was good?

  • Platform/Language independent
  • Not binded to HTTP
    • mail, pure-tcp implementations
  • Strict
  • Strongly typed
  • Extensible
  • Auto-documenting

PHP?

ext-soap

The Good

  • "works"
  • simple
  • no-wsdl mode
  • "works"

The Bad

  • not well documented
  • not clear how to use advanced soap features
  • no type hinting
  • not always working as you will expect
  • too many "var_dump" to make it work
  • not easy to extend
  • ....

goetas-webservices/soap-client

Pure PHP implementation of SOAP 1.1
client specifications

https://github.com/goetas-webservices/soap-client

Started almost 10 years ago

SOAP Client is ready!
SOAP server is coming soon...

goetas-webservices/soap-client

Is up to date!

(even if SOAP is legacy)

goetas-webservices/soap-client

  • Pure PHP, no dependencies on ext-soap
    • ^5.5 | ^7.0
  • Extensible (JMS event listeners support)
  • PSR-7 HTTP messaging compatible
  • Multi HTTP client (guzzle, buzz, curl, react)
  • No WSDL/XSD parsing on production
    • Fast
  • IDE type hinting support

goetas-webservices/soap-client

Composed by a set of independent libraries

xsd-reader

wsdl-reader

soap-reader
 

xsd2php

wsdl2php

 

jms/serializer

php-http

and others....

 

https://github.com/goetas-webservices

Why?

Productivity boost!

Work in progress

Limitations

  • SOAP 1.1
  • only WS-I compliant
  • young...
  • more limitations...?

Wanna contribute?

DEMO Time!

If you have questions feel free to ask me now or later! :)

https://github.com/goetas-webservices/soap-client-demo

Thank you!

SOAP IS BEAUTIFUL (AGAIN)

By Asmir Mustafic

SOAP IS BEAUTIFUL (AGAIN)

  • 2,812