与 PHP 和 SOAP 的同步连接? [英] Simaltaneous connections with PHP and SOAP?

查看:41
本文介绍了与 PHP 和 SOAP 的同步连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用 SOAP 并了解它的最基础知识.

我创建了一个客户端资源/连接,然后在循环中运行一些查询,我就完成了.我遇到的问题是当我增加循环的迭代次数时,即:从 100 到 1000,它似乎耗尽内存并丢弃内部服务器错误.

我怎么可能运行 a) 多个并发连接或 b) 创建一个连接、100 次迭代、关闭连接、创建连接......等等
"a)" 看起来是更好的选择,但我不知道如何启动和运行它,同时将内存(我假设打开和关闭连接)保持在最低限度.

提前致谢!

<块引用>

index.php

<块引用>

class_console.php

 $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;返回 $this->connection;}/*** 将任何类型的数据打印到屏幕上,print_r 支持** @param $var - 要打印到屏幕的数据* @return $this->connection - 连接资源**/公共功能屏幕($var){打印<预>";打印_r($var);打印 '</pre>';返回 $this->connection;}/*** 返回一个服务器/连接资源** @return $this->connection - 连接资源*/公共函数 srv() {返回 $this->connection;}}?>

解决方案

好吧,PHP 中的 SOAP 有点问题.

关于您的问题:是的,SOAP 接受同时连接.你相信内存不足".我认为主要问题是每秒 HTTP 响应.

你能把你的 apache 错误日志放在这里吗?- 假设您在您的环境中同时使用 PHP 和 Apache.

无论如何,我给您的建议是:如果可以,请使用 REST!

I'm new to using SOAP and understanding the utmost basics of it.

I create a client resource/connection, I then run some queries in a loop and I'm done. The issue I am having is when I increase the iterations of the loop, ie: from 100 to 1000, it seems to run out of memory and drops an internal server error.

How could I possibly run either a) multiple simaltaneous connections or b) create a connection, 100 iterations, close connection, create connection.. etc.
"a)" looks to be the better option but I have no clue as to how to get it up and running whilst keeping memory (I assume opening and closing connections) at a minimum.

Thanks in advance!

index.php

<?php
// set loops to 0
$loops = 0;

// connection credentials and settings
$location = 'https://theconsole.com/';
$wsdl = $location.'?wsdl';
$username = 'user';
$password = 'pass';

// include the console and client classes
include "class_console.php";
include "class_client.php";

// create a client resource / connection
$client = new Client($location, $wsdl, $username, $password);

while ($loops <= 100)   
    {
    $dostuff;
    }
?>

class_console.php

<?php
class Console {
// the connection resource
private $connection = NULL;

/**
* When this object is instantiated a connection will be made to the console
*/
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;
}

/**
* Will print any type of data to screen, where supported by print_r
*
* @param $var - The data to print to screen
* @return $this->connection - The connection resource
**/
public function screen($var) {
print '<pre>';
print_r($var);
print '</pre>';
return $this->connection;
}

/**
* Returns a server / connection resource
*
* @return $this->connection - The connection resource
*/
public function srv() {
return $this->connection;
}

}
?>

解决方案

Well, SOAP in PHP is a little problematic.

About your question: yes, SOAP accept simultaneous connections. You believe in a "out of memory". I believe that the major problem is around HTTP responses/per second.

Can you put here your apache error log ? - assuming that you uses PHP and Apache together in your environment.

Anyway, my advice for you is: use REST if you can !

这篇关于与 PHP 和 SOAP 的同步连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆