牛牛在线工具

SoapClient::__doRequest()

收录 8868 个 PHP 函数,含用途说明与用法示例。

SoapClient::__doRequest()

执行SOAP请求

函数名:SoapClient::__doRequest() 适用版本:PHP 5, PHP 7 用法: SoapClient::__doRequest(string $request, string $location, string $action, int $version [, int $one_way = 0]) 参数: $request:包含要发送的SOAP请求的字符串。 $location:SOAP服务器的URL。 $action:SOAP操作的操作标头。 $version:SOAP协议版本(1表示SOAP 1.1,2表示SOAP 1.2)。 $one_way(可选):如果设置为1,则该方法将不会等待服务器的响应。 返回值: 返回包含服务器响应的字符串。 示例: $wsdl = 'http://example.com/soap.wsdl'; $options = array( 'trace' => true, 'exceptions' => true, 'cache_wsdl' => WSDL_CACHE_NONE ); $client = new SoapClient($wsdl, $options); $request = '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <getWeather> <city>London</city> </getWeather> </soap:Body> </soap:Envelope>'; $location = 'http://example.com/soap-server.php'; $action = 'http://example.com/soap-action'; $response = $client->__doRequest($request, $location, $action, SOAP_1_2); echo $response; 上述示例中,我们首先创建了一个SoapClient对象,并指定了相关的选项。然后,我们定义了要发送的SOAP请求的XML字符串,并将SOAP服务器的URL、SOAP操作的操作标头和SOAP协议版本传递给__doRequest()方法。最后,我们通过echo语句输出服务器的响应。