laravel-soap: 400 Bad Request, XML not as expected

Hi @CodeDredd,

I’ve been trying to implement this package today but have encountered a few issues along the way, such as exceptions about request body being empty when using withWsa(), now that I have removed that call I am getting a 400 Bad Request with everything I try even though the docs make it look very straightforward.

Here is a screenshot of my IDE, showing my class on the left creating the Soap client via your package and calling a method defined in the WSDL, and passing three parameters through with keys which I would expect to see in the XML request. However when I perform a dd() in the ExtSoapEncoder it gets passed through, the arguments are there but are not truly reflected in the generated XML.

soap_package_issue_anon

For example it hasn’t added the first parameter languageID at all, and it has added the startDate and endDate as param1, param2 etc not honouring the keys that I am passing through - why is this?

Also just to note I have defined the __call method on my class and applied trait when I took a look at one of the generated classes:

    /**
     * Execute soap call
     *
     * @param string $method
     * @param mixed $parameters
     * @return \CodeDredd\Soap\Client\Response|mixed
     */
    public function __call($method, $parameters)
    {
        if (static::hasMacro($method)) {
            return $this->macroCall($method, $parameters);
        }

        $validationClass = 'App\\Validations'
            . ucfirst(Str::camel($method))
            . 'Validation';
        if (class_exists($validationClass)) {
            $parameters = app()->call([$validationClass, 'validator'], ['parameters' => $parameters]);
        }

        return $this->soap->call($method, $parameters);
    }

I can generate a successful response from the API using the SoapUI application which generates the following XML for the request:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
   <soap:Header/>
   <soap:Body>
      <tem:GetVisitSummariesByDate>
         <tem:languageID>1</tem:languageID>
         <tem:startDate>2021-04-10T00:00:00.000Z</tem:startDate>
         <tem:endDate>2021-04-14T00:00:00.000Z</tem:endDate>
      </tem:GetVisitSummariesByDate>
   </soap:Body>
</soap:Envelope>

The SoapUI configuration in terms of authentication is simply a Username and Password, WSS-Password Type set to PasswordText and the 'Add default wsa:To` option checked.

Am I missing something here or is this package not going to work the way I need it to? 🤔

Laravel 6, package version 1.5.1

Cheers, Matt

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (9 by maintainers)

Most upvoted comments

No problem thanks @CodeDredd - I will get around to testing it at some point and let you know how I get on! Been unable to find time to test just yet and my current implementation is working for current need so I’ll have to come back to it 👍

@clnt ok i finally took the time. I made a PR. Please look into it if it works with that. Added a new option for the Wsse Heaader:

        $client = Soap::baseWsdl('https://laravel-soap.wsdl')->withWsse([
            'userTokenName' => 'Test',
            'userTokenPassword' => 'passwordTest',
            'mustUnderstand' => false
        ])->withWsa();

you can look at the unit test if its now ok. It would be awesome if you could test it 😃