将旧的NuSoap代码转换为PHP核心soap功能

时间:2010-04-09 14:00:58

标签: php codeigniter soap nusoap

我一直在使用codeIgniter(PHP Framework)测试nuSoap但似乎nuSoap不准备使用最新的php 5.3,即使我为php 5.3下载了修补的nusoap版本

我有以下代码:

require_once(APPPATH.'libraries/NuSOAP/lib/nusoap'.EXT); //includes nusoap
$n_params = array('CityName' => 'San Juan', 'CountryName' => 'Argentina');
$client = new nusoap_client('http://www.webservicex.net/globalweather.asmx?WSDL');
$client->setHTTPProxy("10.2.0.1",6588,"","");
$result = $client->call('GetWeather', $n_params);

您能帮助我将这些功能转换为PHP soap功能吗?包括代理功能?

2 个答案:

答案 0 :(得分:2)

require_once(APPPATH.'libraries/NuSOAP/lib/nusoap'.EXT); //includes nusoap
$n_params = array('CityName' => 'San Juan', 'CountryName' => 'Argentina');
$client = new nusoap_client('http://www.webservicex.net/globalweather.asmx?WSDL');
$client->setHTTPProxy("10.2.0.1",6588,"","");
$result = $client->call('GetWeather', $n_params);

变为

$url = 'http://www.webservicex.net/globalweather.asmx?WSDL';
$params = array(
    'proxy_host' => '10.2.0.1',
    'proxy_port' => '6588'
    );
$client = new SoapClient($url, $params);
$client->__soapCall('GetWeather', $n_params);

答案 1 :(得分:-1)

以下代码是调用上述Web服务的正确方法。我刚刚修改了$ ser_params数组。现在它有一个子数组

$url = 'http://www.webservicex.net/globalweather.asmx?WSDL';
$conn_params = array(
'proxy_host' => '10.2.0.1',
'proxy_port' => '6588'
);

$ser_params = array (
'GetWeather' => array (
"CityName" => "San Juan",
"CountryName" => "Argentina"
)
);

$client = new SoapClient($url, $conn_params);
$result = $client->__soapCall('GetWeather', $ser_params);
print_r ($result);