Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

How to send "int" array

Help
severum
2012-11-05
2013-06-06
  • severum
    severum
    2012-11-05

    How to send "int" array

    $params = array(
        'countryId' => 119,
        'towns' => array(24, 172),
    );
    ...
    $client->setHeaders( $header );
    ...
    $response = $client->call("GetSomething", $params );
    xmlprint($client->request);
    

    part of the request:

    ...
    <GetSomething xmlns="urn:SomeName:Contracts:Soap11Gate:v1">
        <countryId>119</countryId>
        <towns/>
    </GetSomething>
    ...
    

    I need to get something like that:

    ...
    <GetSomething xmlns="urn:SomeName:Contracts:Soap11Gate:v1"> 
      <countryId>119</countryId> 
      <towns> 
        <int xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">24</int> 
        <int xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">172</int> 
      </towns> 
    </GetSomething>
    ...
    
     
  • severum
    severum
    2012-11-12

    Finally, I did

    1. patch PHP Warning, nusoap.php on line 4694
    from
    $this->schemas->imports = true;
    to
    $list2 = true;

    2. hack  ArrayOfint, nusoap.php on line 6059

    ...
    if (is_object($value)) {
        $value = get_object_vars($value);
    }
    if (is_array($value)) {
        //hack 
        if (isset($uqType) && $uqType=="ArrayOfint" && isset($value) && is_array($value) )
        {
            $xml = "<$elementName>";
            foreach ($value as $id => $val) {
                $xml .= "<int xmlns=\"".$ns."\">".$val."</int>";
            }
            $xml .= "</$elementName>";
            return $xml;
        }
        //hack end
        
        $elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
    ...