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 /*
14  * This file is automatically generated by the Globus WSDLtoC converter
15  */
16
17 #include "xsd_QName.h"
18 #include "globus_soap_message.h"
19 #include "globus_xsd_type_info.h"
20 #include "wsu_ContextType.h"
21
22 #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
23 xsd_QName wsu_ContextType_qname =
24 {
25     WSU_CONTEXTTYPE_NS,
26     WSU_CONTEXTTYPE_LOCAL
27 };
28 #endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */
29
30 globus_result_t
31 wsu_ContextType_serialize_wrapper(
32     xsd_QName *                         element_qname,
33     void *                              instance,
34     globus_soap_message_handle_t        message_handle,
35     globus_xsd_element_options_t        options)
36 0 {
37 0     return wsu_ContextType_serialize(
38         element_qname,
39         (wsu_ContextType *) instance,
40         message_handle, options);
41 }
42
43 globus_result_t
44 wsu_ContextType_deserialize_pointer_wrapper(
45     xsd_QName *                         element_qname,
46     void **                             ip,
47     globus_soap_message_handle_t        message_handle,
48     globus_xsd_element_options_t        options)
49 0 {
50 0     return wsu_ContextType_deserialize_pointer(
51         element_qname,
52         (wsu_ContextType **) ip,
53         message_handle, options);
54 }
55
56 globus_result_t
57 wsu_ContextType_init_wrapper(void **object)
58 0 {
59 0     return wsu_ContextType_init(
60         (wsu_ContextType **) object);
61 }
62
63 void
64 wsu_ContextType_destroy_wrapper(
65     void *                          object)
66 0 {
67 0     wsu_ContextType_destroy(
68         (wsu_ContextType *) object);
69 }
70
71 globus_result_t
72 wsu_ContextType_copy_wrapper(
73     void **                         dest_obj,
74     void *                          src_obj)
75 0 {
76 0     return wsu_ContextType_copy(
77         (wsu_ContextType **) dest_obj,
78         (wsu_ContextType *) src_obj);
79 }
80
81 globus_result_t
82 wsu_ContextType_init_contents_wrapper(void *object)
83 0 {
84 0     return wsu_ContextType_init_contents(
85         (wsu_ContextType *) object);
86 }
87
88 void
89 wsu_ContextType_destroy_contents_wrapper(
90     void *                          object)
91 0 {
92 0     wsu_ContextType_destroy_contents(
93         (wsu_ContextType *) object);
94 }
95
96 globus_result_t
97 wsu_ContextType_copy_contents_wrapper(
98     void *                          dest_obj,
99     void *                          src_obj)
100 0 {
101 0     return wsu_ContextType_copy_contents(
102         (wsu_ContextType *) dest_obj,
103         (wsu_ContextType *) src_obj);
104 }
105
106 globus_result_t
107 wsu_ContextType_serialize_contents_wrapper(
108     xsd_QName *                         element_qname,
109     void *                              instance,
110     globus_soap_message_handle_t        message_handle,
111     globus_xsd_element_options_t        options)
112 0 {
113 0     return wsu_ContextType_serialize_contents(
114         element_qname,
115         (wsu_ContextType *) instance,
116         message_handle, options);
117 }
118
119 globus_result_t
120 wsu_ContextType_deserialize_contents_wrapper(
121     xsd_QName *                         element_qname,
122     void **                             instance,
123     globus_soap_message_handle_t        message_handle,
124     globus_xsd_element_options_t        options)
125 0 {
126 0     globus_result_t                     result;
127 0     GlobusFuncName(wsu_ContextType_deserialize_contents_wrapper);
128 0     GlobusSoapMessageDebugEnter();
129
130 0     if(!*instance)
131     {
132 0         result = wsu_ContextType_init(
133             (wsu_ContextType **)instance);
134 0         if(result != GLOBUS_SUCCESS)
135         {
136 0             goto error;
137         }
138     }
139
140 0     result = wsu_ContextType_deserialize_contents(
141         element_qname,
142         *(wsu_ContextType **)instance,
143         message_handle, options);
144 error:
145 0     GlobusSoapMessageDebugExit();
146 0     return result;
147 }
148
149 globus_result_t
150 wsu_ContextType_array_serialize_wrapper(
151     xsd_QName *                     element,
152     void *                          instance,
153     globus_soap_message_handle_t    message,
154     globus_xsd_element_options_t    options)
155 0 {
156 0     return wsu_ContextType_array_serialize(
157         element,
158         (wsu_ContextType_array *) instance,
159         message, options);
160 }
161
162 globus_result_t
163 wsu_ContextType_array_deserialize_wrapper(
164     xsd_QName *                         element_qname,
165     void **                             inst,
166     globus_soap_message_handle_t        message,
167     globus_xsd_element_options_t        options)
168 0 {
169 0     if(!*inst)
170     {
171 0         globus_result_t                 result;
172
173 0         result = wsu_ContextType_array_init(
174             (wsu_ContextType_array **)inst);
175 0         if(result != GLOBUS_SUCCESS)
176         {
177 0             return result;
178         }
179     }
180
181 0     return wsu_ContextType_array_deserialize(
182         element_qname,
183         *(wsu_ContextType_array **) inst,
184         message, options);
185 }
186
187 globus_result_t
188 wsu_ContextType_array_init_wrapper(
189     void **                             arr)
190 0 {
191 0     return wsu_ContextType_array_init(
192         (wsu_ContextType_array **) arr);
193 }
194
195 void
196 wsu_ContextType_array_destroy_wrapper(
197     void *                              arr)
198 0 {
199 0     wsu_ContextType_array_destroy(
200         (wsu_ContextType_array *) arr);
201 }
202
203 globus_result_t
204 wsu_ContextType_array_copy_wrapper(
205     void **                             dest_arr,
206     void *                              src_arr)
207 0 {
208 0     return wsu_ContextType_array_copy(
209         (wsu_ContextType_array **) dest_arr,
210         (wsu_ContextType_array *) src_arr);
211 }
212
213 globus_result_t
214 wsu_ContextType_array_init_contents_wrapper(
215     void *                              arr)
216 0 {
217 0     return wsu_ContextType_array_init_contents(
218         (wsu_ContextType_array *) arr);
219 }
220
221 void
222 wsu_ContextType_array_destroy_contents_wrapper(
223     void *                              arr)
224 0 {
225 0     wsu_ContextType_array_destroy_contents(
226         (wsu_ContextType_array *) arr);
227 }
228
229 globus_result_t
230 wsu_ContextType_array_copy_contents_wrapper(
231     void *                              dest_arr,
232     void *                              src_arr)
233 0 {
234 0     return wsu_ContextType_array_copy_contents(
235         (wsu_ContextType_array *) dest_arr,
236         (wsu_ContextType_array *) src_arr);
237 }
238
239 struct globus_xsd_type_info_s wsu_ContextType_contents_info =
240 {
241     &wsu_ContextType_qname,
242     wsu_ContextType_serialize_contents_wrapper,
243     wsu_ContextType_deserialize_contents_wrapper,
244     wsu_ContextType_init_wrapper,
245     wsu_ContextType_destroy_wrapper,
246     wsu_ContextType_copy_wrapper,
247     wsu_ContextType_init_contents_wrapper,
248     wsu_ContextType_destroy_contents_wrapper,
249     wsu_ContextType_copy_contents_wrapper,
250     sizeof(wsu_ContextType),
251     NULL,
252     NULL,
253     NULL
254 };
255
256 struct globus_xsd_type_info_s wsu_ContextType_array_info =
257 {
258     &wsu_ContextType_qname,
259     wsu_ContextType_array_serialize_wrapper,
260     wsu_ContextType_array_deserialize_wrapper,
261     wsu_ContextType_array_init_wrapper,
262     wsu_ContextType_array_destroy_wrapper,
263     wsu_ContextType_array_copy_wrapper,
264     wsu_ContextType_array_init_contents_wrapper,
265     wsu_ContextType_array_destroy_contents_wrapper,
266     wsu_ContextType_array_copy_contents_wrapper,
267     sizeof(wsu_ContextType),
268     wsu_ContextType_array_push_wrapper,
269     NULL,
270     NULL
271 };
272
273 struct globus_xsd_type_info_s wsu_ContextType_info =
274 {
275     &wsu_ContextType_qname,
276     wsu_ContextType_serialize_wrapper,
277     wsu_ContextType_deserialize_pointer_wrapper,
278     wsu_ContextType_init_wrapper,
279     wsu_ContextType_destroy_wrapper,
280     wsu_ContextType_copy_wrapper,
281     wsu_ContextType_init_contents_wrapper,
282     wsu_ContextType_destroy_contents_wrapper,
283     wsu_ContextType_copy_contents_wrapper,
284     sizeof(wsu_ContextType),
285     NULL,
286     &wsu_ContextType_contents_info,
287     &wsu_ContextType_array_info
288 };
289
290 globus_result_t
291 wsu_ContextType_init_contents(
292     wsu_ContextType * instance)
293 0 {
294 0     globus_result_t                     result = GLOBUS_SUCCESS;
295 0     GlobusFuncName(wsu_ContextType_init_contents);
296 0     GlobusSoapMessageDebugEnter();
297
298 0     memset(instance, 0, sizeof(wsu_ContextType));
299
300 0     GlobusSoapMessageDebugExit();
301 0     return result;
302 }
303
304 globus_result_t
305 wsu_ContextType_init(
306     wsu_ContextType ** object)
307 0 {
308 0     wsu_ContextType * instance;
309 0     globus_result_t                     result = GLOBUS_SUCCESS;
310 0     GlobusFuncName(wsu_ContextType_init);
311 0     GlobusSoapMessageDebugEnter();
312
313 0     instance = globus_malloc(sizeof(wsu_ContextType));
314 0     if(!instance)
315     {
316 0         result = GlobusSoapMessageErrorOutOfMemory;
317 0         goto exit;
318     }
319
320 0     memset(instance, 0, sizeof(wsu_ContextType));
321
322 0     *object = instance;
323
324  exit:
325 0     GlobusSoapMessageDebugExit();
326 0     return result;
327 }
328
329 void
330 wsu_ContextType_destroy(
331     wsu_ContextType * instance)
332 0 {
333 0     GlobusFuncName(wsu_ContextType_destroy);
334 0     GlobusSoapMessageDebugEnter();
335
336 0     if(!instance)
337     {
338 0         goto exit;
339     }
340
341 0     wsu_ContextType_destroy_contents(instance);
342 0     globus_free(instance);
343
344  exit:
345
346 0     GlobusSoapMessageDebugExit();
347 }
348
349 void
350 wsu_ContextType_destroy_contents(
351     wsu_ContextType * instance)
352 0 {
353 0     GlobusFuncName(wsu_ContextType_destroy_contents);
354 0     GlobusSoapMessageDebugEnter();
355
356 0     if(instance)
357     {
358
359
360 0     wsu_AttributedDateTime_destroy(instance->Expires);
361 0     instance->Expires = NULL;
362
363 0     wsu_AttributedURI_destroy_contents(
364          &instance->Identifier);
365
366 0         xsd_anyAttributes_destroy(instance->anyAttributes);
367 0         instance->anyAttributes = NULL;
368
369 0     if(instance->_Id)
370     {
371 0         xsd_ID_destroy(
372             instance->_Id);
373 0         instance->_Id = NULL;
374     }
375
376 0     xsd_any_array_destroy_contents(&instance->any);
377
378     }
379
380 0     GlobusSoapMessageDebugExit();
381 }
382
383 globus_result_t
384 wsu_ContextType_copy(
385     wsu_ContextType ** dest_obj,
386     const wsu_ContextType * src_obj)
387 0 {
388 0     globus_result_t                     result = GLOBUS_SUCCESS;
389 0     wsu_ContextType * instance;
390 0     GlobusFuncName(wsu_ContextType_copy);
391
392 0     GlobusSoapMessageDebugEnter();
393
394 0     instance = malloc(sizeof(wsu_ContextType));
395 0     if (instance == NULL)
396     {
397 0         GlobusSoapMessageDebugExit();
398 0         return GlobusSoapMessageErrorOutOfMemory;
399     }
400
401 0     result = wsu_ContextType_copy_contents(instance, src_obj);
402 0     if(result != GLOBUS_SUCCESS)
403     {
404 0         globus_free(instance);
405 0         GlobusSoapMessageDebugExit();
406 0         return GlobusSoapMessageErrorOutOfMemory;
407     }
408
409 0     *dest_obj = instance;
410 0     GlobusSoapMessageDebugExit();
411 0     return result;
412 }
413
414 globus_result_t
415 wsu_ContextType_copy_contents(
416     wsu_ContextType * instance,
417     const wsu_ContextType * src_obj)
418 0 {
419 0     globus_result_t                     result = GLOBUS_SUCCESS;
420 0     GlobusFuncName(wsu_ContextType_copy_contents);
421
422 0     GlobusSoapMessageDebugEnter();
423
424
425 0     if(src_obj->anyAttributes)
426     {
427 0         result = xsd_anyAttributes_copy(&instance->anyAttributes, 
428                                         src_obj->anyAttributes);
429 0         if(result != GLOBUS_SUCCESS)
430         {
431 0             result = GlobusSoapMessageErrorCopyAnyAttrsFailed(
432                 result, NULL);
433 0             goto xsd_anyAttributes_after_destroy;
434         }
435     }
436     else
437     {
438 0         instance->anyAttributes = NULL;
439     }
440
441 0     if(src_obj->_Id)
442     {
443 0         result = xsd_ID_copy(
444             &instance->_Id,
445             src_obj->_Id);
446 0         if(result != GLOBUS_SUCCESS)
447         {
448 0             result = GlobusSoapMessageErrorCopyFailed(
449                 result, NULL, &xsd_ID_qname);
450 0             goto _Id_destroy;
451         }
452     }
453     else
454     {
455 0         instance->_Id = NULL;
456     }
457
458 0     if(src_obj->Expires)
459     {
460 0         result = wsu_AttributedDateTime_copy(
461             &instance->Expires,
462             src_obj->Expires);
463 0         if(result != GLOBUS_SUCCESS)
464         {
465 0             result = GlobusSoapMessageErrorCopyFailed(
466                 result, NULL, &wsu_AttributedDateTime_qname);
467 0             goto Expires_destroy_pointer;
468         }
469     }
470     else
471     {
472 0         instance->Expires = NULL;
473     }
474
475 0     result = wsu_AttributedURI_copy_contents(
476         &instance->Identifier,
477         &src_obj->Identifier);
478 0     if(result != GLOBUS_SUCCESS)
479     {
480 0         result = GlobusSoapMessageErrorCopyFailed(
481                 result, NULL, &wsu_AttributedURI_qname);
482 0         goto Identifier_destroy;
483     }
484     
485 0      result = xsd_any_array_copy_contents(
486          &instance->any,
487          &src_obj->any);
488 0      if(result != GLOBUS_SUCCESS)
489      {
490 0          result = GlobusSoapMessageErrorCopyFailed(
491              result, NULL, &xsd_any_qname);
492 0          goto any_destroy_array;
493      }
494
495 0     goto exit;
496
497  fail_deserialize:
498
499  xsd_anyAttributes_destroy:
500 0         xsd_anyAttributes_destroy(instance->anyAttributes);
501 0         instance->anyAttributes = NULL;
502  xsd_anyAttributes_after_destroy:
503 0         wsu_AttributedDateTime_destroy(
504             instance->Expires);
505 0          instance->Expires = NULL;
506
507  Expires_destroy_pointer:
508 0         wsu_AttributedURI_destroy_contents(
509              &instance->Identifier);
510
511  Identifier_destroy:
512
513  _Id_destroy:
514
515 0     if(instance->_Id)
516     {
517 0         xsd_ID_destroy(
518             instance->_Id);
519 0         instance->_Id = NULL;
520     }
521 0         xsd_any_array_destroy_contents(
522             &instance->any);
523
524  any_destroy_array:
525
526
527  exit:
528
529 0     GlobusSoapMessageDebugExit();
530 0     return result;
531 }
532
533
534
535 globus_result_t
536 wsu_ContextType_serialize_contents(
537     xsd_QName *                         element_qname, /* ignored */
538     wsu_ContextType * inst,
539     globus_soap_message_handle_t        message_handle,
540     globus_xsd_element_options_t        options)
541 0 {
542 0     globus_result_t                     result = GLOBUS_SUCCESS;
543 0     GlobusFuncName(wsu_ContextType_serialize_contents);
544 0     GlobusSoapMessageDebugEnter();
545
546 0     result = wsu_ContextType_serialize(
547         NULL,
548         inst,
549         message_handle,
550         options | GLOBUS_XSD_ELEMENT_CONTENTS_ONLY);
551 0     if(result != GLOBUS_SUCCESS)
552     {
553 0         result = GlobusSoapMessageErrorSerializeFailed(
554             result, NULL, element_qname);
555         goto exit;
556     }
557
558  exit:
559
560 0     GlobusSoapMessageDebugExit();
561 0     return result;
562 }
563
564
565
566 globus_result_t
567 wsu_ContextType_serialize(
568     xsd_QName *                         element_qname,
569     wsu_ContextType * instance,
570     globus_soap_message_handle_t        message_handle,
571     globus_xsd_element_options_t        options)
572 0 {
573 0     globus_result_t                     result = GLOBUS_SUCCESS;
574 0     xsd_QName                           subelement;
575 0     globus_list_t *                     any_attr_keys = NULL;
576 0     globus_list_t *                     any_attr_keys_iterator = NULL;
577 0     xsd_QName *                         type_attr = NULL;
578 0     char *                              prefix = NULL;
579 0     int                                 prefix_created;
580 0     int                                 define_prefix = 0;
581 0     int                                 save_options = options;
582
583 0     GlobusFuncName(wsu_ContextType_serialize);
584 0     GlobusSoapMessageDebugEnter();
585
586
587 0     if(!(options & GLOBUS_XSD_ELEMENT_CONTENTS_ONLY))
588     {
589         /* serialize wsu_ContextType element */
590
591 0         result = globus_soap_message_invoke_ns_callouts(
592             message_handle,
593             element_qname,
594             GLOBUS_SOAP_MESSAGE_CALLOUT_NS_SET,
595             &options);
596 0         if(result != GLOBUS_SUCCESS)
597         {
598 0             result = GlobusSoapMessageErrorSerializeFailed(
599                 result, NULL, element_qname);
600 0             goto exit;
601         }
602
603 0 result = globus_soap_message_element_ns_set(
604             message_handle,
605             element_qname->Namespace,
606             &options);
607 0         if(result != GLOBUS_SUCCESS)
608         {
609 0             result = GlobusSoapMessageErrorSerializeFailed(
610                 result, NULL, element_qname);
611 0             goto exit;
612         }
613
614 0         result = xsd_anyAttributes_namespace_set(
615             message_handle, instance->anyAttributes, &options);
616 0         if(result != GLOBUS_SUCCESS)
617         {
618 0             result = GlobusSoapMessageErrorSerializeAnyAttrsFailed(
619                 result, "Failed to set namespace");
620 0             goto exit;
621         }
622
623 0         if(instance->_Id)
624         {
625
626 0         result = globus_soap_message_attribute_ns_set(
627             message_handle,
628             "http://schemas.xmlsoap.org/ws/2002/07/utility",
629              &options);
630
631 0         if(result != GLOBUS_SUCCESS)
632         {
633 0             xsd_QName               error_qname;
634 0             error_qname.local = prefix;
635 0             error_qname.Namespace = "http://schemas.xmlsoap.org/ws/2002/07/utility";
636 0             result = GlobusSoapMessageErrorSerializeFailed(result, 
637                                                            NULL, 
638                                                            &error_qname);
639 0             goto exit;
640         }
641
642
643         }
644
645 0         if((options & GLOBUS_XSD_ELEMENT_TYPE_ATTR) &&
646    !globus_soap_message_serialize_is_c14n_subset(message_handle))
647         {
648 0             result = globus_soap_message_attribute_ns_set(
649                 message_handle,
650                 "http://www.w3.org/2001/XMLSchema-instance",
651                 &options);
652 0             if(result != GLOBUS_SUCCESS)
653             {
654 0                 result = GlobusSoapMessageErrorSerializeFailed(
655                     result, NULL, element_qname);
656 0                 goto exit;
657             }
658
659 0             result = globus_soap_message_attribute_ns_set(
660                 message_handle,
661                 wsu_ContextType_qname.Namespace,
662                 &options);
663 0             if(result != GLOBUS_SUCCESS)
664             {
665 0                 result = GlobusSoapMessageErrorSerializeFailed(
666                     result, NULL, element_qname);
667 0                 goto exit;
668             }
669         }
670
671 0         result = globus_soap_message_invoke_callouts(
672             message_handle,
673             element_qname,
674             GLOBUS_SOAP_MESSAGE_CALLOUT_BEGIN);
675 0         if(result != GLOBUS_SUCCESS)
676         {
677 0             result = GlobusSoapMessageErrorSerializeFailed(
678                 result, NULL, element_qname);
679 0             goto exit;
680         }
681
682 0         result = globus_soap_message_serialize_element(
683             message_handle,
684             element_qname,
685             options,
686             &wsu_ContextType_qname);
687 0         if(result != GLOBUS_SUCCESS)
688         {
689 0             result = GlobusSoapMessageErrorSerializeFailed(
690                 result, NULL, element_qname);
691 0             goto exit;
692         }
693
694 0         if((options & GLOBUS_XSD_ELEMENT_TYPE_ATTR) &&
695    !globus_soap_message_serialize_is_c14n_subset(message_handle))
696         {
697 0            xsd_QName_init(&type_attr);
698        
699 0            type_attr->local = globus_libc_strdup("type");
700 0            type_attr->Namespace = globus_libc_strdup(XSI_NS);
701         }
702
703         /* serialize namespaces */
704         
705 0 result = globus_soap_message_invoke_ns_callouts(
706             message_handle,
707             element_qname,
708             GLOBUS_SOAP_MESSAGE_CALLOUT_NS_ADD,
709             &options);
710 0         if(result != GLOBUS_SUCCESS)
711         {
712 0             result = GlobusSoapMessageErrorSerializeFailed(
713                 result, NULL, element_qname);
714 0             goto exit;
715         }
716
717 0 result = globus_soap_message_element_ns_add(
718             message_handle,
719             element_qname->Namespace,
720             &options);
721 0         if(result != GLOBUS_SUCCESS)
722         {
723 0             result = GlobusSoapMessageErrorSerializeFailed(
724                 result, NULL, element_qname);
725 0             goto exit;
726         }
727
728 0         result = xsd_anyAttributes_namespace_add(
729             message_handle, instance->anyAttributes, &options);
730 0         if(result != GLOBUS_SUCCESS)
731         {
732 0             result = GlobusSoapMessageErrorSerializeAnyAttrsFailed(
733                 result, "Failed to add namespace");
734 0             goto exit;
735         }
736
737 0         if(instance->_Id)
738         {
739
740 0         result = globus_soap_message_attribute_ns_add(
741             message_handle,
742             "http://schemas.xmlsoap.org/ws/2002/07/utility",
743              &options);
744
745 0         if(result != GLOBUS_SUCCESS)
746         {
747 0             xsd_QName               error_qname;
748 0             error_qname.local = prefix;
749 0             error_qname.Namespace = "http://schemas.xmlsoap.org/ws/2002/07/utility";
750 0             result = GlobusSoapMessageErrorSerializeFailed(result, 
751                                                            NULL, 
752                                                            &error_qname);
753 0             goto exit;
754         }
755
756
757         }
758
759 0         if((options & GLOBUS_XSD_ELEMENT_TYPE_ATTR) &&
760    !globus_soap_message_serialize_is_c14n_subset(message_handle))
761         {
762 0             result = globus_soap_message_attribute_ns_add(
763                 message_handle,
764                 "http://www.w3.org/2001/XMLSchema-instance",
765                 &options);
766 0             if(result != GLOBUS_SUCCESS)
767             {
768 0                 result = GlobusSoapMessageErrorSerializeFailed(
769                     result, NULL, element_qname);
770 0                 goto exit;
771             }
772
773 0             result = globus_soap_message_attribute_ns_add(
774                 message_handle,
775                 wsu_ContextType_qname.Namespace,
776                 &options);
777 0             if(result != GLOBUS_SUCCESS)
778             {
779 0                 result = GlobusSoapMessageErrorSerializeFailed(
780                     result, NULL, element_qname);
781 0                 goto exit;
782             }
783         }
784
785         /* serialize attributes */
786
787 0         if(instance->anyAttributes)
788         {
789 0             any_attr_keys = xsd_anyAttributes_lex_sort(
790                 instance->anyAttributes);
791 0             any_attr_keys_iterator = any_attr_keys;
792         }
793
794 0         subelement.Namespace = "http://schemas.xmlsoap.org/ws/2002/07/utility";
795 0         subelement.local = "Id";
796
797 0         if(any_attr_keys_iterator)
798         {
799 0             result = xsd_anyAttributes_serialize_lex_before(
800                 message_handle,
801                 &any_attr_keys_iterator,
802                 instance->anyAttributes,
803                 &subelement);
804 0             if(result != GLOBUS_SUCCESS)
805             {
806 0                 result = GlobusSoapMessageErrorSerializeFailed(result, 
807                                                                NULL, 
808                                                                element_qname);
809 0                 goto exit;
810             }
811         }
812
813 0         if(instance->_Id)
814         {
815
816 0         result = xsd_ID_serialize_attribute(
817             &subelement,
818             instance->_Id,
819             message_handle,
820             options & (~GLOBUS_XSD_ELEMENT_SET_DEFAULT_NS));
821 0         if(result != GLOBUS_SUCCESS)
822         {
823 0             result = GlobusSoapMessageErrorSerializeFailed(result, 
824                                                            NULL, 
825                                                            element_qname);
826 0             goto exit;
827         }
828
829         }
830
831 0         if(any_attr_keys_iterator)
832         {
833 0             result = xsd_anyAttributes_serialize_lex_before(
834                 message_handle,
835                 &any_attr_keys_iterator,
836                 instance->anyAttributes,
837                 &subelement);
838 0             if(result != GLOBUS_SUCCESS)
839             {
840 0                 result = GlobusSoapMessageErrorSerializeFailed(result, 
841                                                                NULL, 
842                                                                element_qname);
843 0                 goto exit;
844             }
845         }
846
847 0         if((options & GLOBUS_XSD_ELEMENT_TYPE_ATTR) &&
848    !globus_soap_message_serialize_is_c14n_subset(message_handle))
849         {
850 0             result = globus_soap_message_serialize_QName_attribute(
851                 message_handle,
852                 type_attr,
853                 &wsu_ContextType_qname);
854 0             if(result != GLOBUS_SUCCESS)
855             {
856 0                 result = GlobusSoapMessageErrorSerializeFailed(
857                     result, NULL, element_qname);
858 0                 goto exit;
859             }
860         }
861
862
863 0         result = globus_soap_message_invoke_callouts(
864             message_handle,
865             element_qname,
866             GLOBUS_SOAP_MESSAGE_CALLOUT_ATTR);
867 0         if(result != GLOBUS_SUCCESS)
868         {
869 0             result = GlobusSoapMessageErrorSerializeFailed(
870                 result, NULL, element_qname);
871 0             goto exit;
872         }
873     }
874
875 0     if(!(options & GLOBUS_XSD_ELEMENT_CONTENTS_ONLY))
876     {
877 0         result = globus_soap_message_serialize_element_begin_close(
878             message_handle);
879 0         if(result != GLOBUS_SUCCESS)
880         {
881 0             result = GlobusSoapMessageErrorSerializeFailed(
882                 result, NULL, element_qname);
883 0             goto exit;
884         }
885     }
886 0     options &= ~GLOBUS_XSD_ELEMENT_CONTENTS_ONLY;
887
888     /* serialize contents of type */
889
890 0     subelement.local = "Expires";
891 0     subelement.Namespace = "http://schemas.xmlsoap.org/ws/2002/07/utility";
892
893 0     if(instance->Expires)
894     {
895 0         result = wsu_AttributedDateTime_serialize(
896             &subelement,
897             instance->Expires,
898             message_handle,
899             options & (~GLOBUS_XSD_ELEMENT_SET_DEFAULT_NS));
900 0         if(result != GLOBUS_SUCCESS)
901         {
902 0             result = GlobusSoapMessageErrorSerializeFailed(
903                 result, NULL, &wsu_AttributedDateTime_qname);
904 0             goto exit;
905         }
906     }
907
908 0     subelement.local = "Identifier";
909 0     subelement.Namespace = "http://schemas.xmlsoap.org/ws/2002/07/utility";
910
911 0     result = wsu_AttributedURI_serialize(
912          &subelement,
913          &instance->Identifier,
914          message_handle,
915          options & (~GLOBUS_XSD_ELEMENT_SET_DEFAULT_NS));
916 0     if(result != GLOBUS_SUCCESS)
917     {
918 0         result = GlobusSoapMessageErrorSerializeFailed(
919                 result, NULL, &wsu_AttributedURI_qname);
920 0         goto exit;
921     }
922
923 0     subelement.local = "any";
924 0     subelement.Namespace = "http://www.w3.org/2001/XMLSchema";
925     
926 0      result = xsd_any_array_serialize(
927          &subelement,
928          &instance->any,
929          message_handle,
930          options & (~GLOBUS_XSD_ELEMENT_SET_DEFAULT_NS));
931 0      if(result != GLOBUS_SUCCESS)
932      {
933 0          result = GlobusSoapMessageErrorSerializeFailed(
934              result, NULL, &xsd_any_qname);
935 0          goto exit;
936      }
937
938 0     options = save_options;
939
940 0     if(!(options & GLOBUS_XSD_ELEMENT_CONTENTS_ONLY))
941     {
942         /* add end element */
943 0         result = globus_soap_message_serialize_element_end(
944             message_handle,
945             element_qname,
946             options,
947             &wsu_ContextType_qname);
948 0         if(result != GLOBUS_SUCCESS)
949         {
950 0             result = GlobusSoapMessageErrorSerializeFailed(
951                 result, NULL, element_qname);
952 0             goto exit;
953         }
954
955 0         globus_soap_message_element_ns_remove(
956             message_handle,
957             element_qname->Namespace,
958             &options);
959
960     /* remove namespace/prefix mappings for these types */
961
962 0         result = xsd_anyAttributes_namespace_remove(
963             message_handle, instance->anyAttributes, &options);
964 0         if(result != GLOBUS_SUCCESS)
965         {
966 0             result = GlobusSoapMessageErrorSerializeAnyAttrsFailed(
967                 result, "Failed to remove namespace");
968 0             goto exit;
969         }
970
971 0         if(instance->_Id)
972         {
973
974 0         globus_soap_message_attribute_ns_remove(
975             message_handle,
976             "http://schemas.xmlsoap.org/ws/2002/07/utility",
977              &options);
978
979         }
980
981 0         if((options & GLOBUS_XSD_ELEMENT_TYPE_ATTR) &&
982    !globus_soap_message_serialize_is_c14n_subset(message_handle))
983         {
984 0             globus_soap_message_attribute_ns_remove(
985                 message_handle,
986                 "http://www.w3.org/2001/XMLSchema-instance",
987                 &options);
988            
989 0             globus_soap_message_attribute_ns_remove(
990                 message_handle,
991                 wsu_ContextType_qname.Namespace,
992                 &options);
993         }           
994
995 0         result = globus_soap_message_invoke_ns_callouts(
996             message_handle,
997             element_qname,
998             GLOBUS_SOAP_MESSAGE_CALLOUT_NS_REMOVE,
999             &options);
1000 0         if(result != GLOBUS_SUCCESS)
1001         {
1002 0             result  = GlobusSoapMessageErrorSerializeFailed(
1003                 result, NULL, element_qname);
1004 0             goto exit;
1005         }
1006
1007 0         result = globus_soap_message_invoke_callouts(
1008             message_handle,
1009             element_qname,
1010             GLOBUS_SOAP_MESSAGE_CALLOUT_END);
1011 0         if(result != GLOBUS_SUCCESS)
1012         {
1013 0             result = GlobusSoapMessageErrorSerializeFailed(
1014                 result, NULL, element_qname);
1015             goto exit;
1016         }
1017     }
1018
1019  exit:
1020 0     if (type_attr)
1021     {
1022 0         xsd_QName_destroy(type_attr);
1023     }
1024
1025 0     if(any_attr_keys)
1026     {
1027 0         globus_list_free(any_attr_keys);
1028     }
1029
1030 0     GlobusSoapMessageDebugExit();
1031 0     return result;
1032 }
1033
1034
1035
1036 globus_result_t
1037 wsu_ContextType_deserialize_contents(
1038     xsd_QName *                         element_qname, /* ignored */
1039     wsu_ContextType * inst,
1040     globus_soap_message_handle_t        message_handle,
1041     globus_xsd_element_options_t        options)
1042 0 {
1043 0     globus_result_t                     result = GLOBUS_SUCCESS;
1044 0     GlobusFuncName(wsu_ContextType_deserialize_contents);
1045 0     GlobusSoapMessageDebugEnter();
1046
1047 0     result = wsu_ContextType_deserialize(
1048         NULL,
1049         inst,
1050         message_handle,
1051         options | GLOBUS_XSD_ELEMENT_CONTENTS_ONLY);
1052 0     if(result != GLOBUS_SUCCESS)
1053     {
1054 0         result = GlobusSoapMessageErrorDeserializeFailed(
1055             result, element_qname);
1056         goto exit;
1057     }
1058
1059  exit:
1060
1061 0     GlobusSoapMessageDebugExit();
1062 0     return result;
1063 }
1064
1065
1066
1067 globus_result_t
1068 wsu_ContextType_deserialize(
1069     xsd_QName *                         element_qname,
1070     wsu_ContextType * instance,
1071     globus_soap_message_handle_t        message_handle,
1072     globus_xsd_element_options_t        options)
1073 0 {
1074 0     globus_result_t                     result = GLOBUS_SUCCESS;
1075 0     xsd_QName                           subelement;
1076 0     GlobusFuncName(wsu_ContextType_deserialize);
1077 0     GlobusSoapMessageDebugEnter();
1078
1079
1080 0     if(!(options & GLOBUS_XSD_ELEMENT_CONTENTS_ONLY))
1081     {
1082 0         result = globus_soap_message_deserialize_element(
1083             message_handle, element_qname);
1084 0         if(result != GLOBUS_SUCCESS)
1085         {
1086 0             result = GlobusSoapMessageErrorDeserializeFailed(
1087                 result, element_qname);
1088 0             goto exit;
1089         }
1090
1091 0         result = xsd_anyAttributes_init(&instance->anyAttributes);
1092 0         if(result != GLOBUS_SUCCESS)
1093         {
1094 0             result = GlobusSoapMessageErrorDeserializeFailed(
1095                 result, element_qname);
1096 0             goto xsd_anyAttributes_after_destroy;
1097         }
1098
1099 0         result = xsd_anyAttributes_deserialize(
1100             message_handle,
1101             instance->anyAttributes);
1102 0         if(result != GLOBUS_SUCCESS)
1103         {
1104 0             result = GlobusSoapMessageErrorDeserializeFailed(
1105                 result, element_qname);
1106 0             goto xsd_anyAttributes_destroy;
1107         }
1108
1109 0     subelement.Namespace = "http://schemas.xmlsoap.org/ws/2002/07/utility";
1110 0     subelement.local = "Id";
1111
1112 0     result = xsd_ID_deserialize_attribute_pointer(
1113         &subelement,
1114         &instance->_Id,
1115         message_handle,
1116         0);
1117 0     if(result != GLOBUS_SUCCESS)
1118     {
1119 0         result = GlobusSoapMessageErrorDeserializeFailed(result, &subelement);
1120 0         goto _Id_destroy;
1121     }
1122
1123
1124
1125 0         result = globus_soap_message_deserialize_element_begin_close(
1126             message_handle);
1127 0         if(result != GLOBUS_SUCCESS)
1128         {
1129 0             result = GlobusSoapMessageErrorDeserializeFailed(
1130                 result, element_qname);
1131 0             goto fail_deserialize;
1132         }
1133     }
1134
1135 0     subelement.local = "Expires";
1136 0     subelement.Namespace = "http://schemas.xmlsoap.org/ws/2002/07/utility";
1137
1138 0     result = wsu_AttributedDateTime_deserialize_pointer(
1139         &subelement,
1140         &instance->Expires,
1141         message_handle,
1142         0);
1143 0     if(result != GLOBUS_SUCCESS)
1144     {
1145 0         result = GlobusSoapMessageErrorDeserializeFailed(
1146             result, 
1147             (&subelement));
1148 0         goto Expires_destroy_pointer;
1149     }
1150
1151 0     subelement.local = "Identifier";
1152 0     subelement.Namespace = "http://schemas.xmlsoap.org/ws/2002/07/utility";
1153
1154 0     result = wsu_AttributedURI_deserialize(
1155          &subelement,
1156          &instance->Identifier,
1157          message_handle,
1158          0);
1159 0     if(result != GLOBUS_SUCCESS)
1160     {
1161 0         result = GlobusSoapMessageErrorDeserializeFailed(
1162             result, 
1163             &wsu_AttributedURI_qname);
1164 0         goto Identifier_destroy;
1165     }
1166
1167 0     subelement.local = "any";
1168 0     subelement.Namespace = "http://www.w3.org/2001/XMLSchema";
1169     
1170 0     result = xsd_any_array_deserialize(
1171         &subelement,
1172         &instance->any,
1173         message_handle,
1174         0);
1175 0     if(result != GLOBUS_SUCCESS)
1176     {
1177 0         result = GlobusSoapMessageErrorDeserializeFailed(
1178             result, 
1179             (&subelement));
1180 0         goto any_destroy_array;
1181     }
1182
1183 0     if(!(options & GLOBUS_XSD_ELEMENT_CONTENTS_ONLY))
1184     {
1185 0         result = globus_soap_message_deserialize_element_end(
1186             message_handle,
1187             element_qname);
1188 0         if(result != GLOBUS_SUCCESS)
1189         {
1190 0             result = GlobusSoapMessageErrorDeserializeFailed(
1191                 result, element_qname);
1192             goto fail_deserialize;
1193         }
1194     }
1195
1196 0     goto exit;
1197
1198  fail_deserialize:
1199
1200  xsd_anyAttributes_destroy:
1201 0         xsd_anyAttributes_destroy(instance->anyAttributes);
1202 0         instance->anyAttributes = NULL;
1203  xsd_anyAttributes_after_destroy:
1204 0         wsu_AttributedDateTime_destroy(
1205             instance->Expires);
1206 0          instance->Expires = NULL;
1207
1208  Expires_destroy_pointer:
1209 0         wsu_AttributedURI_destroy_contents(
1210              &instance->Identifier);
1211
1212  Identifier_destroy:
1213
1214  _Id_destroy:
1215
1216 0     if(instance->_Id)
1217     {
1218 0         xsd_ID_destroy(
1219             instance->_Id);
1220 0         instance->_Id = NULL;
1221     }
1222 0         xsd_any_array_destroy_contents(
1223             &instance->any);
1224
1225  any_destroy_array:
1226
1227
1228  exit:
1229
1230 0     GlobusSoapMessageDebugExit();
1231 0     return result;
1232 }
1233
1234
1235
1236 globus_result_t
1237 wsu_ContextType_deserialize_pointer(
1238     xsd_QName *                         element_qname,
1239     wsu_ContextType ** ip,
1240     globus_soap_message_handle_t        message_handle,
1241     globus_xsd_element_options_t        options)
1242 0 {
1243 0     wsu_ContextType * instance = NULL;
1244 0     globus_result_t                     result = GLOBUS_SUCCESS;
1245 0     xsd_QName                           subelement;
1246 0     int                                 found_attrs = 0;
1247 0     int                                 empty_element = 0;
1248 0     GlobusFuncName(wsu_ContextType_deserialize_pointer);
1249 0     GlobusSoapMessageDebugEnter();
1250
1251 0     *ip = NULL;
1252
1253 0     result = globus_soap_message_deserialize_element(
1254         message_handle, element_qname);
1255 0     if(result != GLOBUS_SUCCESS &&
1256        (GlobusSoapMessageStatusElementNotFoundCheck(result) ||
1257         GlobusSoapMessageStatusFailedElementCheck(result) ||
1258         GlobusSoapMessageStatusFailedWithTextCheck(result)))
1259     {
1260 0         *ip = NULL;
1261 0         result = GLOBUS_SUCCESS;
1262 0         goto exit;
1263     }
1264
1265 0     if(result != GLOBUS_SUCCESS)
1266     {
1267 0         result = GlobusSoapMessageErrorDeserializeFailed(
1268             result, element_qname);
1269 0         goto exit;
1270     }
1271
1272 0     if(globus_soap_message_deserialize_element_is_empty(
1273            message_handle))
1274     {
1275 0         empty_element = 1;
1276     }
1277
1278
1279
1280 0     result = wsu_ContextType_init(&instance);
1281 0     if(result != GLOBUS_SUCCESS)
1282     {
1283 0         result = GlobusSoapMessageErrorDeserializeFailed(
1284             result, element_qname);
1285 0         goto exit;
1286     }
1287
1288
1289 0         result = xsd_anyAttributes_init(&instance->anyAttributes);
1290 0         if(result != GLOBUS_SUCCESS)
1291         {
1292 0             result = GlobusSoapMessageErrorDeserializeFailed(
1293                 result, element_qname);
1294 0             goto xsd_anyAttributes_after_destroy;
1295         }
1296
1297 0         result = xsd_anyAttributes_deserialize(
1298             message_handle,
1299             instance->anyAttributes);
1300 0         if(result != GLOBUS_SUCCESS)
1301         {
1302 0             result = GlobusSoapMessageErrorDeserializeFailed(
1303                 result, element_qname);
1304 0             goto xsd_anyAttributes_destroy;
1305         }
1306
1307 0         if(instance->anyAttributes &&
1308            xsd_anyAttributes_size(instance->anyAttributes) > 0)
1309         {
1310 0             found_attrs++;
1311         }
1312
1313 0     subelement.Namespace = "http://schemas.xmlsoap.org/ws/2002/07/utility";
1314 0     subelement.local = "Id";
1315
1316 0     result = xsd_ID_deserialize_attribute_pointer(
1317         &subelement,
1318         &instance->_Id,
1319         message_handle,
1320         0);
1321 0     if(result != GLOBUS_SUCCESS)
1322     {
1323 0         result = GlobusSoapMessageErrorDeserializeFailed(result, &subelement);
1324 0         goto _Id_destroy;
1325     }
1326
1327
1328 0     if(instance->_Id)
1329     {
1330 0         found_attrs++;
1331     }
1332
1333
1334 0     if(empty_element)
1335     {
1336 0         result = globus_soap_message_deserialize_element_end(
1337             message_handle,
1338             element_qname);
1339 0         if(result != GLOBUS_SUCCESS)
1340         {
1341 0             result = GlobusSoapMessageErrorDeserializeFailed(
1342                 result, element_qname);
1343 0             goto fail_deserialize;
1344         }
1345
1346 0         *ip = instance;
1347 0         goto exit;
1348     }
1349
1350 0     result = globus_soap_message_deserialize_element_begin_close(
1351         message_handle);
1352 0     if(result != GLOBUS_SUCCESS)
1353     {
1354 0         result = GlobusSoapMessageErrorDeserializeFailed(
1355             result, element_qname);
1356 0         goto exit;
1357     }
1358
1359
1360 0     subelement.local = "Expires";
1361 0     subelement.Namespace = "http://schemas.xmlsoap.org/ws/2002/07/utility";
1362
1363 0     result = wsu_AttributedDateTime_deserialize_pointer(
1364         &subelement,
1365         &instance->Expires,
1366         message_handle,
1367         0);
1368 0     if(result != GLOBUS_SUCCESS)
1369     {
1370 0         result = GlobusSoapMessageErrorDeserializeFailed(
1371             result, 
1372             (&subelement));
1373 0         goto Expires_destroy_pointer;
1374     }
1375
1376 0     subelement.local = "Identifier";
1377 0     subelement.Namespace = "http://schemas.xmlsoap.org/ws/2002/07/utility";
1378
1379 0     result = wsu_AttributedURI_deserialize(
1380          &subelement,
1381          &instance->Identifier,
1382          message_handle,
1383          0);
1384 0     if(result != GLOBUS_SUCCESS)
1385     {
1386 0         result = GlobusSoapMessageErrorDeserializeFailed(
1387             result, 
1388             &wsu_AttributedURI_qname);
1389 0         goto Identifier_destroy;
1390     }
1391
1392 0     subelement.local = "any";
1393 0     subelement.Namespace = "http://www.w3.org/2001/XMLSchema";
1394     
1395 0     result = xsd_any_array_deserialize(
1396         &subelement,
1397         &instance->any,
1398         message_handle,
1399         0);
1400 0     if(result != GLOBUS_SUCCESS)
1401     {
1402 0         result = GlobusSoapMessageErrorDeserializeFailed(
1403             result, 
1404             (&subelement));
1405 0         goto any_destroy_array;
1406     }
1407
1408
1409 0     result = globus_soap_message_deserialize_element_end(
1410         message_handle,
1411         element_qname);
1412 0     if(result != GLOBUS_SUCCESS)
1413     {
1414 0         result = GlobusSoapMessageErrorDeserializeFailed(
1415             result, element_qname);
1416 0         goto fail_deserialize;
1417     }
1418
1419 0     *ip = instance;
1420
1421 0     goto exit;
1422
1423  fail_deserialize:
1424
1425  xsd_anyAttributes_destroy:
1426 0         xsd_anyAttributes_destroy(instance->anyAttributes);
1427 0         instance->anyAttributes = NULL;
1428  xsd_anyAttributes_after_destroy:
1429 0         wsu_AttributedDateTime_destroy(
1430             instance->Expires);
1431 0          instance->Expires = NULL;
1432
1433  Expires_destroy_pointer:
1434 0         wsu_AttributedURI_destroy_contents(
1435              &instance->Identifier);
1436
1437  Identifier_destroy:
1438
1439  _Id_destroy:
1440
1441 0     if(instance->_Id)
1442     {
1443 0         xsd_ID_destroy(
1444             instance->_Id);
1445 0         instance->_Id = NULL;
1446     }
1447 0         xsd_any_array_destroy_contents(
1448             &instance->any);
1449
1450  any_destroy_array:
1451
1452  exit:
1453
1454 0     GlobusSoapMessageDebugExit();
1455 0     return result;
1456 }
1457
1458
1459 globus_result_t
1460 wsu_ContextType_array_init_contents(
1461     wsu_ContextType_array * array)
1462 0 {
1463 0     GlobusFuncName(wsu_ContextType_array_init_contents);
1464 0     GlobusSoapMessageDebugEnter();
1465
1466 0     memset(array, 0, sizeof(wsu_ContextType_array));
1467
1468 0     GlobusSoapMessageDebugExit();
1469 0     return GLOBUS_SUCCESS;
1470 }
1471
1472 globus_result_t
1473 wsu_ContextType_array_init(
1474     wsu_ContextType_array ** arr)
1475 0 {
1476 0     wsu_ContextType_array * array;
1477 0     globus_result_t                     result;
1478 0     GlobusFuncName(wsu_ContextType_array_init);
1479 0     GlobusSoapMessageDebugEnter();
1480
1481 0     array = (wsu_ContextType_array *)
1482         globus_malloc(sizeof(wsu_ContextType_array));
1483 0     if(!array)
1484     {
1485 0         result = GlobusSoapMessageErrorOutOfMemory;
1486 0         goto exit;
1487     }
1488
1489 0     result = wsu_ContextType_array_init_contents(array);
1490 0     if(result != GLOBUS_SUCCESS)
1491     {
1492 0         globus_free(array);
1493 0         array = NULL;
1494
1495     }
1496
1497 0     *arr = array;
1498
1499  exit:
1500 0     GlobusSoapMessageDebugExit();
1501 0     return result;
1502 }
1503
1504 void
1505 wsu_ContextType_array_destroy_contents(
1506     wsu_ContextType_array * array)
1507 0 {
1508 0     int                                 i = 0;
1509 0     GlobusFuncName(wsu_ContextType_array_destroy_contents);
1510 0     GlobusSoapMessageDebugEnter();
1511
1512 0     for(; i < array->length; ++i)
1513     {
1514 0         wsu_ContextType_destroy_contents(&array->elements[i]);
1515     }
1516
1517 0     if(array->elements)
1518     {
1519 0         globus_free(array->elements);
1520 0         array->elements = NULL;
1521     }
1522 0     array->length = 0;
1523
1524 0     GlobusSoapMessageDebugExit();
1525 }
1526
1527 void
1528 wsu_ContextType_array_destroy(
1529     wsu_ContextType_array * array)
1530 0 {
1531 0     GlobusFuncName(wsu_ContextType_array_destroy);
1532 0     GlobusSoapMessageDebugEnter();
1533
1534 0     wsu_ContextType_array_destroy_contents(array);
1535 0     globus_free(array);
1536
1537 0     GlobusSoapMessageDebugExit();
1538 }
1539
1540 globus_result_t
1541 wsu_ContextType_array_copy(
1542     wsu_ContextType_array ** dest_arr,
1543     const wsu_ContextType_array * src_arr)
1544 0 {
1545 0     wsu_ContextType_array * array;
1546 0     globus_result_t                     result;
1547 0     GlobusFuncName(wsu_ContextType_array_copy);
1548 0     GlobusSoapMessageDebugEnter();
1549
1550 0     array = (wsu_ContextType_array *) globus_malloc(
1551         sizeof(wsu_ContextType_array));
1552 0     if(!array)
1553     {
1554 0         result = GlobusSoapMessageErrorOutOfMemory;
1555 0         GlobusSoapMessageDebugExit();
1556 0         return result;
1557     }
1558
1559 0     result = wsu_ContextType_array_copy_contents(array, src_arr);
1560 0     if(result != GLOBUS_SUCCESS)
1561     {
1562 0         globus_free(array);
1563 0         GlobusSoapMessageDebugExit();
1564 0         return result;
1565     }
1566
1567 0     *dest_arr = array;
1568
1569 0     GlobusSoapMessageDebugExit();
1570 0     return GLOBUS_SUCCESS;
1571 }
1572
1573 globus_result_t
1574 wsu_ContextType_array_copy_contents(
1575     wsu_ContextType_array * dest_arr,
1576     const wsu_ContextType_array * src_arr)
1577 0 {
1578 0     int                                 i;
1579 0     globus_result_t                     result = GLOBUS_SUCCESS;
1580 0     GlobusFuncName(wsu_ContextType_array_copy_contents);
1581 0     GlobusSoapMessageDebugEnter();
1582
1583 0     dest_arr->length = src_arr->length;
1584 0     if(dest_arr->length > 0)
1585     {
1586 0         dest_arr->elements = (wsu_ContextType *) malloc(
1587             sizeof(wsu_ContextType) * dest_arr->length);
1588 0         if(!dest_arr->elements)
1589         {
1590 0             result = GlobusSoapMessageErrorOutOfMemory;
1591 0             GlobusSoapMessageDebugExit();
1592 0             return result;
1593         }
1594     }
1595     else
1596     {
1597 0         dest_arr->elements = NULL;
1598     }
1599     
1600 0     for(i = 0; i < dest_arr->length; i++)
1601     {
1602 0         result = wsu_ContextType_copy_contents(
1603             &dest_arr->elements[i], &src_arr->elements[i]);
1604 0         if(result != GLOBUS_SUCCESS)
1605         {
1606 0             while(i--)
1607             {
1608 0                 wsu_ContextType_destroy_contents(&dest_arr->elements[i]);
1609             }
1610
1611 0             globus_free(dest_arr->elements);
1612 0             dest_arr->elements = NULL;
1613 0             dest_arr->length = 0;
1614 0             break;
1615         }
1616     }
1617
1618 0     GlobusSoapMessageDebugExit();
1619 0     return result;
1620 }
1621
1622 wsu_ContextType *
1623 wsu_ContextType_array_push(
1624     wsu_ContextType_array * array)
1625 0 {
1626 0     GlobusFuncName(wsu_ContextType_array_push);
1627 0     GlobusSoapMessageDebugEnter();
1628
1629 0     array->elements = realloc(array->elements,
1630                               sizeof(wsu_ContextType) *
1631                               (array->length + 1));
1632 0     memset(&array->elements[array->length], 0, sizeof(wsu_ContextType));
1633 0     array->length++;
1634
1635 0     GlobusSoapMessageDebugExit();
1636 0     return (&array->elements[array->length - 1]);
1637 }
1638
1639 void *
1640 wsu_ContextType_array_push_wrapper(
1641     void * array)
1642 0 {
1643 0     return (void *) wsu_ContextType_array_push((wsu_ContextType_array *) array);
1644 }
1645
1646 globus_result_t
1647 wsu_ContextType_array_serialize(
1648     xsd_QName *                         element_qname,
1649     wsu_ContextType_array * array,
1650     globus_soap_message_handle_t        message,
1651     globus_xsd_element_options_t        options)
1652 0 {
1653 0     globus_result_t                     result = GLOBUS_SUCCESS;
1654 0     int                                 i = 0;
1655 0     GlobusFuncName(wsu_ContextType_array_serialize);
1656 0     GlobusSoapMessageDebugEnter();
1657
1658 0     for(; i < array->length; ++i)
1659     {
1660 0         result = wsu_ContextType_serialize(
1661             element_qname,
1662             &array->elements[i],
1663             message,
1664             options);
1665 0         if(result != GLOBUS_SUCCESS)
1666         {
1667 0             goto exit;
1668         }
1669     }
1670
1671 exit:
1672
1673 0     GlobusSoapMessageDebugExit();
1674 0     return result;
1675 }
1676
1677 globus_result_t
1678 wsu_ContextType_array_deserialize(
1679     xsd_QName *                         element_qname,
1680     wsu_ContextType_array * array,
1681     globus_soap_message_handle_t        message,
1682     globus_xsd_element_options_t        options)
1683 0 {
1684 0     globus_result_t                     result = GLOBUS_SUCCESS;
1685 0     int                                 i = 0;
1686 0     int                                 pre_length;
1687 0     GlobusFuncName(wsu_ContextType_array_deserialize);
1688 0     GlobusSoapMessageDebugEnter();
1689
1690 0     pre_length = array->length;
1691
1692 0     for(i = 0; i < pre_length; ++i)
1693     {
1694 0         result = wsu_ContextType_deserialize(
1695             element_qname,
1696             &array->elements[i],
1697             message,
1698             options);
1699 0         if(result != GLOBUS_SUCCESS)
1700         {
1701 0             if(GlobusSoapMessageStatusFailedElementCheck(result) ||
1702                GlobusSoapMessageStatusElementNotFoundCheck(result) ||
1703                GlobusSoapMessageStatusFailedWithTextCheck(result))
1704             {
1705 0                 result = GLOBUS_SUCCESS;
1706 0                 break;
1707             }
1708
1709 0             result = GlobusSoapMessageErrorDeserializeFailed(
1710                 result, element_qname);
1711 0             goto exit;
1712         }
1713     }
1714
1715 0     while(result == GLOBUS_SUCCESS)
1716     {
1717 0         wsu_ContextType                  next;
1718 0         memset(&next, 0, sizeof(wsu_ContextType));
1719
1720 0         result = wsu_ContextType_deserialize(
1721             element_qname,
1722             &next,
1723             message,
1724             options);
1725 0         if(result != GLOBUS_SUCCESS)
1726         {
1727 0             if(GlobusSoapMessageStatusFailedElementCheck(result) ||
1728                GlobusSoapMessageStatusElementNotFoundCheck(result) ||
1729                GlobusSoapMessageStatusFailedWithTextCheck(result))
1730             {
1731 0                 result = GLOBUS_SUCCESS;
1732 0                 break;
1733             }
1734
1735 0             result = GlobusSoapMessageErrorDeserializeFailed(
1736                 result, element_qname);
1737 0             goto exit;
1738         }
1739
1740 0         array->elements = realloc(
1741             array->elements,
1742             (array->length + 1) * sizeof(wsu_ContextType));
1743 0         if(!array->elements)
1744         {
1745 0             result = GlobusSoapMessageErrorOutOfMemory;
1746 0             goto exit;
1747         }
1748 0         array->elements[array->length] = next;
1749 0         array->length++;
1750 0         ++i;
1751     }
1752
1753   exit:
1754
1755 0     if(result != GLOBUS_SUCCESS)
1756     {
1757 0         int                             di = 0;
1758 0         for(; di < i; ++di)
1759         {
1760 0             wsu_ContextType_destroy_contents(
1761                 &array->elements[di]);
1762 0             memset(&array->elements[di], 0, sizeof(wsu_ContextType));
1763         }
1764     }
1765
1766 0     GlobusSoapMessageDebugExit();
1767 0     return result;