| 1 | /* | |
| 2 | * Portions of this file Copyright 1999-2005 University of Chicago | |
| 3 | * Portions of this file Copyright 1999-2005 The University of Southern California. | |
| 4 | * | |
| 5 | * This file or a portion of this file is licensed under the | |
| 6 | * terms of the Globus Toolkit Public License, found at | |
| 7 | * http://www.globus.org/toolkit/download/license.html. | |
| 8 | * If you redistribute this file, with or without | |
| 9 | * modifications, you must include this notice in the file. | |
| 10 | */ | |
| 11 | ||
| 12 | ||
| 13 | #include "xsd_any.h" | |
| 14 | #include "globus_soap_message.h" | |
| 15 | #include "globus_soap_message_utils.h" | |
| 16 | #include "globus_i_soap_message.h" | |
| 17 | #include "globus_xml_buffer.h" | |
| 18 | #include "globus_i_soap_message_wildcards.h" | |
| 19 | #include "globus_i_xsd.h" | |
| 20 | ||
| 21 | GLOBUS_I_XSD_DEFINE_QNAME(xsd, any); | |
| 22 | 40 | GLOBUS_I_XSD_DEFINE_TYPE_INIT_ARRAY(xsd_any); |
| 23 | 55652 | GLOBUS_I_XSD_DEFINE_TYPE_DESTROY_ARRAY(xsd_any); |
| 24 | 15919 | GLOBUS_I_XSD_DEFINE_TYPE_COPY_ARRAY(xsd_any); |
| 25 | 4696 | GLOBUS_I_XSD_DEFINE_TYPE_SERIALIZE_ARRAY(xsd_any); |
| 26 | 7861 | GLOBUS_I_XSD_DEFINE_TYPE_DESERIALIZE_ARRAY(xsd_any); |
| 27 | 1113171 | GLOBUS_I_XSD_DEFINE_TYPE_ARRAY_PUSH(xsd_any); |
| 28 | 327 | GLOBUS_I_XSD_DEFINE_TYPE_INIT(xsd_any); |
| 29 | 462 | GLOBUS_I_XSD_DEFINE_TYPE_DESTROY(xsd_any); |
| 30 | 254 | GLOBUS_I_XSD_DEFINE_TYPE_COPY(xsd_any); |
| 31 | 0 | GLOBUS_I_XSD_DEFINE_INIT_CONTENTS_GENERIC(xsd_any); |
| 32 | ||
| 33 | globus_result_t | |
| 34 | xsd_any_serialize_wrapper( | |
| 35 | xsd_QName * element_qname, | |
| 36 | void * instance, | |
| 37 | globus_soap_message_handle_t message_handle, | |
| 38 | globus_xsd_element_options_t options) | |
| 39 | { | |
| 40 | 32 | return xsd_any_serialize( |
| 41 | element_qname, | |
| 42 | (xsd_any *) instance, | |
| 43 | message_handle, options); | |
| 44 | } | |
| 45 | ||
| 46 | globus_result_t | |
| 47 | xsd_any_deserialize_pointer_wrapper( | |
| 48 | xsd_QName * element_qname, | |
| 49 | void ** ip, | |
| 50 | globus_soap_message_handle_t message_handle, | |
| 51 | globus_xsd_element_options_t options) | |
| 52 | 0 | { |
| 53 | 0 | return xsd_any_deserialize_pointer( |
| 54 | element_qname, | |
| 55 | (xsd_any **) ip, | |
| 56 | message_handle, options); | |
| 57 | } | |
| 58 | ||
| 59 | struct globus_xsd_type_info_s xsd_any_info = | |
| 60 | { | |
| 61 | &xsd_any_qname, | |
| 62 | xsd_any_serialize_wrapper, | |
| 63 | xsd_any_deserialize_pointer_wrapper, | |
| 64 | xsd_any_init_wrapper, | |
| 65 | xsd_any_destroy_wrapper, | |
| 66 | xsd_any_copy_wrapper, | |
| 67 | xsd_any_init_contents_wrapper, | |
| 68 | xsd_any_destroy_contents_wrapper, | |
| 69 | xsd_any_copy_contents_wrapper, | |
| 70 | sizeof(xsd_any), | |
| 71 | NULL, | |
| 72 | NULL, | |
| 73 | &xsd_any_array_info | |
| 74 | }; | |
| 75 | ||
| 76 | struct globus_xsd_type_info_s xsd_any_array_info = | |
| 77 | { | |
| 78 | &xsd_any_qname, | |
| 79 | xsd_any_array_serialize_wrapper, | |
| 80 | xsd_any_array_deserialize_wrapper, | |
| 81 | xsd_any_array_init_wrapper, | |
| 82 | xsd_any_array_destroy_wrapper, | |
| 83 | xsd_any_array_copy_wrapper, | |
| 84 | xsd_any_array_init_contents_wrapper, | |
| 85 | xsd_any_array_destroy_contents_wrapper, | |
| 86 | xsd_any_array_copy_contents_wrapper, | |
| 87 | sizeof(xsd_any), | |
| 88 | xsd_any_array_push_wrapper, | |
| 89 | NULL, | |
| 90 | NULL | |
| 91 | }; | |
| 92 | ||
| 93 | void | |
| 94 | xsd_any_destroy_contents( | |
| 95 | xsd_any * instance) | |
| 96 | 1744950 | { |
| 97 | 1744950 | GlobusFuncName(xsd_any_destroy_contents); |
| 98 | 1744950 | GlobusSoapMessageDebugEnter(); |
| 99 | ||
| 100 | 1744950 | if(instance) |
| 101 | { | |
| 102 | 1744950 | if(instance->value && instance->any_info) |
| 103 | { | |
| 104 | 1736910 | instance->any_info->destroy(instance->value); |
| 105 | 1736910 | instance->value = NULL; |
| 106 | } | |
| 107 | ||
| 108 | 1744950 | if(instance->element) |
| 109 | { | |
| 110 | 1736893 | xsd_QName_destroy(instance->element); |
| 111 | 1736893 | instance->element = NULL; |
| 112 | } | |
| 113 | } | |
| 114 | ||
| 115 | 1744950 | GlobusSoapMessageDebugExit(); |
| 116 | } | |
| 117 | ||
| 118 | globus_result_t | |
| 119 | xsd_any_copy_contents( | |
| 120 | xsd_any * dest, | |
| 121 | const xsd_any * src) | |
| 122 | 623708 | { |
| 123 | 623708 | globus_result_t result = GLOBUS_SUCCESS; |
| 124 | 623708 | GlobusFuncName(xsd_any_copy_contents); |
| 125 | 623708 | GlobusSoapMessageDebugEnter(); |
| 126 | ||
| 127 | 623708 | if(dest && src) |
| 128 | { | |
| 129 | 623708 | *dest = *src; |
| 130 | 623708 | if(src->element) |
| 131 | { | |
| 132 | 623698 | result = xsd_QName_copy(&dest->element, src->element); |
| 133 | 623698 | if(result != GLOBUS_SUCCESS) |
| 134 | { | |
| 135 | 0 | goto error; |
| 136 | } | |
| 137 | } | |
| 138 | ||
| 139 | 623708 | if(src->value && src->any_info) |
| 140 | { | |
| 141 | 623708 | result = src->any_info->copy(&dest->value, src->value); |
| 142 | 623708 | if(result != GLOBUS_SUCCESS) |
| 143 | { | |
| 144 | 0 | if(dest->element) |
| 145 | { | |
| 146 | 0 | xsd_QName_destroy(dest->element); |
| 147 | 0 | dest->element = NULL; |
| 148 | goto error; | |
| 149 | } | |
| 150 | } | |
| 151 | } | |
| 152 | } | |
| 153 | ||
| 154 | error: | |
| 155 | 623708 | GlobusSoapMessageDebugExit(); |
| 156 | 623708 | return result; |
| 157 | } | |
| 158 | ||
| 159 | globus_result_t | |
| 160 | xsd_any_serialize( | |
| 161 | xsd_QName * element_qname, | |
| 162 | xsd_any * anyinst, | |
| 163 | globus_soap_message_handle_t message_handle, | |
| 164 | globus_xsd_element_options_t options) | |
| 165 | 493689 | { |
| 166 | 493689 | globus_result_t result = GLOBUS_SUCCESS; |
| 167 | 493689 | GlobusFuncName(xsd_any_serialize); |
| 168 | 493689 | GlobusSoapMessageDebugEnter(); |
| 169 | ||
| 170 | /* if(!anyinst->element) */ | |
| 171 | /* { */ | |
| 172 | /* result = GlobusSoapMessageErrorSerializeFailed( */ | |
| 173 | /* GLOBUS_FAILURE, */ | |
| 174 | /* "element field in xsd:any variable is NULL.", */ | |
| 175 | /* element_qname); */ | |
| 176 | /* goto exit; */ | |
| 177 | /* } */ | |
| 178 | ||
| 179 | /* serialize contents of type */ | |
| 180 | 493689 | result = anyinst->any_info->serialize( |
| 181 | anyinst->element, | |
| 182 | anyinst->value, | |
| 183 | message_handle, | |
| 184 | options | GLOBUS_XSD_ELEMENT_TYPE_ATTR); | |
| 185 | 493689 | if(result != GLOBUS_SUCCESS) |
| 186 | { | |
| 187 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 188 | result, | |
| 189 | "Serialization of xsd:any failed", | |
| 190 | anyinst->element); | |
| 191 | goto exit; | |
| 192 | } | |
| 193 | ||
| 194 | exit: | |
| 195 | ||
| 196 | 493689 | GlobusSoapMessageDebugExit(); |
| 197 | 493689 | return result; |
| 198 | } | |
| 199 | ||
| 200 | globus_result_t | |
| 201 | globus_i_xsd_deserialize_from_element_qname( | |
| 202 | xsd_QName * deselem_qname, | |
| 203 | globus_xsd_type_info_t * found_any_info, | |
| 204 | globus_xsd_type_registry_t registry, | |
| 205 | globus_soap_message_handle_t message_handle) | |
| 206 | 619788 | { |
| 207 | 619788 | globus_result_t result = GLOBUS_SUCCESS; |
| 208 | 619788 | globus_xsd_type_info_t any_info = NULL; |
| 209 | 619788 | GlobusFuncName(globus_i_xsd_deserialize_from_element_qname); |
| 210 | 619788 | GlobusSoapMessageDebugEnter(); |
| 211 | ||
| 212 | 619788 | GlobusSoapMessageDebugPrintf( |
| 213 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 214 | ("\tLooking for element {%s}%s:\n", | |
| 215 | deselem_qname->Namespace, | |
| 216 | deselem_qname->local)); | |
| 217 | ||
| 218 | 619788 | GlobusSoapMessageDebugPrintf( |
| 219 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 220 | ("\t\tin instance registry\n")); | |
| 221 | ||
| 222 | 619788 | if(registry) |
| 223 | { | |
| 224 | /* look for element QName in instance registry */ | |
| 225 | 0 | result = globus_xsd_type_registry_get( |
| 226 | registry, deselem_qname, &any_info); | |
| 227 | 0 | if(result != GLOBUS_SUCCESS) |
| 228 | { | |
| 229 | 0 | result = GlobusSoapMessageErrorFailedRegistryLookup( |
| 230 | result, deselem_qname); | |
| 231 | 0 | goto exit; |
| 232 | } | |
| 233 | ||
| 234 | 0 | if(GlobusSoapMessageDebug(GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS)) |
| 235 | { | |
| 236 | 0 | if(any_info) |
| 237 | { | |
| 238 | 0 | GlobusSoapMessageDebugPrintf( |
| 239 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 240 | ("\tFound type info: {%s}%s\n", | |
| 241 | any_info->type->Namespace, | |
| 242 | any_info->type->local)); | |
| 243 | } | |
| 244 | } | |
| 245 | } | |
| 246 | ||
| 247 | 619788 | if(!any_info) |
| 248 | { | |
| 249 | 619788 | globus_xsd_type_registry_t message_registry; |
| 250 | ||
| 251 | 619788 | GlobusSoapMessageDebugPrintf( |
| 252 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 253 | ("\t\tin message registry\n")); | |
| 254 | ||
| 255 | 619788 | globus_soap_message_handle_get_registry(message_handle, |
| 256 | &message_registry); | |
| 257 | 619788 | if(message_registry) |
| 258 | { | |
| 259 | 618479 | result = globus_xsd_type_registry_get( |
| 260 | message_registry, deselem_qname, &any_info); | |
| 261 | 618479 | if(result != GLOBUS_SUCCESS) |
| 262 | { | |
| 263 | 0 | result = GlobusSoapMessageErrorFailedRegistryLookup( |
| 264 | result, deselem_qname); | |
| 265 | 0 | goto exit; |
| 266 | } | |
| 267 | ||
| 268 | 618479 | if(GlobusSoapMessageDebug(GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS)) |
| 269 | { | |
| 270 | 0 | if(any_info) |
| 271 | { | |
| 272 | 0 | GlobusSoapMessageDebugPrintf( |
| 273 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 274 | ("\tFound type info: {%s}%s\n", | |
| 275 | any_info->type->Namespace, | |
| 276 | any_info->type->local)); | |
| 277 | } | |
| 278 | } | |
| 279 | } | |
| 280 | } | |
| 281 | ||
| 282 | 619788 | if(!any_info) |
| 283 | { | |
| 284 | 3109 | GlobusSoapMessageDebugPrintf( |
| 285 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 286 | ("\t\tin global registry\n")); | |
| 287 | ||
| 288 | 3109 | result = globus_xsd_type_registry_get( |
| 289 | GLOBUS_GLOBAL_TYPE_REGISTRY, deselem_qname, &any_info); | |
| 290 | 3109 | if(result != GLOBUS_SUCCESS) |
| 291 | { | |
| 292 | 0 | result = GlobusSoapMessageErrorFailedRegistryLookup( |
| 293 | result, deselem_qname); | |
| 294 | 0 | goto exit; |
| 295 | } | |
| 296 | ||
| 297 | 3109 | if(GlobusSoapMessageDebug(GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS)) |
| 298 | { | |
| 299 | 0 | if(any_info) |
| 300 | { | |
| 301 | 0 | GlobusSoapMessageDebugPrintf( |
| 302 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 303 | ("Found type info: {%s}%s\n", | |
| 304 | any_info->type->Namespace, | |
| 305 | any_info->type->local)); | |
| 306 | } | |
| 307 | } | |
| 308 | } | |
| 309 | ||
| 310 | exit: | |
| 311 | ||
| 312 | 619788 | *found_any_info = any_info; |
| 313 | ||
| 314 | 619788 | GlobusSoapMessageDebugExit(); |
| 315 | 619788 | return result; |
| 316 | } | |
| 317 | ||
| 318 | ||
| 319 | globus_result_t | |
| 320 | globus_i_xsd_deserialize_from_xsi_type( | |
| 321 | globus_xsd_type_info_t * found_any_info, | |
| 322 | globus_xsd_type_registry_t registry, | |
| 323 | globus_soap_message_handle_t message_handle) | |
| 324 | 3097 | { |
| 325 | 3097 | globus_result_t result = GLOBUS_SUCCESS; |
| 326 | 3097 | globus_xsd_type_info_t any_info = NULL; |
| 327 | 3097 | xsd_QName type; |
| 328 | 3097 | xmlChar * type_string = NULL; |
| 329 | 3097 | xmlChar * type_prefix = NULL; |
| 330 | 3097 | xmlChar * type_local = NULL; |
| 331 | 3097 | xmlChar * type_ns = NULL; |
| 332 | 3097 | GlobusFuncName(globus_i_xsd_deserialize_from_xsi_type); |
| 333 | 3097 | GlobusSoapMessageDebugEnter(); |
| 334 | ||
| 335 | 3097 | type.Namespace = NULL; |
| 336 | 3097 | type.local = NULL; |
| 337 | ||
| 338 | 3097 | type_string = xmlTextReaderGetAttributeNs( |
| 339 | message_handle->reader, "type", XSI_NS); | |
| 340 | 3097 | if(!type_string) |
| 341 | { | |
| 342 | 2610 | goto exit; |
| 343 | } | |
| 344 | ||
| 345 | 487 | type_local = xmlSplitQName2(type_string, &type_prefix); |
| 346 | 487 | if(type_prefix) |
| 347 | { | |
| 348 | 487 | type_ns = xmlTextReaderLookupNamespace( |
| 349 | message_handle->reader, type_prefix); | |
| 350 | 487 | if(!type_ns) |
| 351 | { | |
| 352 | 0 | result = GlobusSoapMessageErrorUndefinedNamespace(type_prefix); |
| 353 | 0 | goto exit; |
| 354 | } | |
| 355 | ||
| 356 | 487 | type.Namespace = globus_libc_strdup(type_ns); |
| 357 | } | |
| 358 | else | |
| 359 | { | |
| 360 | 0 | type.Namespace = NULL; |
| 361 | } | |
| 362 | ||
| 363 | 487 | type.local = globus_libc_strdup(type_local); |
| 364 | ||
| 365 | 487 | GlobusSoapMessageDebugPrintf( |
| 366 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 367 | ("\tLooking for xsi:type {%s}%s:\n", | |
| 368 | type.Namespace, type.local)); | |
| 369 | ||
| 370 | 487 | if(!any_info && registry) |
| 371 | { | |
| 372 | 0 | GlobusSoapMessageDebugPrintf( |
| 373 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 374 | ("\t\tin instance registry\n")); | |
| 375 | ||
| 376 | 0 | result = globus_xsd_type_registry_get( |
| 377 | registry, &type, &any_info); | |
| 378 | 0 | if(result != GLOBUS_SUCCESS) |
| 379 | { | |
| 380 | 0 | result = GlobusSoapMessageErrorFailedRegistryLookup(result, &type); |
| 381 | 0 | goto exit; |
| 382 | } | |
| 383 | ||
| 384 | 0 | if(GlobusSoapMessageDebug(GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS)) |
| 385 | { | |
| 386 | 0 | if(any_info) |
| 387 | { | |
| 388 | 0 | GlobusSoapMessageDebugPrintf( |
| 389 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 390 | ("\t\tFound any info: {%s}%s\n", | |
| 391 | any_info->type->Namespace, any_info->type->local)); | |
| 392 | } | |
| 393 | } | |
| 394 | } | |
| 395 | ||
| 396 | 487 | if(!any_info) |
| 397 | { | |
| 398 | 487 | globus_xsd_type_registry_t message_registry; |
| 399 | ||
| 400 | 487 | GlobusSoapMessageDebugPrintf( |
| 401 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, ("\t\tin message registry\n")); | |
| 402 | ||
| 403 | 487 | globus_soap_message_handle_get_registry(message_handle, |
| 404 | &message_registry); | |
| 405 | 487 | if(message_registry) |
| 406 | { | |
| 407 | 261 | result = globus_xsd_type_registry_get( |
| 408 | message_registry, &type, &any_info); | |
| 409 | 261 | if(result != GLOBUS_SUCCESS) |
| 410 | { | |
| 411 | 0 | result = GlobusSoapMessageErrorFailedRegistryLookup( |
| 412 | result, &type); | |
| 413 | 0 | goto exit; |
| 414 | } | |
| 415 | } | |
| 416 | ||
| 417 | 487 | if(GlobusSoapMessageDebug(GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS)) |
| 418 | { | |
| 419 | 0 | if(any_info) |
| 420 | { | |
| 421 | 0 | GlobusSoapMessageDebugPrintf( |
| 422 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 423 | ("\tFound any info: {%s}%s\n", | |
| 424 | any_info->type->Namespace, | |
| 425 | any_info->type->local)); | |
| 426 | } | |
| 427 | } | |
| 428 | } | |
| 429 | ||
| 430 | 487 | if(!any_info) |
| 431 | { | |
| 432 | 487 | GlobusSoapMessageDebugPrintf( |
| 433 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 434 | ("\t\tin global registry\n")); | |
| 435 | ||
| 436 | 487 | result = globus_xsd_type_registry_get( |
| 437 | GLOBUS_GLOBAL_TYPE_REGISTRY, &type, &any_info); | |
| 438 | 487 | if(result != GLOBUS_SUCCESS) |
| 439 | { | |
| 440 | 0 | result = GlobusSoapMessageErrorFailedRegistryLookup( |
| 441 | result, &type); | |
| 442 | 0 | goto exit; |
| 443 | } | |
| 444 | ||
| 445 | 487 | if(GlobusSoapMessageDebug(GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS)) |
| 446 | { | |
| 447 | 0 | if(any_info) |
| 448 | { | |
| 449 | 0 | GlobusSoapMessageDebugPrintf( |
| 450 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 451 | ("\tFound any info: {%s}%s\n", | |
| 452 | any_info->type->Namespace, | |
| 453 | any_info->type->local)); | |
| 454 | } | |
| 455 | } | |
| 456 | } | |
| 457 | ||
| 458 | 487 | if(!any_info) |
| 459 | { | |
| 460 | 1 | any_info = &globus_xml_buffer_contents_info; |
| 461 | } | |
| 462 | ||
| 463 | exit: | |
| 464 | ||
| 465 | 3097 | *found_any_info = any_info; |
| 466 | ||
| 467 | 3097 | if(type.local) |
| 468 | { | |
| 469 | 487 | free(type.local); |
| 470 | } | |
| 471 | ||
| 472 | 3097 | if(type.Namespace) |
| 473 | { | |
| 474 | 487 | free(type.Namespace); |
| 475 | } | |
| 476 | ||
| 477 | 3097 | if (type_string) |
| 478 | { | |
| 479 | 487 | xmlFree(type_string); |
| 480 | } | |
| 481 | ||
| 482 | 3097 | if (type_local) |
| 483 | { | |
| 484 | 487 | xmlFree(type_local); |
| 485 | } | |
| 486 | ||
| 487 | 3097 | if (type_prefix) |
| 488 | { | |
| 489 | 487 | xmlFree(type_prefix); |
| 490 | } | |
| 491 | ||
| 492 | 3097 | if (type_ns) |
| 493 | { | |
| 494 | 487 | xmlFree(type_ns); |
| 495 | } | |
| 496 | ||
| 497 | 3097 | GlobusSoapMessageDebugEnter(); |
| 498 | 3097 | return result; |
| 499 | } | |
| 500 | ||
| 501 | globus_result_t | |
| 502 | xsd_any_deserialize( | |
| 503 | xsd_QName * element_qname, | |
| 504 | xsd_any * instance, | |
| 505 | globus_soap_message_handle_t message_handle, | |
| 506 | globus_xsd_element_options_t options) | |
| 507 | 627649 | { |
| 508 | 627649 | globus_result_t result = GLOBUS_SUCCESS; |
| 509 | 627649 | xsd_QName * deselem_qname = NULL; |
| 510 | 627649 | int element_exists = 0; |
| 511 | 627649 | GlobusFuncName(xsd_any_deserialize); |
| 512 | 627649 | GlobusSoapMessageDebugEnter(); |
| 513 | ||
| 514 | 627649 | result = globus_soap_message_deserialize_element( |
| 515 | message_handle, NULL); | |
| 516 | 627649 | if(result != GLOBUS_SUCCESS) |
| 517 | { | |
| 518 | 7862 | if(GlobusSoapMessageStatusFailedWithTextCheck(result)) |
| 519 | { | |
| 520 | 1 | element_exists = 0; |
| 521 | 1 | instance->any_info = &globus_xml_buffer_contents_info; |
| 522 | } | |
| 523 | 7861 | else if(!GlobusSoapMessageStatusCheck(result)) |
| 524 | { | |
| 525 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 526 | result, &xsd_any_qname); | |
| 527 | 0 | goto exit; |
| 528 | } | |
| 529 | else | |
| 530 | { | |
| 531 | 619787 | goto exit; |
| 532 | } | |
| 533 | } | |
| 534 | else | |
| 535 | { | |
| 536 | 619787 | element_exists = 1; |
| 537 | 619787 | globus_soap_message_deserialize_push_element(message_handle); |
| 538 | } | |
| 539 | ||
| 540 | 619788 | GlobusSoapMessageDebugPrintf( |
| 541 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, ("\n\nDeserializing xsd:any\n")); | |
| 542 | ||
| 543 | /* only if an element exists, set the instance->element to it */ | |
| 544 | 619788 | if(element_exists) |
| 545 | { | |
| 546 | 619787 | xsd_QName_init(&deselem_qname); |
| 547 | ||
| 548 | 619787 | deselem_qname->local = globus_libc_strdup( |
| 549 | xmlTextReaderConstLocalName( | |
| 550 | message_handle->reader)); | |
| 551 | 619787 | deselem_qname->Namespace = globus_libc_strdup( |
| 552 | xmlTextReaderConstNamespaceUri(message_handle->reader)); | |
| 553 | ||
| 554 | 619787 | instance->element = deselem_qname; |
| 555 | ||
| 556 | /* if instance->any_info isn't set, then look for info in registry | |
| 557 | * based on QName of element | |
| 558 | */ | |
| 559 | 619787 | if(!instance->any_info) |
| 560 | { | |
| 561 | 619787 | result = globus_i_xsd_deserialize_from_element_qname( |
| 562 | deselem_qname, | |
| 563 | &instance->any_info, | |
| 564 | instance->registry, | |
| 565 | message_handle); | |
| 566 | 619787 | if(result != GLOBUS_SUCCESS) |
| 567 | { | |
| 568 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 569 | result, &xsd_any_qname); | |
| 570 | 0 | goto exit; |
| 571 | } | |
| 572 | } | |
| 573 | } | |
| 574 | ||
| 575 | /* no any_info, look for xsi:type */ | |
| 576 | 619788 | if(!instance->any_info) |
| 577 | { | |
| 578 | 3096 | result = globus_i_xsd_deserialize_from_xsi_type( |
| 579 | &instance->any_info, | |
| 580 | instance->registry, | |
| 581 | message_handle); | |
| 582 | 3096 | if(result != GLOBUS_SUCCESS) |
| 583 | { | |
| 584 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 585 | result, &xsd_any_qname); | |
| 586 | 0 | goto exit; |
| 587 | } | |
| 588 | } | |
| 589 | ||
| 590 | 619788 | if(!instance->any_info) |
| 591 | { | |
| 592 | 2609 | instance->any_info = (&globus_xml_buffer_contents_info); |
| 593 | } | |
| 594 | ||
| 595 | 619788 | GlobusSoapMessageDebugPrintf( |
| 596 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 597 | ("Using any info: {%s}%s\n", | |
| 598 | instance->any_info->type->Namespace, | |
| 599 | instance->any_info->type->local)); | |
| 600 | ||
| 601 | 619788 | result = instance->any_info->deserialize( |
| 602 | deselem_qname, | |
| 603 | &instance->value, | |
| 604 | message_handle, | |
| 605 | options); | |
| 606 | 619788 | if(result != GLOBUS_SUCCESS) |
| 607 | { | |
| 608 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 609 | result, instance->any_info->type); | |
| 610 | goto exit; | |
| 611 | } | |
| 612 | ||
| 613 | exit: | |
| 614 | ||
| 615 | 627649 | if(result != GLOBUS_SUCCESS) |
| 616 | { | |
| 617 | 7861 | xsd_any_destroy_contents(instance); |
| 618 | } | |
| 619 | ||
| 620 | 627649 | GlobusSoapMessageDebugExit(); |
| 621 | 627649 | return result; |
| 622 | } | |
| 623 | ||
| 624 | globus_result_t | |
| 625 | xsd_any_deserialize_pointer( | |
| 626 | xsd_QName * element_qname, | |
| 627 | xsd_any ** ip, | |
| 628 | globus_soap_message_handle_t message_handle, | |
| 629 | globus_xsd_element_options_t options) | |
| 630 | 71 | { |
| 631 | 71 | xsd_any * instance; |
| 632 | 71 | xsd_QName * deselem_qname; |
| 633 | 71 | int element_exists; |
| 634 | 71 | globus_result_t result = GLOBUS_SUCCESS; |
| 635 | 71 | GlobusFuncName(xsd_any_deserialize_pointer); |
| 636 | 71 | GlobusSoapMessageDebugEnter(); |
| 637 | ||
| 638 | 71 | result = xsd_any_init(&instance); |
| 639 | 71 | if(result != GLOBUS_SUCCESS) |
| 640 | { | |
| 641 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 642 | result, &xsd_any_qname); | |
| 643 | 0 | goto exit; |
| 644 | } | |
| 645 | ||
| 646 | 71 | result = globus_soap_message_deserialize_element( |
| 647 | message_handle, NULL); | |
| 648 | 71 | if(result != GLOBUS_SUCCESS) |
| 649 | { | |
| 650 | 70 | if(GlobusSoapMessageStatusElementNotFoundCheck(result) || |
| 651 | GlobusSoapMessageStatusFailedWithTextCheck(result)) | |
| 652 | { | |
| 653 | 4 | element_exists = 0; |
| 654 | 4 | instance->any_info = &globus_xml_buffer_contents_info; |
| 655 | 4 | result = GLOBUS_SUCCESS; |
| 656 | } | |
| 657 | 66 | else if(!GlobusSoapMessageStatusCheck(result)) |
| 658 | { | |
| 659 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 660 | result, &xsd_any_qname); | |
| 661 | 0 | goto exit; |
| 662 | } | |
| 663 | else | |
| 664 | { | |
| 665 | 1 | goto exit; |
| 666 | } | |
| 667 | } | |
| 668 | else | |
| 669 | { | |
| 670 | 1 | element_exists = 1; |
| 671 | 1 | globus_soap_message_deserialize_push_element(message_handle); |
| 672 | } | |
| 673 | ||
| 674 | 5 | GlobusSoapMessageDebugPrintf( |
| 675 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, ("\n\nDeserializing xsd:any\n")); | |
| 676 | ||
| 677 | 5 | if(element_exists) |
| 678 | { | |
| 679 | 1 | xsd_QName_init(&deselem_qname); |
| 680 | ||
| 681 | 1 | deselem_qname->local = globus_libc_strdup( |
| 682 | xmlTextReaderConstLocalName(message_handle->reader)); | |
| 683 | 1 | deselem_qname->Namespace = globus_libc_strdup( |
| 684 | xmlTextReaderConstNamespaceUri(message_handle->reader)); | |
| 685 | ||
| 686 | 1 | instance->element = deselem_qname; |
| 687 | ||
| 688 | /* if instance->any_info isn't set, then look for info in registry | |
| 689 | * based on QName of element | |
| 690 | */ | |
| 691 | 1 | if(!instance->any_info) |
| 692 | { | |
| 693 | 1 | result = globus_i_xsd_deserialize_from_element_qname( |
| 694 | deselem_qname, | |
| 695 | &instance->any_info, | |
| 696 | instance->registry, | |
| 697 | message_handle); | |
| 698 | 1 | if(result != GLOBUS_SUCCESS) |
| 699 | { | |
| 700 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 701 | result, &xsd_any_qname); | |
| 702 | 0 | goto exit; |
| 703 | } | |
| 704 | } | |
| 705 | } | |
| 706 | ||
| 707 | /* no any_info, look for xsi:type */ | |
| 708 | 5 | if(!instance->any_info) |
| 709 | { | |
| 710 | 1 | result = globus_i_xsd_deserialize_from_xsi_type( |
| 711 | &instance->any_info, | |
| 712 | instance->registry, | |
| 713 | message_handle); | |
| 714 | 1 | if(result != GLOBUS_SUCCESS) |
| 715 | { | |
| 716 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 717 | result, &xsd_any_qname); | |
| 718 | 0 | goto exit; |
| 719 | } | |
| 720 | } | |
| 721 | ||
| 722 | 5 | if(!instance->any_info) |
| 723 | { | |
| 724 | 1 | instance->any_info = (&globus_xml_buffer_contents_info); |
| 725 | } | |
| 726 | ||
| 727 | 5 | GlobusSoapMessageDebugPrintf( |
| 728 | GLOBUS_SOAP_MESSAGE_DEBUG_WILDCARDS, | |
| 729 | ("Using any info: {%s}%s\n", | |
| 730 | instance->any_info->type->Namespace, | |
| 731 | instance->any_info->type->local)); | |
| 732 | ||
| 733 | 5 | result = instance->any_info->deserialize( |
| 734 | deselem_qname, | |
| 735 | &instance->value, | |
| 736 | message_handle, | |
| 737 | options); | |
| 738 | 5 | if(result != GLOBUS_SUCCESS) |
| 739 | { | |
| 740 | 0 | result = GlobusSoapMessageErrorDeserializeFailed( |
| 741 | result, instance->any_info->type); | |
| 742 | 0 | goto exit; |
| 743 | } | |
| 744 | ||
| 745 | 5 | *ip = instance; |
| 746 | ||
| 747 | exit: | |
| 748 | ||
| 749 | 71 | if(result != GLOBUS_SUCCESS) |
| 750 | { | |
| 751 | 66 | xsd_any_destroy(instance); |
| 752 | } | |
| 753 | ||
| 754 | 71 | GlobusSoapMessageDebugExit(); |
| 755 | 71 | return result; |
| 756 | } | |
| 757 |