summaryrefslogtreecommitdiff
path: root/ext/soap
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2004-01-14 16:24:09 +0000
committerDmitry Stogov <dmitry@php.net>2004-01-14 16:24:09 +0000
commit49b698c67ed0f8408c54d0754672e552376b7554 (patch)
treee0bcefe36cb1496ee4b9b81bfe5b4e13262cdc03 /ext/soap
parent51cbc1f84fbe2b6e762e527608e62835f2baa753 (diff)
downloadphp-git-49b698c67ed0f8408c54d0754672e552376b7554.tar.gz
WSDL: restrictions support (whiteSpace, minLength, maxLength, length)
Diffstat (limited to 'ext/soap')
-rw-r--r--ext/soap/TODO24
-rw-r--r--ext/soap/php_encoding.c21
-rw-r--r--ext/soap/php_encoding.h2
-rw-r--r--ext/soap/php_sdl.c48
4 files changed, 70 insertions, 25 deletions
diff --git a/ext/soap/TODO b/ext/soap/TODO
index 5c40a5ec3b..3438b3ed3d 100644
--- a/ext/soap/TODO
+++ b/ext/soap/TODO
@@ -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
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index 6605bcd1e2..5fbdb95a03 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -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) {
diff --git a/ext/soap/php_encoding.h b/ext/soap/php_encoding.h
index e7755008b2..7b2bbe13e2 100644
--- a/ext/soap/php_encoding.h
+++ b/ext/soap/php_encoding.h
@@ -105,6 +105,8 @@
#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"
diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c
index 1a6a688336..1e41f45ea2 100644
--- a/ext/soap/php_sdl.c
+++ b/ext/soap/php_sdl.c
@@ -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) {