Skip to content
This repository was archived by the owner on Jan 13, 2020. It is now read-only.
cowglowPublic archive

About

A simple calculator utilizing a SOAP web service for calculation

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

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

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages