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