我運行下面的代碼:並行的多個SOAP請求/連接?
<?php
$i=0;
// connection credentials and settings
$location = 'https://url.com/';
$wsdl = $location.'?wsdl';
$username = 'user';
$password = 'pass';
// create client resource - connection
$client = new Client($location, $wsdl, $username, $password);
// do stuff
while($i<10)
{
$client-‐>doStuff();
echo $client‐>response();
$i++;
}
?>
另外:
<?php
public function doStuff() {
$this->response = $this->srv()->doStuff(array('stuff' => $this->get('stuff')));
return $this;
}
public function __construct($location, $wsdl, $username, $password, $proxyHost = NULL, $proxyPort = NULL) {
if(is_null($proxyHost) || is_null($proxyPort)) $connection = new SoapClient($wsdl, array('login' => $username, 'password' => $password));
else $connection = new SoapClient($wsdl, array('login' => $username, 'password' => $password, 'proxy_host' => $proxyHost, 'proxy_port' => $proxyPort));
$connection->__setLocation($location);
$this->connection = $connection;
return $this->connection;
}
public function srv() {
return $this->connection;
}
?>
我想改變這種運行多個連接,可能並行,雖然我不是用肥皂瞭解不夠熟悉如何去做這件事。
ie:它運行$ client - > doStuff();在循環中,我希望它在另一個完成之前運行下一個迭代的另一個資源/連接。
任何想法?謝謝
我會研究多線程:http://stackoverflow.com/questions/70855/how-can-one-use-multi-threading-in-php-applications – 2011-02-09 15:04:27
@Phill Pafford:謝謝!看起來像我以後,但不知道如何調整上述來完成示例[link](http://phplens.com/phpeverywhere/?q=node/view/254)中顯示的內容,因爲它使用fsock 。任何使用SOAP的建議或例子?再次感謝你。 – jeremycollins 2011-02-09 15:10:10