Skip to content

Instantly share code, notes, and snippets.

@aminin
Created December 30, 2011 11:59
Show Gist options
  • Save aminin/1539513 to your computer and use it in GitHub Desktop.
Save aminin/1539513 to your computer and use it in GitHub Desktop.
PHP SoapServer ignores invalid enum value
<?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>
<?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>
<?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");
@quickshiftin
Copy link

There's actually quite a bit it doesn't support, have a look at the TODO from the source

General

  • make sure soapserver.map(), soap_encode_to_xml() and soap_encode_to_zval() are really need
  • reimplement SoapObject::__getfunctions() and SoapObject::__gettypes()
    to return structures instead of strings
  • error handling???

SOAP

  • SOAP routing
  • root attribute (it is defined by SOAP 1.1, but not SOAP 1.2)
  • make sure soap 1.1 and 1.2 are supported fully

Encoding

? full support for standard simple types (
? language, (pattern: "[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})")
? NMTOKEN, (pattern: "\c+") (\c: [a-zA-Z0-9.-
:])
? NMTOKENS, (list: NMTOKEN, minLength: 1)
? Name, (pattern: "\i\c_") (\i: [a-zA-Z_:]
? NCName, (pattern: "[\i-[:]][\c-[:]]*")
? ID, (base: NCName)
? IDREF, (base: NCName)
? IDREFS, (list: IDREF; minLength: 1)
? ENTITY, (base: NCName)
? ENTITIES, (list: ENTITY; minLength: 1)
? duration)
? full support for standard date/time types (
? dateTime,
? time,
? date,
? gYearMonth,
? gYear,
? gMonthDay,
? gDay,
? gMonth)
? full support for arrays

  • SOAP 1.1 encoding of arrays with holes (partially transmitted and sparse arrays)
    SOAP 1.2 doesn't support partially transmitted and sparse arrays
    • references to external resources
      ? support for "nillable" and "nil"
      ? default values of
      ? provide schema 1999/2001 support???
      ? make internal refrences for soap encoding (use seralization logic)???
      ? provide user space overriding of serialization certin objects and types???

WSDL

? server part support for "document" style encoding
? support for , soap:fault
? soap:headerfault

  • soap:body parts attribute (with MIME/DIME binding)
  • MIME binding
  • DIME binding
  • support for portType/operation parameterOrder attribute
  • support for binding operation input/output name attribute (part of overloading)
  • function/method overloading/redeclaration (test(int); test(string))
  • wsdl auto generation
  • HTTP GET/POST binding
  • SOAP security extension

Schema

  • ? support for user defined simple types ? restiction ? enumeration ? length (for string, anyURI, hexBinary, base64Binary and derived) list??? ? minLength (for string, hexBinary, base64Binary and derived) list??? ? maxLength (for string, hexBinary, base64Binary and derived) list??? + whiteSpace (preserve, replace [#x9,#xA,#xD=>#x20], collapse [replace+?]) - pattern - minExclusive (for numeric, date types) - minInclusive (for numeric, date types) - maxExclusive (for numeric, date types) - maxInclusive (for numeric, date types) - totalDigits (for decimal) - fractionDigits (for decimal) ? union ? support for user defined complex types ? full support for content model encoding/decoding - -

Transport

? HTTP status codes
? HTTP chunked Transfer-Encoding
? support for HTTP compression (gzip,x-gzip,defalte)

  • transport abstraction layer???

Interop Testing

  • more interop rounds/groups

UDDI

  • ???

@aminin
Copy link
Author

aminin commented Jul 19, 2012

Thanks for a detailed list of php soap server's limitations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment