PHP.mk документација

SoapClient

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

class.soapclient.php PHP.net прокси Преводот е вчитан
Оригинал на PHP.net
Патека class.soapclient.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + преведен приказ Кодовите, табелите и белешките остануваат читливи во истиот тек.
SoapClient

Референца за `class.soapclient.php` со подобрена типографија и навигација.

class.soapclient.php

На SoapClient class

класата mysqli_driver

Вовед

Класата SoapClient обезбедува клиент за SOAP екстензијата може да се користи за пишување SOAP сервери и клиенти. Поддржува подмножества на, » SOAP 1.1 сервери. Може да се користи во WSDL или non-WSDL режим.

Синопсис на класата

class SoapClient {
/* Својства */
private ?string $uri (PHP 7, PHP 8);
private ?int $style (PHP 7, PHP 8);
private ?int $use (PHP 7, PHP 8);
private ?string $location (PHP 7, PHP 8);
private bool $trace = лажно;
private ?int $compression (PHP 7, PHP 8);
private ?resource $sdl (PHP 7, PHP 8);
private ?resource $typemap (PHP 7, PHP 8);
private ?resource $httpsocket (PHP 7, PHP 8);
private ?resource $httpurl (PHP 7, PHP 8);
private ?string $_login (PHP 7, PHP 8);
private ?string $_password (PHP 7, PHP 8);
private bool $_use_digest = лажно;
private ?string $_digest (PHP 7, PHP 8);
private ?string $_proxy_host (PHP 7, PHP 8);
private ?int $_proxy_port (PHP 7, PHP 8);
private ?string $_proxy_login (PHP 7, PHP 8);
private ?string $_proxy_password (PHP 7, PHP 8);
private bool $_exceptions = точно;
private ?string $_encoding (PHP 7, PHP 8);
private ?array $_classmap (PHP 7, PHP 8);
private ?int $_features (PHP 7, PHP 8);
private ?resource $_stream_context (PHP 7, PHP 8);
private ?string $_user_agent (PHP 7, PHP 8);
private bool $_keep_alive = точно;
private ?int $_ssl_method (PHP 7, PHP 8);
private ?int $_use_proxy (PHP 7, PHP 8);
private array $_cookies = [];
private ?array $__default_headers (PHP 7, PHP 8);
private ?SoapFault $__soap_fault (PHP 7, PHP 8);
private ?string $__last_request (PHP 7, PHP 8);
private ?string $__last_response (PHP 7, PHP 8);
private ?string $__last_request_headers (PHP 7, PHP 8);
private ?string $__last_response_headers (PHP 7, PHP 8);
/* Методи */
public __construct(?string $wsdl, array $options = [])
public __call(string $name, array $args): mixed
public __doRequest(
         string $request,
         string $location,
         string $action,
         int $version,
         bool $oneWay = false,
         ?string $uriParserClass = null
): ?string
public __getTypes(): ?array
public __setCookie(string $name, ?string $value = null): void
public __setLocation(?string $location = null): ?string
public __soapCall(
         string $name,
         array $args,
         ?array $options = null,
         SoapHeader|array|null $inputHeaders = null,
         array &$outputHeaders = null
): mixed
}

Својства

__default_headers

__last_request

__last_request_headers

__last_response

__last_response_headers

__soap_fault

_classmap

_connection_timeout

_cookies

_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

Содржина

Белешки од корисници 9 белешки

hugues на zonereseau точка com
пред 15 години
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!";
}
?>
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
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.