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!";
}
?>
PHP.mk документација
SoapClient
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
Патека
class.soapclient.php
Локална патека за оваа страница.
Извор
php.net/manual/en
Оригиналниот HTML се реупотребува и локално се стилизира.
Режим
Прокси + преведен приказ
Кодовите, табелите и белешките остануваат читливи во истиот тек.
Референца
class.soapclient.php
SoapClient
Референца за `class.soapclient.php` со подобрена типографија и навигација.
На SoapClient class
класата mysqli_driver
Вовед
Класата SoapClient обезбедува клиент за SOAP екстензијата може да се користи за пишување SOAP сервери и клиенти. Поддржува подмножества на, » SOAP 1.1 сервери. Може да се користи во 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 — Повикува SOAP функција (застарена)
- SoapClient::__doRequest — SoapClient конструктор
- SoapClient::__getCookies — Извршува SOAP барање
- SoapClient::__getFunctions — Добива листа на колачиња
- SoapClient::__getLastRequest — Враќа листа на достапни SOAP функции
- SoapClient::__getLastRequestHeaders — Враќа последното SOAP барање
- SoapClient::__getLastResponse — Враќа SOAP заглавја од последното барање
- SoapClient::__getLastResponseHeaders — Враќа последен SOAP одговор
- SoapClient::__getTypes — Враќа SOAP заглавја од последниот одговор
- SoapClient::__setCookie — Враќа листа на SOAP типови
- SoapClient::__setLocation — Дефинира колаче за SOAP барања
- SoapClient::__setSoapHeaders — Поставува локација на веб-сервисот што треба да се користи
- SoapClient::__soapCall — Поставува SOAP заглавја за последователни повици
Белешки од корисници 9 белешки
hugues на zonereseau точка com ¶
пред 15 години
spam на kacke точка de ¶
3 години пред
In case a soap response returns nodes with the attribute xsi:nil="false", they are currently not processed by php-soapclient.
This seems to be a bug (not correct).
Workaround:
class mySoapClient extends SoapClient {
public function __doRequest($request, $location, $action, $version, $one_way = 0) {
$response = parent::__doRequest($request, $location, $action, $version, $one_way);
$response = str_replace('xsi:nil="false"',"",$response);
return $response;
}
}
Took me a day. Hope it can help
Toppi
info на nospam x valiton x com ¶
пред 10 години
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
Стефан ¶
пред 11 години
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
Рикардо Педрасани ¶
пред 9 години
If the XML have identities with same name in different levels there is a solution. You don´t have to ever submit a raw XML (this PHP SOAP object don´t allows send a RAW XML), so you have to always translate your XML to a array, like the example below:
$originalXML = "
<xml>
<firstClient>
<name>someone</name>
<adress>R. 1001</adress>
</firstClient>
<secondClient>
<name>another one</name>
<adress></adress>
</secondClient>
</xml>"
//Translate the XML above in a array, like PHP SOAP function requires
$myParams = array('firstClient' => array('name' => 'someone',
'adress' => 'R. 1001'),
'secondClient' => array('name' => 'another one',
'adress' => ''));
$webService = new SoapClient($someURL);
$result = $webService->someWebServiceFunction($myParams);
peter точка hansen на fastit точка net ¶
пред 16 години
When you get errors like:
"Fatal error: Uncaught SoapFault exception: [HTTP] Error Fetching http headers in"
after a few (time intensive) SOAP-Calls, check your webserver-config.
Sometimes the webservers "KeepAlive"-Setting tends to result in this error. For SOAP-Environments I recommend you to disable KeepAlive.
Hint: It might be tricky to create a dedicated vhost for your SOAP-Gateways and disable keepalive just for this vhost because for normal webpages Keepalive is a nice speed-boost.
acopantepuy на gmail точка com ¶
пред 10 години
when they want to pass variables into the http header that is how it is done:
<?php
$aHTTP['http']['header'] = "User-Agent: PHP-SOAP/5.5.11\r\n";
$aHTTP['http']['header'].= "username: XXXXXXXXXXX\r\n"."password: XXXXX\r\n";
$context = stream_context_create($aHTTP);
$client=new SoapClient("https://ocppws-cert.extra.bcv.org.ve:443/AltoValor/BancoUniversal?WSDL",array('trace' => 1,"stream_context" => $context));
$result = $client->jornadaActiva();
var_dump($result);
?>
jjlopez ¶
пред 15 години
If you are making soap calls in WSDL mode , and the address of your web service includes a port different from 80 (like http://my_ip_address:8080//service.asmx?wsdl), the WSDL file is fetched correctly, but all subsequent requests are made without any port in the host field. This causes a SoapFault exception when trying to call any of the service’s methods.
You need to redefine the soapClient class and force the port in each call.
See this example:
http://www.victorstanciu.ro/php-soapclient-port-bug-workaround/
mcinantyspam на fejm точка pl ¶
пред 9 години
Please note, that if you provide values that contain illegal xml characters (ASCII codes 0-8, 11-12, 14-15 - or x0-x8, xB-xC, xE-xF in hex), php's SoapClient will do send them in request, although such request is improper because it does not meet XML 1.0 requirements.
You always have to replace or remove these characters in your data before supplying them to SoapClient