GithubHelp home page GithubHelp logo

yii2-soap-server's Introduction

yii2-soap-server

A SOAP server for Yii 2 based on the implementation of Yii 1 framework.

This extension is an adaptation of the SOAP Web Service available in Yii1, to Yii2. It contains features available up to v1.1.15.

Note: Things might not work as Yii2 progresses but I'll keep it updated as much as I can.

Build Status

Requirements

Installation

Use composer and add the following line to your composer.json file:

"subdee/yii2-soap-server": "*"

Usage

Usage is similar to the explanation in the Yii guide

Define the custom action in your controller:

public function actions()
{
    return [
        ...,
        'myService' => [
            'class' => 'subdee\soapserver\SoapAction',
        ],
        ...,
    ];
}

Add the @soap keyword to the properly documented actions you want:

/**
* Returns hello and the name that you gave
*
* @param string $name Your name
* @return string
* @soap
*/
public function getHello($name)
{
    return 'Hello ' . $name;
}

Also, remember to turn off CSRF validation for the controller by setting its property:

public $enableCsrfValidation = false;

yii2-soap-server's People

Contributors

ant0ny avatar gektor0856 avatar necrosisoff avatar subdee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

yii2-soap-server's Issues

maxOccurs generates wrong wsdl when set on array's

At least, that is what I found when I tried to load the wsdl into SoapUI,

Example:

class Test{
 /**
     * @var Example[] {nillable = 0, minOccurs=1, maxOccurs = unbounded}
     * @soap
     */
    public $examples= [];
}

It renders:

<xsd:complexType name="Test">
        <xsd:all>
          <xsd:element minOccurs="1" maxOccurs="unbounded" nillable="false" name="examples" type="tns:ExampleArray"/>
        </xsd:all>
      </xsd:complexType>
      <xsd:complexType name="ExampleArray">
        <xsd:complexContent>
          <xsd:restriction base="soap-enc:Array">
            <xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="tns:Example[]"/>
          </xsd:restriction>
        </xsd:complexContent>
      </xsd:complexType>
      <xsd:complexType name="Example">
        <xsd:all>

I think the correct xml should contain the minOccurs, MaxOccurs line on the generated ExampleArray?

SOAP-ERROR: Encoding: object has no 'propety_name' property in object

Hello!
I have a complex object with an array of other complex objects (several hundred). It is generated automatically once per day and saved serialised into a file. And I have web-service based on yii2-soap-server, which serves this object from the file to clients. Sometimes it returns following error:

SOAP-ERROR: Encoding: object has no 'property_name' property in
/var/www/site/vendor/subdee/yii2-soap-server/SoapService.php:172

Maybe one or few objects miss this 'property_name' while generating stage, but I haven't found the bug yet.

My question: is there a way to find (var_dump maybe) the object which causes the error ?

yii2-soap-server : ea980cf
php version: 7.0.15

Using SoapAction in controller in module

Seem there is error in WSDL when using SoapAction in controller in module.

I have module qbConnector. The module has controller QBWCController which has action service.

    public function actions()
    {
        return [
            'service' => [
                'class' => SoapAction::className(),
            ],
        ];
    }

In WSDL I have:

  <wsdl:service name="modules/qbConnector/controllers/QBWCControllerService">
    <wsdl:port name="modules/qbConnector/controllers/QBWCControllerPort" binding="tns:modules/qbConnector/controllers/QBWCControllerBinding">
      <soap:address location="http://localhost/aris-pool-2.0/qbwc/service?ws=1"/>
    </wsdl:port>
  </wsdl:service>

It should be:

  <wsdl:service name="modules/qbConnector/controllers/QBWCControllerService">
    <wsdl:port name="modules/qbConnector/controllers/QBWCControllerPort" binding="tns:modules/qbConnector/controllers/QBWCControllerBinding">
      <soap:address location="http://localhost/aris-pool-2.0/qbConnector/qbwc/service?ws=1"/>
    </wsdl:port>
  </wsdl:service>

Complex Type as input parameter

Hey guys.

I expect the following operation in the controller class to work:

/**
* Returns hello and the name that you gave
*
* @param app\models\Post $post
* @return string
* @soap
*/
public function receive($post)
{
    return 'Hello ' . $post->title;
}

The WSDL is generated correcly, here it is:

https://gist.github.com/jonvargas/054d9cac7a7c4e51e527

But SoapUI complains:

"The value 'app\models\Post' is an invalid name."

Is this the proper way to generate a service operation that expects a complex type? Could you detail a bit more?

Thanks in advance

classMap not working?

Hi, I try to map the follwing classes:

public function actions()
  {
      return [
          'SearchLists'=>[
            'class'=>'subdee\soapserver\SoapAction',
            'classMap'=>[
                'SearchRequest' => '\common\models\SOAP\SearchRequest',
                'common\models\SOAP\ResultRecord',
                'common\models\SOAP\names',
                'common\models\SOAP\addresses'
            ],
          ],
          'HelloWorld'=>[
            'class'=>'subdee\soapserver\SoapAction'
          ]
      ];
  }

But whatever I try, the system tells me:

Previous exception:
exception 'ReflectionException' with message 'Class SearchRequest does not exist' in /Users/philippfrenzel/Sites/resparty/vendor/subdee/yii2-soap-server/WsdlGenerator.php:392

What can I do, to get that class recognized?!

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.