note 129542 added to soapclient.construct

From: Date: Thu, 06 Jun 2024 09:21:21 +0000
Subject: note 129542 added to soapclient.construct
Groups: php.notes 
Request: Send a blank email to php-notes+get-221347@lists.php.net to get a copy of this message
Two notes about the steam_context option: 1- In the example of the documentation, it says: <?php $client = new SoapClient("some.wsdl", ['context' => $context]); ?> This is wrong. As it is stated in the parameters list, it must be "stream_context" and NOT "context". 2- The HTTP Context manual here: https://www.php.net/manual/en/context.http.php It says header can either be of type array or string. This is also wrong. It may not necessarily be optional because it might depend on your PHP compile time configuration. If your instance is compiled --with-curlwrappers option, you should use array type for header in the HTTP context and if not; you should use a string separated by new line (\n) for the header. I am not sure if SoapClient respects curl_wrappers option because although it is enabled in my instance and although I am using arrays for the headers to create HTTP context for non-Soap operations; SoapClient required me to use a string. It otherwise just dropped the stream_context altogether. So with SoapClient, you better use a string for the HTTP header like: <?php $context = stream_context_create(array( 'http' => array( 'user_agent' => 'My App', 'header' => "Custom-Header: Value\n" . "Another Header: Surprise" ) )); $client = new SoapClient('some.wsdl', ['stream_context' => $context]); ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 46.1.2.249) ---- Manual Page -- https://php.net/manual/en/soapclient.construct.php Edit -- https://main.php.net/note/edit/129542 Del: integrated -- https://main.php.net/note/delete/129542/integrated Del: useless -- https://main.php.net/note/delete/129542/useless Del: bad code -- https://main.php.net/note/delete/129542/bad+code Del: spam -- https://main.php.net/note/delete/129542/spam Del: non-english -- https://main.php.net/note/delete/129542/non-english Del: in docs -- https://main.php.net/note/delete/129542/in+docs Del: other reasons-- https://main.php.net/note/delete/129542 Reject -- https://main.php.net/note/reject/129542 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221347) next »