Validate an incoming SOAP request to the WSDL in PHP

php, soap, wsdl, xsd

Solution

Been digging around on this matter a view hours. Neither the native PHP SoapServer nore the NuSOAP Library does any Validation. PHP SoapServer simply makes a type cast. For Example if you define

<xsd:element name="SomeParameter" type="xsd:boolean" />

and submit

<get:SomeParameter>dfgdfg</get:SomeParameter>

you'll get the php Type boolean (true)

NuSOAP simply casts everthing to string although it recognizes simple types:

from the nuSOAP debug log:

nusoap_xmlschema: processing typed element SomeParameter of type http://www.w3.org/2001/XMLSchema:boolean

So the best way is joelhardi solution to validate yourself or use some xml Parser like XERCES

Problem

The built-in `PHP` extension for `SOAP` doesn't validate everything in the incoming `SOAP` request against the `XML Schema` in the `WSDL`. It does check for the existence of basic entities, but when you have something complicated like `simpleType` restrictions the extension pretty much ignores their existence. What is the best way to validate the `SOAP` request against `XML Schema` contained in the `WSDL`?

Original source