1

I have to send this XML with SoapClient:

<xml>
  <field>
    <subfield1>value</subfield1>
    <subfield2>value</subfield2>
  </field>
  <field>
    <subfield1>value</subfield1>
    <subfield2>value</subfield2>
  </field>
</xml>

So I created this PHP array:

$params = [
  'field' => [
    ['subfield1' => 'value', 'subfield2' => 'value']
    ['subfield1' => 'value', 'subfield2' => 'value']
  ]
]

// ...
$client = new SoapClient($wsdl, $config);
$client->method($params);

But I don't understand why I get the following error:

SOAP-ERROR: Encoding: object has no 'subfield1' property

For information, the WSDL contains that following:

<xs:sequence>
<xs:element name="field" type="tns:field" minOccurs="0" />
</xs:sequence>

<xs:complexType name="field">
<xs:sequence>
<xs:element name="subfield1" type="xs:string" />
<xs:element name="subfield2" type="xs:string" />
</xs:sequence>
</xs:complexType>

I already checked the issue SoapClient: how to pass multiple elements with same name? but it didn't help me.

nemenems
  • 1,064
  • 2
  • 9
  • 27
  • What about using SoapVar ? https://stackoverflow.com/questions/37207403/getting-the-xml-as-string-for-a-soapvar-variable-without-a-webservice-locally – nemenems Aug 29 '19 at 15:52

0 Answers0