SoapClient クラス
(PHP 5, PHP 7, PHP 8)
はじめに
SoapClient クラスは » SOAP 1.1、» SOAP 1.2 サーバー用のクライアントとなります。 WSDL モードあるいは non-WSDL モードで動作します。
クラス概要
プロパティ
- __default_headers
-
- __last_request
-
- __last_request_headers
-
- __last_response
-
- __last_response_headers
-
- __soap_fault
-
- _classmap
-
- _connection_timeout
-
-
- _digest
-
- _encoding
-
- _exceptions
-
- _features
-
- _keep_alive
-
- _login
-
- _password
-
- _proxy_host
-
- _proxy_login
-
- _proxy_password
-
- _proxy_port
-
- _soap_version
-
- _ssl_method
-
- _stream_context
-
- _use_digest
-
- _use_proxy
-
- _user_agent
-
- compression
-
- httpsocket
-
- httpurl
-
- location
-
- sdl
-
- style
-
- trace
-
- typemap
-
- uri
-
- use
-
目次
- SoapClient::__call — SOAP 関数をコールする (非推奨)
- SoapClient::__construct — SoapClient のコンストラクタ
- SoapClient::__doRequest — SOAP リクエストを実行する
- SoapClient::__getCookies — クッキーの一覧を取得する
- SoapClient::__getFunctions — SOAP 関数の一覧を返す
- SoapClient::__getLastRequest — 直近の SOAP リクエストを返す
- SoapClient::__getLastRequestHeaders — 直近の SOAP リクエストヘッダを返す
- SoapClient::__getLastResponse — 直近の SOAP レスポンスを返す
- SoapClient::__getLastResponseHeaders — 直近の SOAP レスポンスヘッダを返す
- SoapClient::__getTypes — SOAP 型の一覧を返す
- SoapClient::__setCookie — SOAP リクエストと共に送信されるクッキーを設定する
- SoapClient::__setLocation — 使用するウェブサービスの場所を設定する
- SoapClient::__setSoapHeaders — 以降のコール用の SOAP ヘッダを設定する
- SoapClient::__soapCall — SOAP 関数をコールする
+add a note
User Contributed Notes 9 notes
hugues at zonereseau dot com ¶
13 years ago
When you need to connect to services requiring to send extra header use this method.
Here how we can to it with PHP and SoapClient
<?php
class exampleChannelAdvisorAuth
{
public $DeveloperKey;
public $Password;
public function __construct($key, $pass)
{
$this->DeveloperKey = $key;
$this->Password = $pass;
}
}
$devKey = "";
$password = "";
$accountId = "";
// Create the SoapClient instance
$url = "";
$client = new SoapClient($url, array("trace" => 1, "exception" => 0));
// Create the header
$auth = new ChannelAdvisorAuth($devKey, $password);
$header = new SoapHeader("http://www.example.com/webservices/", "APICredentials", $auth, false);
// Call wsdl function
$result = $client->__soapCall("DeleteMarketplaceAd", array(
"DeleteMarketplaceAd" => array(
"accountID" => $accountId,
"marketplaceAdID" => "9938745" // The ads ID
)
), NULL, $header);
// Echo the result
echo "<pre>".print_r($result, true)."</pre>";
if($result->DeleteMarketplaceAdResult->Status == "Success")
{
echo "Item deleted!";
}
?>
Stefan ¶
10 years ago
There is a known bug with some versions of Xdebug which can cause SoapClient to not throw an exception but instead cause a fatal error.
Surround the SoapClient call with xdebug_disable(); and xdebug_enable(); to work around this problem.
For reference:
http://bugs.xdebug.org/view.php?id=249
https://bugs.php.net/bug.php?id=47584
info at nospam x valiton x com ¶
9 years ago
CAUTION:
I had quite a bit of trouble trying to make a request with fopen through a proxy to a secure url. I kept getting a 400 Bad Request back from the remote host. It was receiving the proxy url as the SNI host. In order to get around this I had to explicity set the SNI host to the domain I was trying to reach. It's apparently the issue outlined in this bug:
https://bugs.php.net/bug.php?id=63519
<?php
$domain = parse_url($file, PHP_URL_HOST);
$proxy_string = "tcp://" . WP_PROXY_HOST . ":" . WP_PROXY_PORT;
$opts = array(
'http' => array( 'proxy' => $proxy_string ),
'ssl' => array( 'SNI_enabled' => true, 'SNI_server_name' => $domain));
$context = stream_context_create($opts);
$handle = fopen( $file, 'r', false, $context );
?>
src:
http://php.net/manual/en/context.http.php#114314