dmitry Thu Aug 26 14:40:10 2004 EDT Modified files: /php-src/ext/soap php_encoding.c php_encoding.h php_schema.c php_sdl.c php_sdl.h /php-src/ext/soap/tests/bugs bug29839.phpt bug29839.wsdl xml.xsd Log: Fixed bug #29839 (incorrect convert (xml:lang to lang))
http://cvs.php.net/diff.php/php-src/ext/soap/php_encoding.c?r1=1.73&r2=1.74&ty=u Index: php-src/ext/soap/php_encoding.c diff -u php-src/ext/soap/php_encoding.c:1.73 php-src/ext/soap/php_encoding.c:1.74 --- php-src/ext/soap/php_encoding.c:1.73 Thu Aug 26 11:26:32 2004 +++ php-src/ext/soap/php_encoding.c Thu Aug 26 14:40:10 2004 @@ -17,7 +17,7 @@ | Dmitry Stogov <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: php_encoding.c,v 1.73 2004/08/26 15:26:32 dmitry Exp $ */ +/* $Id: php_encoding.c,v 1.74 2004/08/26 18:40:10 dmitry Exp $ */ #include <time.h> @@ -1357,7 +1357,14 @@ if ((*attr)->fixed && strcmp((*attr)->fixed,dummy->children->content) != 0) { soap_error3(E_ERROR, "Encoding: Attribute '%s' has fixed value '%s' (value '%s' is not allowed)", (*attr)->name, (*attr)->fixed, dummy->children->content); } - xmlSetProp(xmlParam, (*attr)->name, dummy->children->content); + if ((*attr)->namens && + (type->ns == NULL || strcmp((*attr)->namens, type->ns))) { + xmlNsPtr nsp = encode_add_ns(xmlParam, (*attr)->namens); + + xmlSetNsProp(xmlParam, nsp, (*attr)->name, dummy->children->content); + } else { + xmlSetProp(xmlParam, (*attr)->name, dummy->children->content); + } } xmlUnlinkNode(dummy); xmlFreeNode(dummy); http://cvs.php.net/diff.php/php-src/ext/soap/php_encoding.h?r1=1.35&r2=1.36&ty=u Index: php-src/ext/soap/php_encoding.h diff -u php-src/ext/soap/php_encoding.h:1.35 php-src/ext/soap/php_encoding.h:1.36 --- php-src/ext/soap/php_encoding.h:1.35 Tue Feb 24 05:12:45 2004 +++ php-src/ext/soap/php_encoding.h Thu Aug 26 14:40:10 2004 @@ -17,7 +17,7 @@ | Dmitry Stogov <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: php_encoding.h,v 1.35 2004/02/24 10:12:45 dmitry Exp $ */ +/* $Id: php_encoding.h,v 1.36 2004/08/26 18:40:10 dmitry Exp $ */ #ifndef PHP_ENCODING_H #define PHP_ENCODING_H @@ -43,6 +43,8 @@ #define XSD_NS_PREFIX "xsd" #define XSI_NAMESPACE "http://www.w3.org/2001/XMLSchema-instance" #define XSI_NS_PREFIX "xsi" +#define XML_NAMESPACE "http://www.w3.org/XML/1998/namespace" +#define XML_NS_PREFIX "xml" #define XSD_STRING 101 #define XSD_STRING_STRING "string" http://cvs.php.net/diff.php/php-src/ext/soap/php_schema.c?r1=1.49&r2=1.50&ty=u Index: php-src/ext/soap/php_schema.c diff -u php-src/ext/soap/php_schema.c:1.49 php-src/ext/soap/php_schema.c:1.50 --- php-src/ext/soap/php_schema.c:1.49 Wed May 5 06:31:26 2004 +++ php-src/ext/soap/php_schema.c Thu Aug 26 14:40:10 2004 @@ -17,7 +17,7 @@ | Dmitry Stogov <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: php_schema.c,v 1.49 2004/05/05 10:31:26 dmitry Exp $ */ +/* $Id: php_schema.c,v 1.50 2004/08/26 18:40:10 dmitry Exp $ */ #include "php_soap.h" #include "libxml/uri.h" @@ -1729,6 +1729,7 @@ if (nsptr != NULL) { smart_str_appends(&key, nsptr->href); smart_str_appendc(&key, ':'); + newAttr->namens = estrdup(nsptr->href); } smart_str_appends(&key, attr_name); smart_str_0(&key); @@ -1745,6 +1746,7 @@ if (ns != NULL) { smart_str_appends(&key, ns->children->content); smart_str_appendc(&key, ':'); + newAttr->namens = estrdup(ns->children->content); } smart_str_appends(&key, name->children->content); smart_str_0(&key); @@ -2014,6 +2016,9 @@ if ((*tmp)->name != NULL && attr->name == NULL) { attr->name = estrdup((*tmp)->name); } + if ((*tmp)->namens != NULL && attr->namens == NULL) { + attr->namens = estrdup((*tmp)->namens); + } if ((*tmp)->def != NULL && attr->def == NULL) { attr->def = estrdup((*tmp)->def); } @@ -2071,6 +2076,7 @@ memcpy(newAttr, *tmp_attr, sizeof(sdlAttribute)); if (newAttr->def) {newAttr->def = estrdup(newAttr->def);} if (newAttr->fixed) {newAttr->fixed = estrdup(newAttr->fixed);} + if (newAttr->namens) {newAttr->namens = estrdup(newAttr->namens);} if (newAttr->name) {newAttr->name = estrdup(newAttr->name);} if (newAttr->extraAttributes) { xmlNodePtr node; @@ -2329,6 +2335,9 @@ } if (attr->name) { efree(attr->name); + } + if (attr->namens) { + efree(attr->namens); } if (attr->ref) { efree(attr->ref); http://cvs.php.net/diff.php/php-src/ext/soap/php_sdl.c?r1=1.71&r2=1.72&ty=u Index: php-src/ext/soap/php_sdl.c diff -u php-src/ext/soap/php_sdl.c:1.71 php-src/ext/soap/php_sdl.c:1.72 --- php-src/ext/soap/php_sdl.c:1.71 Mon Jul 19 09:58:10 2004 +++ php-src/ext/soap/php_sdl.c Thu Aug 26 14:40:10 2004 @@ -17,7 +17,7 @@ | Dmitry Stogov <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: php_sdl.c,v 1.71 2004/07/19 13:58:10 dmitry Exp $ */ +/* $Id: php_sdl.c,v 1.72 2004/08/26 18:40:10 dmitry Exp $ */ #include "php_soap.h" #include "libxml/uri.h" @@ -993,7 +993,7 @@ return ctx.sdl; } -#define WSDL_CACHE_VERSION 0x09 +#define WSDL_CACHE_VERSION 0x0a #define WSDL_CACHE_GET(ret,type,buf) memcpy(&ret,*buf,sizeof(type)); *buf += sizeof(type); #define WSDL_CACHE_GET_INT(ret,buf) ret = ((unsigned char)(*buf)[0])|((unsigned char)(*buf)[1]<<8)|((unsigned char)(*buf)[2]<<16)|((int)(*buf)[3]<<24); *buf += 4; @@ -1042,6 +1042,7 @@ int i; attr->name = sdl_deserialize_string(in); + attr->namens = sdl_deserialize_string(in); attr->ref = sdl_deserialize_string(in); attr->def = sdl_deserialize_string(in); attr->fixed = sdl_deserialize_string(in); @@ -1317,7 +1318,7 @@ sdlPtr sdl; time_t old_t; int i, num_groups, num_types, num_elements, num_encoders, num_bindings, num_func; - sdlFunctionPtr *functions; + sdlFunctionPtr *functions = NULL; sdlBindingPtr *bindings; sdlTypePtr *types; encodePtr *encoders; @@ -1472,6 +1473,7 @@ /* deserialize functions */ WSDL_CACHE_GET_INT(num_func, &in); +<<<<<<< php_sdl.c zend_hash_init(&sdl->functions, num_func, NULL, delete_function, 0); functions = emalloc(num_func*sizeof(sdlFunctionPtr)); for (i = 0; i < num_func; i++) { @@ -1499,42 +1501,73 @@ WSDL_CACHE_SKIP(1, &in); func->bindingAttributes = NULL; } +======= + if (num_func > 0) { + zend_hash_init(&sdl->functions, num_func, NULL, delete_function, 0); + functions = emalloc(num_func*sizeof(sdlFunctionPtr)); + for (i = 0; i < num_func; i++) { + int binding_num, num_faults; + sdlFunctionPtr func = emalloc(sizeof(sdlFunction)); + sdl_deserialize_key(&sdl->functions, func, &in); + func->functionName = sdl_deserialize_string(&in); + func->requestName = sdl_deserialize_string(&in); + func->responseName = sdl_deserialize_string(&in); + + WSDL_CACHE_GET_INT(binding_num, &in); + if (binding_num == 0) { + func->binding = NULL; + } else { + func->binding = bindings[binding_num-1]; + } + if (func->binding && func->binding->bindingType == BINDING_SOAP && *in != 0) { + sdlSoapBindingFunctionPtr binding = func->bindingAttributes = emalloc(sizeof(sdlSoapBindingFunction)); + memset(binding, 0, sizeof(sdlSoapBindingFunction)); + WSDL_CACHE_GET_1(binding->style,sdlEncodingStyle,&in); + binding->soapAction = sdl_deserialize_string(&in); + sdl_deserialize_soap_body(&binding->input, encoders, types, &in); + sdl_deserialize_soap_body(&binding->output, encoders, types, &in); + } else { + WSDL_CACHE_SKIP(1, &in); + func->bindingAttributes = NULL; + } +>>>>>>> 1.70.2.3 - func->requestParameters = sdl_deserialize_parameters(encoders, types, &in); - func->responseParameters = sdl_deserialize_parameters(encoders, types, &in); + func->requestParameters = sdl_deserialize_parameters(encoders, types, &in); + func->responseParameters = sdl_deserialize_parameters(encoders, types, &in); - WSDL_CACHE_GET_INT(num_faults, &in); - if (num_faults > 0) { - int j; - - func->faults = emalloc(sizeof(HashTable)); - zend_hash_init(func->faults, num_faults, NULL, delete_fault, 0); - - for (j = 0; j < num_faults; j++) { - sdlFaultPtr fault = emalloc(sizeof(sdlFault)); - - sdl_deserialize_key(func->faults, fault, &in); - fault->name =sdl_deserialize_string(&in); - fault->details =sdl_deserialize_parameters(encoders, types, &in); - if (*in != 0) { - sdlSoapBindingFunctionFaultPtr binding = fault->bindingAttributes = emalloc(sizeof(sdlSoapBindingFunctionFault)); - memset(binding, 0, sizeof(sdlSoapBindingFunctionFault)); - WSDL_CACHE_GET_1(binding->use,sdlEncodingUse,&in); - if (binding->use == SOAP_ENCODED) { - WSDL_CACHE_GET_1(binding->encodingStyle, sdlRpcEncodingStyle, &in); + WSDL_CACHE_GET_INT(num_faults, &in); + if (num_faults > 0) { + int j; + + func->faults = emalloc(sizeof(HashTable)); + zend_hash_init(func->faults, num_faults, NULL, delete_fault, 0); + + for (j = 0; j < num_faults; j++) { + sdlFaultPtr fault = emalloc(sizeof(sdlFault)); + + sdl_deserialize_key(func->faults, fault, &in); + fault->name =sdl_deserialize_string(&in); + fault->details =sdl_deserialize_parameters(encoders, types, &in); + if (*in != 0) { + sdlSoapBindingFunctionFaultPtr binding = fault->bindingAttributes = emalloc(sizeof(sdlSoapBindingFunctionFault)); + memset(binding, 0, sizeof(sdlSoapBindingFunctionFault)); + WSDL_CACHE_GET_1(binding->use,sdlEncodingUse,&in); + if (binding->use == SOAP_ENCODED) { + WSDL_CACHE_GET_1(binding->encodingStyle, sdlRpcEncodingStyle, &in); + } else { + binding->encodingStyle = SOAP_ENCODING_DEFAULT; + } + binding->ns = sdl_deserialize_string(&in); } else { - binding->encodingStyle = SOAP_ENCODING_DEFAULT; + WSDL_CACHE_SKIP(1, &in); + fault->bindingAttributes = NULL; } - binding->ns = sdl_deserialize_string(&in); - } else { - WSDL_CACHE_SKIP(1, &in); - fault->bindingAttributes = NULL; } + } else { + func->faults = NULL; } - } else { - func->faults = NULL; + functions[i] = func; } - functions[i] = func; } /* deserialize requests */ @@ -1551,7 +1584,9 @@ } } - efree(functions); + if (functions) { + efree(functions); + } efree(bindings); efree(encoders); efree(types); @@ -1619,6 +1654,7 @@ int i; sdl_serialize_string(attr->name, out); + sdl_serialize_string(attr->namens, out); sdl_serialize_string(attr->ref, out); sdl_serialize_string(attr->def, out); sdl_serialize_string(attr->fixed, out); http://cvs.php.net/diff.php/php-src/ext/soap/php_sdl.h?r1=1.31&r2=1.32&ty=u Index: php-src/ext/soap/php_sdl.h diff -u php-src/ext/soap/php_sdl.h:1.31 php-src/ext/soap/php_sdl.h:1.32 --- php-src/ext/soap/php_sdl.h:1.31 Tue Feb 24 10:06:41 2004 +++ php-src/ext/soap/php_sdl.h Thu Aug 26 14:40:10 2004 @@ -17,7 +17,7 @@ | Dmitry Stogov <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: php_sdl.h,v 1.31 2004/02/24 15:06:41 dmitry Exp $ */ +/* $Id: php_sdl.h,v 1.32 2004/08/26 18:40:10 dmitry Exp $ */ #ifndef PHP_SDL_H #define PHP_SDL_H @@ -239,6 +239,7 @@ struct _sdlAttribute { char *name; + char *namens; char *ref; char *def; char *fixed; http://cvs.php.net/diff.php/php-src/ext/soap/tests/bugs/bug29839.phpt?r1=1.1&r2=1.2&ty=u Index: php-src/ext/soap/tests/bugs/bug29839.phpt diff -u /dev/null php-src/ext/soap/tests/bugs/bug29839.phpt:1.2 --- /dev/null Thu Aug 26 14:40:10 2004 +++ php-src/ext/soap/tests/bugs/bug29839.phpt Thu Aug 26 14:40:10 2004 @@ -0,0 +1,41 @@ +--TEST-- +Bug #29839 incorrect convert (xml:lang to lang) +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +function EchoString($s) { + return $s; +} + +class LocalSoapClient extends SoapClient { + + function LocalSoapClient($wsdl, $options) { + $this->SoapClient($wsdl, $options); + $this->server = new SoapServer($wsdl, $options); + $this->server->addFunction('EchoString'); + } + + function __doRequest($request, $location, $action, $version) { + ob_start(); + $this->server->handle($request); + $response = ob_get_contents(); + ob_end_clean(); + return $response; + } + +} + +$client = new LocalSoapClient(dirname(__FILE__)."/bug29839.wsdl", array("trace"=>1)); +$client->EchoString(array("value"=>"hello","lang"=>"en")); +echo $client->__getLastRequest(); +echo $client->__getLastResponse(); +echo "ok\n"; +?> +--EXPECT-- +<?xml version="1.0" encoding="UTF-8"?> +<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://test-uri"><SOAP-ENV:Body><string xml:lang="en"><ns1:value>hello</ns1:value></string></SOAP-ENV:Body></SOAP-ENV:Envelope> +<?xml version="1.0" encoding="UTF-8"?> +<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://test-uri"><SOAP-ENV:Body><string xml:lang="en"><ns1:value>hello</ns1:value></string></SOAP-ENV:Body></SOAP-ENV:Envelope> +ok \ No newline at end of file http://cvs.php.net/diff.php/php-src/ext/soap/tests/bugs/bug29839.wsdl?r1=1.1&r2=1.2&ty=u Index: php-src/ext/soap/tests/bugs/bug29839.wsdl diff -u /dev/null php-src/ext/soap/tests/bugs/bug29839.wsdl:1.2 --- /dev/null Thu Aug 26 14:40:10 2004 +++ php-src/ext/soap/tests/bugs/bug29839.wsdl Thu Aug 26 14:40:10 2004 @@ -0,0 +1,42 @@ +<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://test-uri" targetNamespace="http://test-uri"> + <types> + <xs:schema targetNamespace="http://test-uri" elementFormDefault="qualified"> + <import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd" /> + <complexType name="LocalizedString"> + <sequence> + <element name="value" type="xsd:string"/> + </sequence> + <attribute ref="xml:lang" use="required"/> + </complexType> + </xs:schema> + </types> + <message name="EchoStringRequest"> + <part name="string" type="tns:LocalizedString"/> + </message> + <message name="EchoStringResponse"> + <part name="string" type="tns:LocalizedString"/> + </message> + <portType name="AWSProductDataPortType"> + <operation name="EchoString"> + <input message="tns:EchoStringRequest"/> + <output message="tns:EchoStringResponse"/> + </operation> + </portType> + <binding name="AWSProductDataBinding" type="tns:AWSProductDataPortType"> + <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <operation name="EchoString"> + <soap:operation soapAction="http://test-uri"/> + <input> + <soap:body use="literal"/> + </input> + <output> + <soap:body use="literal"/> + </output> + </operation> + </binding> + <service name="AWSProductData"> + <port name="AWSProductDataPort" binding="tns:AWSProductDataBinding"> + <soap:address location="http://aws-beta.amazon.com/onca/soap?Service=AWSProductData"/> + </port> + </service> +</definitions> http://cvs.php.net/diff.php/php-src/ext/soap/tests/bugs/xml.xsd?r1=1.1&r2=1.2&ty=u Index: php-src/ext/soap/tests/bugs/xml.xsd diff -u /dev/null php-src/ext/soap/tests/bugs/xml.xsd:1.2 --- /dev/null Thu Aug 26 14:40:10 2004 +++ php-src/ext/soap/tests/bugs/xml.xsd Thu Aug 26 14:40:10 2004 @@ -0,0 +1,34 @@ +<?xml version='1.0'?> +<!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "XMLSchema.dtd" > +<xs:schema targetNamespace="http://www.w3.org/XML/1998/namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema" xml:lang="en"> + + <xs:attribute name="lang" type="xs:language"> + <xs:annotation> + <xs:documentation>In due course, we should install the relevant ISO 2- and 3-letter + codes as the enumerated possible values . . .</xs:documentation> + </xs:annotation> + </xs:attribute> + + <xs:attribute name="space" default="preserve"> + <xs:simpleType> + <xs:restriction base="xs:NCName"> + <xs:enumeration value="default"/> + <xs:enumeration value="preserve"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + + <xs:attribute name="base" type="xs:anyURI"> + <xs:annotation> + <xs:documentation>See http://www.w3.org/TR/xmlbase/ for + information about this attribute.</xs:documentation> + </xs:annotation> + </xs:attribute> + + <xs:attributeGroup name="specialAttrs"> + <xs:attribute ref="xml:base"/> + <xs:attribute ref="xml:lang"/> + <xs:attribute ref="xml:space"/> + </xs:attributeGroup> + +</xs:schema>
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php