简体   繁体   中英

Laravel SOAP request call

I'm looking to get access to a specific API (found here: https://jigsaw.w3.org/css-validator/manual.html#api ), however this is a SOAP api and I've never worked with SOAP. So I install this package: https://codedredd.github.io/laravel-soap/ and I try a test call. It looks like this:

    $response = Soap::baseWsdl('https://jigsaw.w3.org/css-validator/validator')
        ->call('validator', [
            'text' => $text,
            'lang' => 'en',
        ]);

    
    
    dd($response);
    

however I already know this is going to fail because I have no idea what to put into the ->call('')

and as expected I get the response:

#response: GuzzleHttp\Psr7\Response {#1715 -reasonPhrase: "Bad Request"

Help?

According to the documentation you provided. https://jigsaw.w3.org/css-validator/manual.html#api

You have to set the output to either 'application/soap+xml' or 'soap12'

$response = Soap::baseWsdl('https://www.w3.org/2005/09/css-validator.wsdl')
    ->call('validator', [
        'uri' => $text,
        'lang' => 'en',
        'output' => 'application/soap+xml'
    ]);


dd($response);

Answer: This is not a SOAP API. That's embarrassing. The title of the documentation was "CSS Validator Web Service API SOAP 1.2" so I had assumed it was going to be a SOAP API. But no, the SOAP part is just a reference to returning XML.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM