0
votes

I need to return SOAP call answer according to WSDL. Everything is working OK, except returning xsd:any element. Part of the WSDL, that I'm having problem with (this is for excpected answer).


    xsd:complexType name="data"
        xsd:sequence
         xsd:any minOccurs="1" maxOccurs="unbounded"
        xsd:sequence
    xsd:complexType

What I tried:


    foreach($data as $name=>$value) {
        $object->data->any[$name] = $value;
    }
    return $object;

The SOAP call returns answer like this:


    ..response>
    -data>value1value2value3value4-/data>
    .../response>

Although before returning the object, it can be seen, that the object is created as it should have been:


    $object->data->any[name1] = value1
    $object->data->any[name2] = value2

    etc...

But in the return asnwer, all the values are just put into one string into one return field. This code and returning works correctly with any other field type (for example xsd:string etc).

How should the object be returned in case of xsd:any type, to get the answer with multiple fields according to the names and values?

Thanks

2

2 Answers

0
votes

Solved the problem.

I had to create SoapVar object for the field.


    $o = new Object();
    $o->field = $value;
    $object->data = new SoapVar($field, XSD_ANYTYPE);
    return $object;

Thanks

-1
votes

This should also work:

$object->data = new SoapVar($data, SOAP_ENC_OBJECT);