Bonjour à tous,

J'essais de faire un call soap avec soapclient ça fonctionne avec curl mais pas avec le SoapClient

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 $context = stream_context_create([
                'ssl' => [
                    // set some SSL/TLS specific options
                    'verify_peer' => false,
                    'verify_peer_name' => false,
                    'allow_self_signed' => true
                ]
            ]);
        $this->client = new SoapClient($this->wsdlUrl,  array(
            'keep_alive' => false,
            "stream_context" => $context
         ));
 
        $header = new SoapHeader(
            'http://tempuri.org/',
            'Content-Type',
            'text/xml',
        );
        $this->client->__setSoapHeaders($header);
        dd($this->client->__soapCall('HelloWorld', []));
// fonctionne pas
        $xml_post_string = '<?xml version="1.0" encoding="utf-8"?>
        <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
            <soap12:Body>
            <HelloWorld xmlns="http://tempuri.org/" />
            </soap12:Body>
        </soap12:Envelope>';
        $headers = array(
        "Content-type: text/xml;charset=\"utf-8\"",
        // "Accept: text/xml",
        "Cache-Control: no-cache",
        "Pragma: no-cache",
        ); 
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
        curl_setopt($ch, CURLOPT_URL, $this->wsdlUrl);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); 
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
 
        $response = curl_exec($ch);
        curl_close($ch);
        dd($response);
//fonctionne
Qu'est-ce que j'ai oublié s'il vous plaît?