-
-
Save wagnerpinheiro/6e76f2f35c1bf458579a006fb9d6b630 to your computer and use it in GitHub Desktop.
PHP SoapServer ignores invalid enum value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="test-service-namespace"> | |
<SOAP-ENV:Body> | |
<ns1:TestOperation> | |
<ns1:firstArgument> | |
<!-- Wrong enum --> | |
<ns1:timeGroup>FooBar</ns1:timeGroup> | |
<!-- Good enum --> | |
<ns1:customerType>CHILD</ns1:customerType> | |
</ns1:firstArgument> | |
</ns1:TestOperation> | |
</SOAP-ENV:Body> | |
</SOAP-ENV:Envelope> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='UTF-8'?> | |
<wsdl:definitions | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" | |
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" | |
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" | |
targetNamespace="test-service-namespace" | |
name="TestService"> | |
<wsdl:types> | |
<xs:schema targetNamespace="test-service-namespace" elementFormDefault="qualified"> | |
<xs:simpleType name="TimeGroupEnum"> | |
<xs:restriction base="xs:string"> | |
<xs:enumeration value="NOGROUP"/> | |
<xs:enumeration value="DAY"/> | |
<xs:enumeration value="WEEK"/> | |
<xs:enumeration value="MONTH"/> | |
<xs:enumeration value="QUARTER"/> | |
<xs:enumeration value="YEAR"/> | |
</xs:restriction> | |
</xs:simpleType> | |
<xs:simpleType name="CustomerTypeEnum"> | |
<xs:restriction base="xs:string"> | |
<xs:enumeration value="CHILD"/> | |
<xs:enumeration value="ADULT"/> | |
</xs:restriction> | |
</xs:simpleType> | |
<xs:complexType name="TestStructure"> | |
<xs:sequence> | |
<xs:element name="timeGroup" type="tns:TimeGroupEnum"/> | |
<xs:element name="customerType" type="tns:CustomerTypeEnum"/> | |
</xs:sequence> | |
</xs:complexType> | |
<xs:complexType name="TestOperation"> | |
<xs:sequence> | |
<xs:element name="firstArgument" type="tns:TestStructure"/> | |
</xs:sequence> | |
</xs:complexType> | |
<xs:complexType name="TestOperationResponse"> | |
<xs:sequence> | |
<xs:element name="TestOperationResult" type="xs:string" minOccurs="0" nillable="true"/> | |
</xs:sequence> | |
</xs:complexType> | |
<xs:element name="TestStructure" type="tns:TestStructure"/> | |
<xs:element name="TestOperation" type="tns:TestOperation"/> | |
<xs:element name="TestOperationResponse" type="tns:TestOperationResponse"/> | |
</xs:schema> | |
</wsdl:types> | |
<wsdl:message name="TestOperation"> | |
<wsdl:part name="TestOperation" element="tns:TestOperation"/> | |
</wsdl:message> | |
<wsdl:message name="TestOperationResponse"> | |
<wsdl:part name="TestOperationResponse" element="tns:TestOperationResponse"/> | |
</wsdl:message> | |
<wsdl:portType name="TestService"> | |
<wsdl:operation name="TestOperation" parameterOrder="TestOperation"> | |
<wsdl:input name="TestOperation" message="tns:TestOperation"/> | |
<wsdl:output name="TestOperationResponse" message="tns:TestOperationResponse"/> | |
</wsdl:operation> | |
</wsdl:portType> | |
<wsdl:binding name="TestService" type="tns:TestService"> | |
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> | |
<wsdl:operation name="TestOperation"> | |
<soap:operation soapAction="TestOperation" style="document"/> | |
<wsdl:input name="TestOperation"> | |
<soap:body use="literal"/> | |
</wsdl:input> | |
<wsdl:output name="TestOperationResponse"> | |
<soap:body use="literal"/> | |
</wsdl:output> | |
</wsdl:operation> | |
</wsdl:binding> | |
<wsdl:service name="TestService"> | |
<wsdl:port name="TestService" binding="tns:TestService"> | |
<soap:address location="http://localhost/test/service"/> | |
</wsdl:port> | |
</wsdl:service> | |
</wsdl:definitions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Проверка упадёт ли SOAP сервер от неправильного енума | |
// reportType из request.xml не соответствует определению service.wsdl.xml | |
function TestOperation($params) | |
{ | |
print_r($params); | |
die(); | |
return array('TestOperationResult' => 42); | |
return 42; | |
} | |
$soapServer = new SoapServer('service.wsdl.xml'); | |
$soapServer->addFunction('TestOperation'); | |
$request = file_get_contents('request.xml'); | |
print_r($soapServer->handle($request)); | |
die("\n\n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment