Skip to content
This repository has been archived by the owner on Jan 13, 2020. It is now read-only.
/ SoapCalculator Public archive

A simple calculator utilizing a SOAP web service for calculation

Notifications You must be signed in to change notification settings

cowglow/SoapCalculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SoapCalculator

Before the days of REST APIs the world used SOAP web services. Instead of JSON, we used XML to communicate. Soap clients in PHP are simple to understand and follow. You'll first need a WSDL, which acts as instructions of what you can request and expect as response.

This project utilized a public SOAP Web Service which provides 4 methods Add, Subtract, Multiply, Divide.

The code

The project is follows the clear-architecture. On the abstract port layer you'll find the bulk of the code.

$soapClient = new \SoapClient($this->wsdl);
  $input = [
    'intA' => $inputs[0],
    'intB' => $inputs[1]
  ];

The request gets sent to the Soap web service and a specific method is utilized to read the response.

switch ($operator) {
    case '+':
        $response = $soapClient->Add($input);
        return $response->AddResult;
        break;
    case '-':
        $response = $soapClient->Subtract($input);
        return $response->SubtractResult;
        break;
    case '*':
        $response = $soapClient->Multiply($input);
        return $response->MultiplyResult;
        break;
    case '/':
        $response = $soapClient->Divide($input);
        return $response->DivideResult;
        break;
}

About me

I'm American living and working in Germany.

Todos

  • Fork it
  • Code it!
  • Do it on your own!

License

MIT

About

A simple calculator utilizing a SOAP web service for calculation

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published