Page 1 of 1

How do you pass array to web service using nuSOAP?

Posted: Tue Sep 25, 2007 10:01 pm
by mrloofer
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I'm completely stumped on this. I am trying to connect to a .NET web service that accepts the following parameters:

[syntax="xml"]
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Send xmlns="http://www.group2call.com/messagecenter/webservice/SendMessage">
      <sAccount>string</sAccount>
      <sPin>string</sPin>
      <sGroup>string</sGroup>
      <sPhone>
        <string>string</string>
        <string>string</string>
      </sPhone>
      <sType>string</sType>
      <iVoice>int</iVoice>
      <sMessage>string</sMessage>
    </Send>
  </soap:Body>
</soap:Envelope>
sPhone is type="tns:ArrayOfString"

My PHP code:[/syntax]

Code: Select all

$client = new SoapClient($this->wsdlADMServer,'wsdl','','','','');
			$param = array('sAccount' => $this->g2cACCOUNT,
				        'sPin' => $this->g2cPIN,
				        'sPhone' => ??????????,
					'sMessage' => 'hello',
					'iVoice' => 1,
					'sType' => 'SMS');
			$result = $client->call('Send', array('parameters' => $param), '', '', false, true);
sPhone accepts multiple phone numbers, how do I pass an array of numbers to this parameter?

Thanks.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Sep 26, 2007 8:17 am
by jeffery
have you tried:

Code: Select all

$client = new SoapClient($this->wsdlADMServer,'wsdl','','','','');
                        $param = array('sAccount' => $this->g2cACCOUNT,
                                        'sPin' => $this->g2cPIN,
                                        'sPhone' => array('key' => 'value'),
                                        'sMessage' => 'hello',
                                        'iVoice' => 1,
                                        'sType' => 'SMS');
                        $result = $client->call('Send', array('parameters' => $param), '', '', false, true); 

Posted: Wed Sep 26, 2007 10:28 am
by mrloofer
I take it 'Key' is "string" in this case? per WSDL:

<sPhone>
<string>string</string>
<string>string</string>
</sPhone>

I tried what you said and the following worked in passing the first number but the 2nd number waa not picked up by the web service:

Code: Select all

$client = new SoapClient($this->wsdlADMServer,'wsdl','','','','');
			$param = array('sAccount' => $this->g2cACCOUNT,
				        'sPin' => $this->g2cPIN,
				        'sPhone' => array('string' => '5611231234','string' => '5614567890'),
					'sMessage' => 'hello',
					'iVoice' => 1,
					'sType' => 'SMS');
			$result = $client->call('Send', array('parameters' => $param), '', '', false, true);
We're pretty close though. Thanks!

Posted: Wed Sep 26, 2007 11:25 am
by volka
array('string' => '5611231234','string' => '5614567890')
The second entry with the same name overrides the first.

Code: Select all

var_dump(array('string' => '5611231234','string' => '5614567890'));
array(1) {
["string"]=>
string(10) "5614567890"
}
I'd try without a key

Code: Select all

'sPhone' => array('5611231234','5614567890')

Posted: Thu Sep 27, 2007 7:25 pm
by mrloofer
Nope, trying it without the key results in nothing at all. This is sooo weird!

Posted: Thu Sep 27, 2007 9:32 pm
by jeffery
have you got the call to SoapClient correct?

Code: Select all

$client = new SoapClient($this->wsdlADMServer,'wsdl','','','',''); 
documentation says the second parameter is an array()

http://php.net/manual/en/function.soap- ... struct.php

Posted: Mon Oct 01, 2007 9:28 am
by mrloofer
I've tried $client = new SoapClient($this->wsdlADMServer,true); and I get the same response.

Posted: Mon Oct 01, 2007 5:06 pm
by jeffery
mrloofer read the documentation properly. I have provided a link above.

Posted: Thu Oct 04, 2007 9:00 am
by mrloofer
Thanks for the link. I tried all combinations of setting the soapclient but I keep getting the same result.

Posted: Fri Oct 05, 2007 5:20 am
by jeffery
without showing us what your latest example code is, it is hard to analyse what is wrong.