]> granicus.if.org Git - php/commitdiff
WSDL: restrictions support (whiteSpace, minLength, maxLength, length)
authorDmitry Stogov <dmitry@php.net>
Wed, 14 Jan 2004 16:24:09 +0000 (16:24 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 14 Jan 2004 16:24:09 +0000 (16:24 +0000)
ext/soap/TODO
ext/soap/php_encoding.c
ext/soap/php_encoding.h
ext/soap/php_sdl.c

index 5c40a5ec3b33faebb250b2ecd3737c7a72ac26b2..3438b3ed3d4e2a9efb5301007f72818c5adaba61 100644 (file)
@@ -22,7 +22,7 @@ Encoding
   ? anyURI, 
   ? QName, 
   ? NOTATION,
-  ? normalizedString, 
+  + normalizedString, 
   ? token, 
   ? language, 
   ? NMTOKEN, 
@@ -33,7 +33,7 @@ Encoding
   ? IDREFS, 
   ? ENTITY, 
   ? ENTITIES, 
-  ? unsignedLong)
+  + unsignedLong)
 - full support for standard date/time types (
   ? dateTime,
   ? time,
@@ -67,30 +67,30 @@ WSDL
 + support for <opperation> without <input>
 + support for style "rpc"/"document" encoding (client part)
 - support for style "rpc"/"document" encoding (server part)
-  How to get function name from request?
+  How to get function name from request? May be SoapAction HTTP header?
 + support for "encoded"/"literal" encoding
 ? arrayType and "literal" encoding
 ? support for "nillable" and "nil"
 - support for user defined simple types
   - restiction
          + base
+         + enumeration
+               + length (for string, anyURI, hexBinary, base64Binary and derived)
+               + minLength (for string, hexBinary, base64Binary and derived)
+               + maxLength (for string, hexBinary, base64Binary and derived)
+               + 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)
-               - length (for string, anyURI, hexBinary, base64Binary and derived)
-               - minLength (for string, hexBinary, base64Binary and derived)
-               - maxLength (for string, hexBinary, base64Binary and derived)
-               - whiteSpace (preserve, replace [#x9,#xA,#xD=>#x20], collapse [replace+?])
-               - pattern
-         ? enumeration
        - list ???
        - union ???
 - support for user defined complex types
   - simpleContent extension   
-  ? base
+  + base
   - group
        - name
        - all
@@ -111,7 +111,7 @@ WSDL
        - sequence
        - any ???
   - attribute
-- function/method overloading (test(int); test(string))
+- function/method overloading/redeclaration (test(int); test(string))
 - wsdl caching
 - wsdl auto generation
 ? SOAP binding
@@ -135,7 +135,7 @@ Transport
 + HTTP Cookies support 
 - support for HTTP proxies
 - transport abstraction layer
-? SoapAction HTTP header field
++ SoapAction HTTP header field
 ? HTTP status codes
 ? HTTP chunked Transfer-Encoding
 
index 6605bcd1e207b19ea85cd17ec24bf775a7c01b44..5fbdb95a030af0612d32d115a8702250ad45aa7d 100644 (file)
@@ -87,6 +87,7 @@ encode defaultEncoding[] = {
        {{XSD_UNSIGNEDLONG, XSD_UNSIGNEDLONG_STRING, XSD_NAMESPACE, NULL}, to_zval_ulong, to_xml_ulong},
 
        {{XSD_ANYTYPE, XSD_ANYTYPE_STRING, XSD_NAMESPACE, NULL}, guess_zval_convert, guess_xml_convert},
+       {{XSD_UR_TYPE, XSD_UR_TYPE_STRING, XSD_NAMESPACE, NULL}, guess_zval_convert, guess_xml_convert},
        {{XSD_ANYURI, XSD_ANYURI_STRING, XSD_NAMESPACE, NULL}, to_zval_stringc, to_xml_string},
        {{XSD_QNAME, XSD_QNAME_STRING, XSD_NAMESPACE, NULL}, to_zval_stringc, to_xml_string},
        {{XSD_NOTATION, XSD_NOTATION_STRING, XSD_NAMESPACE, NULL}, to_zval_stringc, to_xml_string},
@@ -452,9 +453,19 @@ static zval *to_zval_ulong(encodeType type, xmlNodePtr data)
        FIND_XML_NULL(data, ret);
 
        if (data && data->children && data->children->content) {
+               unsigned long val = 0;
+               char *s;
                whiteSpace_collapse(data->children->content);
-               /* TODO: long overflow */
-               ZVAL_LONG(ret, atol(data->children->content));
+               s = data->children->content;
+               while (*s >= '0' && *s <= '9') {
+                       val = (val*10)+(*s-'0');
+                       s++;
+               }
+               if ((long)val >= 0) {
+                       ZVAL_LONG(ret, val);
+               } else {
+                       ZVAL_STRING(ret, data->children->content, 1);
+               }
        } else {
                ZVAL_NULL(ret);
        }
@@ -857,7 +868,6 @@ xmlNodePtr to_xml_array(encodeType type, zval *data, int style)
        encodePtr enc = NULL;
        int dimension = 1;
        int* dims;
-//     int map;
 
        TSRMLS_FETCH();
 
@@ -866,12 +876,7 @@ xmlNodePtr to_xml_array(encodeType type, zval *data, int style)
        FIND_ZVAL_NULL(data, xmlParam, style);
 
        if (Z_TYPE_P(data) == IS_ARRAY) {
-//             map = is_map(data);
-//             if (map) {
                        i = zend_hash_num_elements(Z_ARRVAL_P(data));
-//             } else {
-//                     i = array_num_elements(Z_ARRVAL_P(data));
-//             }
 
                /*FIXME: arrayType and "literal" encoding? */
                if (style == SOAP_ENCODED) {
index e7755008b24e826bf7fb4699a72b9ac667cb4248..7b2bbe13e2c89f7fb75bb575df9cded8022f5acd 100644 (file)
 #define XSD_POSITIVEINTEGER_STRING "positiveInteger"
 #define XSD_ANYTYPE 143
 #define XSD_ANYTYPE_STRING "anyType"
+#define XSD_UR_TYPE 144
+#define XSD_UR_TYPE_STRING "ur-type"
 
 #define APACHE_NAMESPACE "http://xml.apache.org/xml-soap"
 #define APACHE_NS_PREFIX "apache"
index 1a6a6883364aa484e3ccd505971b1d3801a12b84..1e41f45ea2742efb57df79520af92c685c211b27 100644 (file)
@@ -120,6 +120,34 @@ zval *sdl_guess_convert_zval(encodeType enc, xmlNodePtr data)
        sdlTypePtr type;
 
        type = enc.sdl_type;
+
+       if (type && type->restrictions &&
+           data &&  data->children && data->children->content) {
+               if (type->restrictions->whiteSpace && type->restrictions->whiteSpace->value) {
+                       if (strcmp(type->restrictions->whiteSpace->value,"replace") == 0) {
+                               whiteSpace_replace(data->children->content);
+                       } else if (strcmp(type->restrictions->whiteSpace->value,"collapse") == 0) {
+                               whiteSpace_collapse(data->children->content);
+                       }       
+               }
+               if (type->restrictions->enumeration) {
+                       if (!zend_hash_exists(type->restrictions->enumeration,data->children->content,strlen(data->children->content)+1)) {
+                               php_error(E_WARNING,"Restriction: invalid enumeration value \"%s\"",data->children->content);
+                       }
+               }
+               if (type->restrictions->minLength &&
+                   strlen(data->children->content) < type->restrictions->minLength->value) {
+                 php_error(E_WARNING,"Restriction: length less then 'minLength'");
+               }
+               if (type->restrictions->maxLength &&
+                   strlen(data->children->content) > type->restrictions->maxLength->value) {
+                 php_error(E_WARNING,"Restriction: length greater then 'maxLength'");
+               }
+               if (type->restrictions->length &&
+                   strlen(data->children->content) != type->restrictions->length->value) {
+                 php_error(E_WARNING,"Restriction: length is not equal to 'length'");
+               }
+       }       
        if (type->encode) {
                if (type->encode->details.type == IS_ARRAY ||
                        type->encode->details.type == SOAP_ENC_ARRAY) {
@@ -149,14 +177,24 @@ xmlNodePtr sdl_guess_convert_xml(encodeType enc, zval *data, int style)
 
        type = enc.sdl_type;
 
-       if (type->restrictions) {
+       if (type && type->restrictions && Z_TYPE_P(data) == IS_STRING) {
                if (type->restrictions->enumeration) {
-                       if (Z_TYPE_P(data) == IS_STRING) {
-                               if (!zend_hash_exists(type->restrictions->enumeration,Z_STRVAL_P(data),Z_STRLEN_P(data)+1)) {
-                                       php_error(E_WARNING,"Restriction: invalid enumeration value \"%s\".",Z_STRVAL_P(data));
-                               }
+                       if (!zend_hash_exists(type->restrictions->enumeration,Z_STRVAL_P(data),Z_STRLEN_P(data)+1)) {
+                               php_error(E_WARNING,"Restriction: invalid enumeration value \"%s\".",Z_STRVAL_P(data));
                        }
                }
+               if (type->restrictions->minLength &&
+                   Z_STRLEN_P(data) < type->restrictions->minLength->value) {
+                 php_error(E_WARNING,"Restriction: length less then 'minLength'");
+               }
+               if (type->restrictions->maxLength &&
+                   Z_STRLEN_P(data) > type->restrictions->maxLength->value) {
+                 php_error(E_WARNING,"Restriction: length greater then 'maxLength'");
+               }
+               if (type->restrictions->length &&
+                   Z_STRLEN_P(data) != type->restrictions->length->value) {
+                 php_error(E_WARNING,"Restriction: length is not equal to 'length'");
+               }
        }
 
        if (type->encode) {