0

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 Answers 2

0

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

Sign up to request clarification or add additional context in comments.

Comments

-1

This should also work:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.