SoapClient PHP application/soap+xml;-ThrowExceptions

Exception or error:

How to set the content type so that the following code does not return an error:

Cannot process the message because the content type ‘application/soap+xml; charset=utf-8; action=”http://webservice.comarchedi.com/ComarchEdiWebService/SubscriptionGet”‘ was not the expected type ‘text/xml; charset=utf-8’.

    $url = 'https://edi.edoc-online.com/EdiWebService/EdiWebService.svc?wsdl';

    $stream_context_opts = [
        'http' => [
            'method' => 'GET',
            'header' => 'application/soap+xml; charset=utf-8'
        ]
    ];

    $soap_stream_context = stream_context_create($stream_context_opts);

    try {
        $client = new SoapClient($url, [
            'soap_version' => SOAP_1_2,
            'trace' => true,
            'encoding' => 'UTF-8',
            'stream_context' => $soap_stream_context
        ]);

        debug($client->__getFunctions());

        debug($client->SubscriptionGet($login, $password));
    } catch (\Exception $ex) {
        echo $ex->getMessage();
    }
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *