Why do I get SOAP-ERROR: Encoding: object has not 'tax', in wdsl with nested complextype?

0

I have to consume a SOAP web services with PHP and I get the title error.

The (partial) structure of the wsdl is as follows

<xs:element name="Obligations" type="tns:ObligationsType"/>
<xs:complexType name="ObligationsType">
<xs:sequence>

<xs:element maxOccurs="99" name="Taxes" type="tns:TaxesType"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="TaxesType">
<xs:sequence>
<xs:element name="tax">
<xs:simpleType>
<xs:restriction base="xs:int">
<xs:maxInclusive value="9999"/>
<xs:minInclusive value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="amount">
<xs:simpleType>
<xs:restriction base="xs:double">
<xs:minInclusive value="0.01"/>
<xs:maxInclusive value="9999999999.99"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>

The associative array that I send:

$params = array(
  'token' => $TOKEN,
  'sign' => $SIGN,
  'paymentEntity' => 1001,
  'form' => array(
      'formNumber' => 6042,
    'idPaymentType' => 951,
    'Obligations' => array (
      array( 
          'Taxes' => array(
          'tax' => 6041,
            'amount' => 602.0 
        )
      )
    )
  )             
);

With Classes

class Taxes{
  var $tax;
  var $amount;
}

class Obligations{
  var $Taxes;
}

class form{
  var $formNumber;
  var $idPaymentType;
  var $Obligations;
}

I tried to do it with classes and I get the same error. The problem is from the Obligations object. I tried nesting like this:

  

'Obligations' = > array ('Taxes' = > array ('tax' = > 1, 'amount' = > 1.0)) I get Unrecognized field Obligations

     

'Obligations' = > array ('tax' = > 1, 'amount' = > 1.0) I get object has not 'Taxes' property

     

'Obligations' = > array (array ('Taxes' = > array ('tax' = > 1, 'amount' = > 1.0))) I get object has no 'tax' property

     

'Obligations' = > array ('Taxes' = > array ('tax' = > 1)) I get object has not 'amount' property

     

'Obligations' = > array ('Taxes' = > array ('amount' = > 1)) I get object has not 'tax' property

I would appreciate any suggestions. Greetings

    
asked by Developer 02.08.2018 в 15:23
source

1 answer

0

try this structure in your array:

$params = [
    'token' =>  'eltoken',
    'sign'  =>  'sign',
    'paymentEntity' =>  1001,
    'form'  =>  [
        'formNumber'    =>  123456,
        'idPaymentType' =>  654,
        'Obligations'   =>  [
            [
                'Taxes'  => [
                    'TaxesType' =>  [
                        'tax'    => 6041,
                        'amount' => 602.0
                    ]
                ]
            ]
        ]
    ]
];

That's because I see that Taxes comes from TaxesType and then tax and amount

    
answered by 03.08.2018 в 20:04