Reputation: 2495
I'm picking up an old project that uses SOAP and WSDL, something that I'm not too familiar with. I have the following data structure defined in the WSDL (simplified in this example):
<s:complexType name="RequestPayment">
<s:sequence>
<s:element minOccurs="0" name="ProviderData" type="s0:ArrayOfFieldPairOfNameString"/>
</s:sequence>
<s:attribute name="CancelURL" type="s:string"/>
<s:attribute name="ReturnURL" type="s:string"/>
</s:complexType>
<s:complexType name="ArrayOfFieldPairOfNameString">
<s:sequence>
<s:element maxOccurs="unbounded" minOccurs="0" name="Field" nillable="true" type="s0:PairOfNameString"/>
</s:sequence>
</s:complexType>
<s:complexType name="PairOfNameString">
<s:simpleContent>
<s:extension base="s:string">
<s:attribute name="Name" type="s:string" use="required"/>
</s:extension>
</s:simpleContent>
</s:complexType>
The project is using nusoap, a portion of my PHP looks like:
$payment['ProviderData'] = array(
'Field' => array(
'Name' => 'Foo',
),
);
Which is able to produce the following (again, simplified here):
<payment>
<ProviderData>
<Field Name="Foo" />
</ProviderData>
</payment>
I'm not sure what format my PHP array should be in, in order to produce XML that looks like the following:
<payment>
<ProviderData>
<Field Name="name 1">value 1</Field>
<Field Name="name 10">value 10</Field>
<Field Name="name 2">value 2</Field>
</ProviderData>
</payment>
I've tried setting a key called Value
, !Value
, and other variations, without success.
Any help would be appreciated. Thanks.
Upvotes: 2
Views: 1398
Reputation: 1116
After working backwards (converting the XML example into PHP), the format you want is:
$payment['ProviderData'] = array(
'Field' => array (
0 =>
array (
'!Name' => 'Foo',
'!' => 'Bar',
),
1 =>
array (
'!Name' => 'Amount',
'!' => '98',
),
)
);
Upvotes: 1
Reputation: 760
the best solution is to use a WSDL to php generator susch as the PackageGenerator project as you won't wonder how to construct the request
Upvotes: 0