views:

389

answers:

0

I am having trouble trying to pass an array of data to a Nusoap client request to a WSDL server. The spec is a mixture of attribute values and simpleContent values.

The WDSL spec looks something like this:

<s:complexType name="RequestMessage">
  <s:sequence>
    <s:element minOccurs="0" name="Address" type="s0:MessageAddress"/>
    <s:element minOccurs="0" name="EmailAddress" type="s0:EmailAddress"/>
  </s:sequence>
</s:complexType>
<s:complexType name="MessageAddress">
  <s:attribute name="Line1" type="s:string"/>
  <s:attribute name="Line2" type="s:string"/>
  <s:attribute name="Line3" type="s:string"/>
  <s:attribute name="Line4" type="s:string"/>
  <s:attribute name="Line5" type="s:string"/>
  <s:attribute name="Line6" type="s:string"/>
  <s:attribute name="Postcode" type="s:string"/>
</s:complexType>
<s:complexType name="EmailAddress">
  <s:simpleContent>
    <s:extension base="s:string"/>
  </s:simpleContent>
</s:complexType>

My array of data looks something like this:

$address = array(
  'Line1'     => 'Address line 1',
  'Line2'     => 'Address line 2',
  'Line3'     => 'Address line 3',
  'Line4'     => 'Address line 4',
  'Line5'     => '',
  'Line6'     => '',
  'Postcode'  => 'SN1 1XX');
$email = array('[email protected]');
$message = array(
  'Address'       => $address,
  'EmailAddress'  => $email);

And the resulting XML looks something like this:

<message>
  <Address Line1="Address line 1" Line2="Address line 2" Line3="Address line 3" Line4="Address line 4" Line5="" Line6="" Postcode="SN1 1XX"></Address>
  <EmailAddress></EmailAddress>
</message>

As you can see, the address values are all getting passed to appropriate element and populating the attributes correctly. However, the email address is not getting passed into the EmailAddress element.

In my example array above I have passed the email address as an array. I have tried passing it as a string but when I do this Nusoap fails altogether.

Any help with this would be much appreciated - I've pulled enough hair out for today.