How to send plain XML to SOAP response?

I am using the PHP SoapServer class and trying to put plain XML in the body of a SOAP response.

Case 1:

My WSDL has

<element name="getDataResponse" type="xsd:string"/>

I encode the answer

return new SoapVar($my_xml,XSD_ANYXML)

PHP SoapClient says

SOAP-ERROR: Encoding: Violation of encoding rules

Case 2:

Wsdl

<element name="getDataResponse" type="xsd:string"/>

response

return new SoapVar($my_xml,XSD_STRING)

the XML response has everything <encoded as <and> as>

Case 3:

Wdsl

<element name="getDataResponse">
  <complexType>
   ... 
  </complexType>
</element>

where complexType matches the XML structure to return

response

return new SoapVar($my_xml,XSD_ANYXML)

now the return type is an object, not an XML string

Case 4

the same as in case 3, except for the encoding as SOAP_ENC_OBJECT. Again the result will be an object.

Please, help! How can I get plain XML text as the body of a SOAP response?

+5
source share
1 answer

Have you tried this?

return new SoapVar(
     '<ns1:xmlDocument>'.$my_xml.'</ns1:xmlDocument>',
     XSD_ANYXML
);

PHP. (. " " )

+4

All Articles