Git Product home page Git Product logo

lv-soap-server's Introduction

laravel-soap-server

Latest Version on Packagist Build Status Quality Score Total Downloads

Laravel SOAP service server

Installation

You can install the package via composer:

composer require kduma/laravel-soap-server

Usage

Create server class - remember to provide correct typehints and doc blocks:

class SoapDemoServer
{
    /**
     * Adds two numbers
     *
     * @param float $a
     * @param float $b
     *
     * @return float
     */
    public function sum(float $a = 0, float $b = 0): float
    {
        return $a + $b;
    }

    /**
     * Returns your data
     *
     * @return Person
     */
    public function me(): Person
    {
        return new Person('John', 'Doe');
    }

    /**
     * Says hello to person provided
     *
     * @param Person $person
     *
     * @return string
     */
    public function hello(Person $person): string
    {
        return sprintf("Hello %s!", $person->first_name);
    }
}

...and DTO objects:

class Person
{
    /**
     * @var string
     */
    public $first_name;

    /**
     * @var string
     */
    public $last_name;

    /**
     * @param string $first_name
     * @param string $last_name
     */
    public function __construct(string $first_name, string $last_name)
    {
        $this->first_name = $first_name;
        $this->last_name = $last_name;
    }
}

Create controller class for your SOAP server:

class MySoapController extends \KDuma\SoapServer\AbstractSoapServerController
{
    protected function getService(): string
    {
        return SoapDemoServer::class;
    }

    protected function getEndpoint(): string
    {
        return route('my_soap_server');
    }

    protected function getWsdlUri(): string
    {
        return route('my_soap_server.wsdl');
    }

    protected function getClassmap(): array
    {
        return [
            'SoapPerson' => Person::class,
        ];
    }
}

Register routes in your routes file:

Route::name('my_soap_server.wsdl')->get('/soap.wsdl', [MySoapController::class, 'wsdlProvider']);
Route::name('my_soap_server')->post('/soap', [MySoapController::class, 'soapServer']);

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

lv-soap-server's People

Contributors

kduma avatar raidski20 avatar

Stargazers

Robert Butler avatar BinotaLIU avatar  avatar Rangel Albrecht avatar  avatar  avatar  avatar  avatar Caio Jhonny avatar ericivan avatar Ramón E. Zayas avatar fabiolopes22103261 avatar José Rosendo avatar Piotr  avatar  avatar Nguyễn Quang Vũ avatar Alexandre Teixeira Mendes avatar Khalil Charfi avatar Edwin Heij avatar

Watchers

Robert Butler avatar James Cloos avatar  avatar

lv-soap-server's Issues

Request example

Hey, this my first time setting up/working a soap web services, and I'm having a problem with the client side.
Would you please be able to provide examples of how to call the web service from the client side?

I have tried making a POST request using the following request body

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Sum>
        <a>100</a>
        <b>20</b>
    </Sum>
  </soap:Body>
</soap:Envelope>

I get the following response back

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
        <SOAP-ENV:Fault>
            <faultcode>SOAP-ENV:Server</faultcode>
            <faultstring>Procedure 'Sum' not present</faultstring>
        </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.