Zend Soap NULL Reponse

I have been working with some SOAP APIs for a few days and after successful creation of some new API endpoints, i was hoping i could save folks out there from tearing out their hair.

SOAP is a standards-based Web services access protocol that has been around for a while and enjoys all of the benefits of long-term use. Originally developed by Microsoft, SOAP really isn’t as simple as the acronym would suggest.

And while some say it’s dead, it ain’t. Many .Net projects and legacy APIs still use SOAP.

OK. So let’s come back to my own problems that i had using SOAP for creating APIs. Here is how i was setup with the code:

  • Yii2 Framework
  • Zend SOAP Library
  • PHP 7.2 / Apache 2.4

So it all seemed fair and simple when i followed the tutorials on Zend website and remember i was using Zend library as i read it somewhere that it has more support for .NET APIs.

So i created my server this way:

And i added some api test code as well

I came upon my first problem when i started getting HTTP 400 Bad Request errors on simplest of API calls like the one above in actionApiClient. I soon figured out that it was caused by the CSRF validation that Yii2 serves out of the box. I disabled that and came upon another issue.

The response for every call seemed to be NULL! Hard to debug what was happening i googled around for a couple of hours with no help. Then i saw that every official documentation had guess what, ANNOTATIONS. So i changed my API function from this

To this

And voila! The NULL response changed to the expected one.

Let me know in comments if you think something is missing or needs clarification.

alexey

alexey

Application developer, movie buff, occasional reader and a huge Manchester United fan.
alexey

Application developer, movie buff, occasional reader and a huge Manchester United fan.