1

I use php to get data from webservice. I have this code:

try 
{ 
    $wsdl_url = 'https://xxx';
    $client = new SOAPClient($wsdl_url); 
    $params = array(
        'Code' => '1111', 
        'Name' => 'Marcos', 
        'Client' => '009462'
    );
    $return = $client->GetData($params); 

    print_r($return); 
} 
catch (Exception $e) 
{ 
    echo "Exception occured: " . $e;
}

Now, i have an xml with parameters. Example:

<san:GetData>
<san:objData xsi:type="PricesData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://">
    <san:Code>7</san:Code>
    <san:Client>999999</san:Client>

    <san:Data>
        <san:Fact>CF</san:Fact>
        <san:Fact2>CF</san:Fact2>
    </san:Data>
    <san:DataProduct>
        <san:Code>0202</san:Code>
        <san:PersonalData>
          <san:Name>00030</san:Name>
          <san:Company>00045</san:Company>
        </san:PersonalData>
    </san:DataProduct>
</san:objData>

how I can do to pass those parameters for php array? because it has data into "categories" and i don't know how to manipulate them.

Thanks.

wanheda
  • 81
  • 1
  • 9
  • If I understand correctly, those XML is Web Service response. SOAPClient should have converted this into proper PHP types according to WSDL. – Alex Paliarush Nov 13 '15 at 14:37
  • I need to know how to pass parameters have to be within the categories. one below the other?. Example: $params = array( 'Code' => '1111', 'Cliente' => 'Marcos', 'Fact' => '009462', 'Fact2' => '009462', 'Code' => '009462' ); The last code is in DataProduct. How I send? – wanheda Nov 13 '15 at 15:03
  • I have to send the values to the web service to get the answer. – wanheda Nov 13 '15 at 15:05
  • This might help http://stackoverflow.com/a/15981533/5554254 – Alex Paliarush Nov 13 '15 at 15:42
  • Perfect, it would be an array into another array. Thanks!, I'll try. – wanheda Nov 13 '15 at 15:45
  • @user1110238 Please accept my answer below if it was helpful to you. – Alex Paliarush Nov 16 '15 at 13:05

1 Answers1

0

To represent an array in SOAP request, an indexed array of nested associative arrays should be used as input for SOAPClient. Array keys should correspond to elements names declared in WSDL. See examples in this post.

Community
  • 1
  • 1
Alex Paliarush
  • 337
  • 4
  • 6