Am trying to call an API. The XML I needed is follows.
我试图调用API。我需要的XML如下。
<SOAP-ENV:Envelope xmlns:ns1="http://www.webserviceX.NET/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<ns1:ConversionRate/>
<param1>
<MessageTitle>Some Title</MessageTitle>
<Images>
<Image>http://3.bp.blogspot.com/-gzGWCfqJr_k/T-B7L0wlwSI/AAAAAAAADkw/C7sznAKVktc/s1600/rose_flower_screensaver-234027-1240456558.jpeg</Image>
<Image>http://img.ehowcdn.com/article-new-thumbnail/ehow/images/a07/tv/vu/object-property-names-array-php-800x800.jpg</Image>
</Images>
</param1>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I want to pass multiple images in tags. But I can only pass only one item. In php multi dimentional array doesnot support same key. My php code
我想在标签中传递多个图像。但我只能传递一个项目。在php中,多维数组不支持相同的键。我的PHP代码
$client = new SoapClient('http://www.webservicex.com/CurrencyConvertor.asmx?wsdl', array( 'trace' => true, 'exceptions' => true,'soap_version' => SOAP_1_1 ) );
try {
$data_params = new stdClass();
$imgs = new stdClass();
$img1 = 'http://3.bp.blogspot.com/-gzGWCfqJr_k/T-B7L0wlwSI/AAAAAAAADkw/C7sznAKVktc/s1600/rose_flower_screensaver-234027-1240456558.jpeg';
$img2 = 'http://img.ehowcdn.com/article-new-thumbnail/ehow/images/a07/tv/vu/object-property-names-array-php-800x800.jpg';
$imgs->Image = $img1;
$data_params->MessageTitle = 'Some Title';
$data_params->Images = $imgs;
$params = array( 'Id' => '187',
'Data'=>$data_params);
$result = $client->__soapCall('ConversionRate',$params);
echo $client->__getLastRequest();
}catch(SoapFault $exception)
{
var_dump($exception);
echo $client->__getLastRequest();
}
2 个解决方案
#1
0
try some thing like
尝试一些类似的事情
<Images>
<Image>
<item>your Image<item>
</Image>
<Image>
<item>your 2nd Image<item>
</Image>
</Images>
#2
0
You must absolutely have confused something, the CurrencyConvertor webservice ConversionRate method in question works just fine and does not have any duplicate parameter names, only duplicate types, but those are strings - and not image URLs.
你必须完全混淆一些东西,有问题的CurrencyConvertor webservice ConversionRate方法工作得很好,没有任何重复的参数名称,只有重复的类型,但那些是字符串 - 而不是图像URL。
Here is the output of the working code (ConversionRate from EUR to USD):
以下是工作代码的输出(ConversionRate从EUR到USD):
class stdClass#2 (1) {
public $ConversionRateResult =>
double(1.3488)
}
Here is the working code:
这是工作代码:
<?php
/**
* Multiple Nodes with same Name in SOAP Call
* @link http://*.com/q/19727338/367456
*/
$wsdl = 'http://www.webservicex.com/CurrencyConvertor.asmx?wsdl';
$options = array(
'trace' => true,
'exceptions' => true,
'soap_version' => SOAP_1_1,
);
$client = new SoapClient($wsdl, $options);
$params = array(
'FromCurrency' => 'EUR',
'ToCurrency' => 'USD',
);
var_dump(
$client->ConversionRate($params)
);
#1
0
try some thing like
尝试一些类似的事情
<Images>
<Image>
<item>your Image<item>
</Image>
<Image>
<item>your 2nd Image<item>
</Image>
</Images>
#2
0
You must absolutely have confused something, the CurrencyConvertor webservice ConversionRate method in question works just fine and does not have any duplicate parameter names, only duplicate types, but those are strings - and not image URLs.
你必须完全混淆一些东西,有问题的CurrencyConvertor webservice ConversionRate方法工作得很好,没有任何重复的参数名称,只有重复的类型,但那些是字符串 - 而不是图像URL。
Here is the output of the working code (ConversionRate from EUR to USD):
以下是工作代码的输出(ConversionRate从EUR到USD):
class stdClass#2 (1) {
public $ConversionRateResult =>
double(1.3488)
}
Here is the working code:
这是工作代码:
<?php
/**
* Multiple Nodes with same Name in SOAP Call
* @link http://*.com/q/19727338/367456
*/
$wsdl = 'http://www.webservicex.com/CurrencyConvertor.asmx?wsdl';
$options = array(
'trace' => true,
'exceptions' => true,
'soap_version' => SOAP_1_1,
);
$client = new SoapClient($wsdl, $options);
$params = array(
'FromCurrency' => 'EUR',
'ToCurrency' => 'USD',
);
var_dump(
$client->ConversionRate($params)
);