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 "globus_soap_message.h"
18 #include "globus_handler.h"
19 #include "globus_xio.h"
20 #include "ResourcePropertiesTestService_client.h"
21 #include "ResourcePropertiesTestService_client_internal.h"
22 #include "globus_xsd_type_registry.h"
23 #include "globus_soap_message_fault.h"
24 #include "globus_soap_message_attrs.h"
25 #include "globus_soap_message_markers.h"
26 #include "globus_soap_message_attrs.h"
27 #include "globus_ws_addressing.h"
28
29 static globus_list_t *                  ResourcePropertiesTestService_l_extensions = NULL;
30 static globus_mutex_t                   ResourcePropertiesTestService_l_extensions_mutex;
31
32 globus_xsd_type_registry_t              ResourcePropertiesTestService_l_registry = NULL;
33
34 static
35 int
36 ResourcePropertiesTestService_l_client_module_activate();
37
38 static
39 int
40 ResourcePropertiesTestService_l_client_module_deactivate();
41
42 globus_module_descriptor_t
43 ResourcePropertiesTestService_i_module = 
44 {
45     "ResourcePropertiesTestService",
46     ResourcePropertiesTestService_l_client_module_activate,
47     ResourcePropertiesTestService_l_client_module_deactivate
48 };
49
50 static
51 int
52 ResourcePropertiesTestService_l_client_module_activate()
53 22 {
54 22     int res = 0;        
55 22     globus_result_t result = GLOBUS_SUCCESS;
56 22     res = globus_module_activate(GLOBUS_SOAP_MESSAGE_MODULE);
57 22     if(res != GLOBUS_SUCCESS)
58     {
59 0         return res;
60     }
61
62 22     if(!ResourcePropertiesTestService_l_registry)
63     {
64 22         result = globus_xsd_type_registry_init(&ResourcePropertiesTestService_l_registry);
65 22         if(result != GLOBUS_SUCCESS)
66         {
67 0             return (int) result;
68         }
69
70 22         result = ResourcePropertiesTestService_registry_add_types(ResourcePropertiesTestService_l_registry);
71 22         if(result != GLOBUS_SUCCESS)
72         {
73 0             return (int) result;
74         }
75     }
76
77 22     if(GLOBUS_GLOBAL_TYPE_REGISTRY == NULL)
78     {
79 0         result = GLOBUS_FAILURE;
80 0         return GLOBUS_FAILURE;
81     }
82
83 22     result = ResourcePropertiesTestService_registry_add_types(GLOBUS_GLOBAL_TYPE_REGISTRY);
84 22     if(result != GLOBUS_SUCCESS)
85     {
86 0         result = GlobusSoapMessageErrorFailedClientInit(
87             result, "ResourcePropertiesTestService");
88     }
89
90 22     globus_mutex_init(&ResourcePropertiesTestService_l_extensions_mutex, NULL);
91
92 22     return res;
93 }
94
95 static
96 void
97 ResourcePropertiesTestService_l_extension_destroy(
98     void *                              sym)
99 22 {
100 22     char *                              symbol = (char *) sym;
101
102 22     globus_extension_deactivate(symbol);
103 22     globus_free(symbol);
104 }
105
106 static
107 int
108 ResourcePropertiesTestService_l_client_module_deactivate()
109 22 {
110 22     int res = 0;
111
112 22     globus_xsd_type_registry_destroy(ResourcePropertiesTestService_l_registry);
113 22     ResourcePropertiesTestService_l_registry = NULL;
114
115 22     globus_module_deactivate(GLOBUS_SOAP_MESSAGE_MODULE);
116
117 22     globus_mutex_lock(&ResourcePropertiesTestService_l_extensions_mutex);
118 22     globus_list_destroy_all(
119         ResourcePropertiesTestService_l_extensions,
120         ResourcePropertiesTestService_l_extension_destroy);
121 22     ResourcePropertiesTestService_l_extensions = NULL;
122 22     globus_mutex_unlock(&ResourcePropertiesTestService_l_extensions_mutex);
123 22     globus_mutex_destroy(&ResourcePropertiesTestService_l_extensions_mutex);
124
125 22     return res;
126 }
127
128 globus_result_t
129 ResourcePropertiesTestService_client_init(
130     ResourcePropertiesTestService_client_handle_t * handle,
131     globus_soap_message_attr_t attrs,
132     globus_handler_chain_t chain)
133 22 {
134 22     ResourcePropertiesTestService_client_handle_t client_handle;
135 22     globus_result_t                     result = GLOBUS_SUCCESS;
136 22     GlobusFuncName(ResourcePropertiesTestService_client_init);
137 22     GlobusSoapMessageDebugEnter();
138         
139 22     client_handle = malloc(sizeof(struct ResourcePropertiesTestService_client_handle_s));
140 22     globus_assert_string(client_handle, "Memory allocation failed");
141 22     memset(client_handle, 0, sizeof(struct ResourcePropertiesTestService_client_handle_s));
142     
143 22     if(chain)
144     {
145 0         result = globus_handler_chain_copy(
146             &client_handle->handler_chain, chain);
147 0         if(result != GLOBUS_SUCCESS)
148         {
149 0             goto error;
150         }
151     }
152     else
153     {
154 22         globus_handler_chain_init(&client_handle->handler_chain);
155
156 22 if(attrs &&
157    ((int)globus_soap_message_attr_get(
158        attrs,
159        GLOBUS_SOAP_MESSAGE_AUTHENTICATION_METHOD_KEY)) ==
160    GLOBUS_SOAP_MESSAGE_AUTH_SECURE_MESSAGE)
161 {
162 0     result = globus_extension_activate(
163 "globus_handler_ws_secure_message");
164 0     if(result != GLOBUS_SUCCESS)
165     {
166 0 result = GlobusSoapMessageErrorFailedClientInit(
167     result, "ResourcePropertiesTestPortType_CreateResourcePropertiesTest");
168 0 goto error;
169     }
170
171 0     globus_mutex_lock(&ResourcePropertiesTestService_l_extensions_mutex);
172 0     globus_list_insert(
173 &ResourcePropertiesTestService_l_extensions,
174 strdup("globus_handler_ws_secure_message"));
175 0     globus_mutex_unlock(&ResourcePropertiesTestService_l_extensions_mutex);
176
177 0     result = globus_handler_chain_push(
178                 client_handle->handler_chain, 
179         GLOBUS_HANDLER_TYPE_ALL,
180                 "globus_handler_ws_secure_message_client");
181 0             if(result != GLOBUS_SUCCESS)
182             {
183 0                 result = GlobusSoapMessageErrorFailedClientInit(
184                     result, "ResourcePropertiesTestPortType_CreateResourcePropertiesTest");
185 0                 goto error;
186             }
187
188     
189 22 result = globus_extension_activate(GLOBUS_HANDLER_WS_ADDRESSING_LIB);
190 22         if(result != GLOBUS_SUCCESS)
191         {
192 0             result = GlobusSoapMessageErrorFailedClientInit(
193                 result, "ResourcePropertiesTestPortType_CreateResourcePropertiesTest");
194 0             goto error;
195         }
196
197 22         globus_mutex_lock(&ResourcePropertiesTestService_l_extensions_mutex);
198 22         globus_list_insert(
199             &ResourcePropertiesTestService_l_extensions, 
200             strdup(GLOBUS_HANDLER_WS_ADDRESSING_LIB));
201 22         globus_mutex_unlock(&ResourcePropertiesTestService_l_extensions_mutex);
202
203 22         result = globus_handler_chain_push(
204             client_handle->handler_chain, 
205     GLOBUS_HANDLER_TYPE_REQUEST_ALL,
206             GLOBUS_HANDLER_WS_ADDRESSING_CLIENT);
207 22         if(result != GLOBUS_SUCCESS)
208         {
209 0             result = GlobusSoapMessageErrorFailedClientInit(
210                 result, "ResourcePropertiesTestPortType_CreateResourcePropertiesTest");
211 0             goto error;
212         }
213
214 22         result = globus_handler_chain_push(
215             client_handle->handler_chain, 
216     GLOBUS_HANDLER_TYPE_RESPONSE_ALL,
217             GLOBUS_HANDLER_WS_ADDRESSING_CLIENT);
218 22         if(result != GLOBUS_SUCCESS)
219         {
220 0             result = GlobusSoapMessageErrorFailedClientInit(
221                 result, "ResourcePropertiesTestPortType_CreateResourcePropertiesTest");
222 0             goto error;
223         }
224     }
225
226 22     if(attrs)
227     {
228 22         globus_soap_message_attr_copy(
229             &client_handle->attrs, attrs);
230     }
231     else
232     {
233 0         globus_soap_message_attr_init(&client_handle->attrs);
234     }
235
236 22     *handle = client_handle;
237
238 22     GlobusSoapMessageDebugExit();
239 22     return result;
240     
241 error:
242 0     globus_free(client_handle);
243 0     GlobusSoapMessageDebugExit();
244 0     return result;
245 }
246
247 void
248 ResourcePropertiesTestService_client_destroy(
249     ResourcePropertiesTestService_client_handle_t             handle)
250 22 {
251 22     if(handle)
252     {
253 22         if(handle->handler_chain)
254         {
255 22             globus_handler_chain_destroy(handle->handler_chain);
256         }
257
258 22         if(handle->attrs)
259         {
260 22             globus_soap_message_attr_destroy(handle->attrs);
261         }
262
263 22         if(handle->message)
264         {
265 0             globus_soap_message_handle_destroy(handle->message);
266         }
267
268 22         free(handle);
269     }
270 }
271
272 globus_result_t
273 ResourcePropertiesTestService_client_operation_cancel(
274     ResourcePropertiesTestService_client_handle_t handle)
275 0 {
276 0     globus_result_t result = GLOBUS_SUCCESS;
277 0     GlobusFuncName(ResourcePropertiesTestService_client_message_cancel);
278 0     GlobusSoapMessageDebugEnter();
279
280 0     if(handle->message)
281     {
282 0         result = globus_soap_message_cancel_message(handle->message);
283     }
284
285 0     return result;
286 }
287     
288 globus_result_t
289 ResourcePropertiesTestService_client_get_registry(
290     ResourcePropertiesTestService_client_handle_t handle,
291     globus_xsd_type_registry_t * registry)
292 0 {
293 0     globus_result_t                     result = GLOBUS_SUCCESS;
294 0     GlobusFuncName(ResourcePropertiesTestService_client_get_registry);
295 0     GlobusSoapMessageDebugEnter();
296
297 0     *registry = ResourcePropertiesTestService_l_registry;
298
299 0     GlobusSoapMessageDebugExit();
300 0     return result;
301 }
302
303 globus_result_t
304 ResourcePropertiesTestService_client_get_handler_chain(
305     ResourcePropertiesTestService_client_handle_t handle,
306     globus_handler_chain_t * handlers)
307 0 {
308 0     globus_result_t                     result = GLOBUS_SUCCESS;
309 0     GlobusFuncName(ResourcePropertiesTestService_client_get_handle_chain);
310 0     GlobusSoapMessageDebugEnter();
311
312 0     *handlers = handle->handler_chain;
313     
314 0     GlobusSoapMessageDebugExit();
315 0     return result;
316 }
317
318 globus_result_t
319 ResourcePropertiesTestService_client_attr_set(
320     ResourcePropertiesTestService_client_handle_t handle,
321     const char * prop_name,
322     globus_soap_message_attr_copy_func_t copy,
323     globus_soap_message_attr_destroy_func_t destroy,
324     void * value)
325 0 {
326 0     return globus_soap_message_attr_set(
327         handle->attrs,
328         prop_name,
329         copy,
330         destroy,
331         value);
332 }
333
334 void *
335 ResourcePropertiesTestService_client_attr_remove(
336     ResourcePropertiesTestService_client_handle_t handle,
337     const char * prop_name)
338 0 {
339 0     return globus_soap_message_attr_remove(
340         handle->attrs,
341         prop_name);
342 }
343
344 void *
345 ResourcePropertiesTestService_client_attr_get(
346     ResourcePropertiesTestService_client_handle_t handle,
347     const char * prop_name)
348 0 {
349 0     return globus_soap_message_attr_get(
350         handle->attrs,
351         prop_name);
352 }
353
354 typedef enum
355 {
356     RESOURCEPROPERTIESTESTSERVICE_REQUEST_INIT,
357     RESOURCEPROPERTIESTESTSERVICE_REQUEST_INIT_HANDLERS,
358     RESOURCEPROPERTIESTESTSERVICE_REQUEST_OPENING,
359     RESOURCEPROPERTIESTESTSERVICE_REQUEST_INVOKING_HANDLERS,
360     RESOURCEPROPERTIESTESTSERVICE_REQUEST_SENDING,
361     RESOURCEPROPERTIESTESTSERVICE_REQUEST_DESTROY_HANDLERS,
362     RESOURCEPROPERTIESTESTSERVICE_REQUEST_DONE
363 } ResourcePropertiesTestService_request_state_t;
364
365 typedef enum
366 {
367     RESOURCEPROPERTIESTESTSERVICE_RESPONSE_INIT,
368     RESOURCEPROPERTIESTESTSERVICE_RESPONSE_INIT_HANDLERS,
369     RESOURCEPROPERTIESTESTSERVICE_RESPONSE_READING,
370     RESOURCEPROPERTIESTESTSERVICE_RESPONSE_TRIGGER_HANDLERS,
371     RESOURCEPROPERTIESTESTSERVICE_RESPONSE_HANDLER_DESERIALIZE,
372     RESOURCEPROPERTIESTESTSERVICE_RESPONSE_INVOKING_HANDLERS,
373     RESOURCEPROPERTIESTESTSERVICE_RESPONSE_HEADER_FAILED,
374     RESOURCEPROPERTIESTESTSERVICE_RESPONSE_DESTROY_HANDLERS,
375     RESOURCEPROPERTIESTESTSERVICE_RESPONSE_CLOSE,
376     RESOURCEPROPERTIESTESTSERVICE_RESPONSE_DONE
377 } ResourcePropertiesTestService_response_state_t;
378
379
380
381 typedef struct SetTerminationTime_i_request_handle_s
382 {
383     char * endpoint;
384     int done;
385     globus_mutex_t mutex;
386     ResourcePropertiesTestService_request_state_t state;
387     ResourcePropertiesTestPortType_SetTerminationTime_request_callback_func_t callback;
388     void * args;
389     ResourcePropertiesTestService_client_handle_t client_handle;
390     wsrl_SetTerminationTimeType * SetTerminationTime;
391     globus_callback_handle_t            callback_handle;
392     globus_result_t result;
393 } SetTerminationTime_i_request_handle_t;
394
395 static void
396 SetTerminationTime_i_request_callback(
397     void *                              args);
398
399 static void
400 SetTerminationTime_i_request_done_callback(
401     globus_result_t                     result,
402     void *                              args)
403 0 {
404 0     SetTerminationTime_i_request_handle_t * request;
405
406 0     request = (SetTerminationTime_i_request_handle_t *) args;
407 0     globus_assert_string(request, "request handle in callback is NULL");
408
409 0     globus_mutex_lock(&request->mutex);
410 0     request->result = result;
411 0     request->done = 1;
412 0     globus_mutex_unlock(&request->mutex);
413
414 0     SetTerminationTime_i_request_callback(request);
415 }
416
417 static void
418 SetTerminationTime_i_request_handle_destroy(
419     void *                              args)
420 0 {
421 0     SetTerminationTime_i_request_handle_t * request;
422
423 0     request = (SetTerminationTime_i_request_handle_t *) args;
424 0     globus_assert_string(request, "request handle in callback is NULL");
425
426 0     globus_mutex_destroy(&request->mutex);
427     
428 0     if(request->SetTerminationTime)
429     {
430 0         wsrl_SetTerminationTimeType_destroy(request->SetTerminationTime);
431     }
432 0     if(request->endpoint)
433     {
434 0         globus_free(request->endpoint);
435     }
436
437 0     globus_free(request);
438 }
439
440 static void
441 SetTerminationTime_i_request_callback(
442     void *                              args)
443 0 {
444 0     globus_soap_message_handle_t        message_handle = NULL;
445 0     globus_result_t                     result = GLOBUS_SUCCESS;
446 0     globus_handler_chain_t              chain = NULL;
447 0     SetTerminationTime_i_request_handle_t * request;
448 0     xsd_QName                           subelement;
449
450 0     request = (SetTerminationTime_i_request_handle_t *) args;
451 0     globus_assert_string(request, "request handle is NULL");
452
453 0     switch(request->state)
454     {
455
456     case RESOURCEPROPERTIESTESTSERVICE_REQUEST_INIT:
457
458 0         globus_mutex_lock(&request->mutex);
459 0         request->done = 0;
460 0         request->state = RESOURCEPROPERTIESTESTSERVICE_REQUEST_INIT_HANDLERS;
461 0         globus_mutex_unlock(&request->mutex);
462
463 0         result = globus_soap_message_get_handler_chain(
464             request->client_handle->message, &chain);
465 0         if(result != GLOBUS_SUCCESS)
466         {
467 0             goto error_exit;
468         }
469
470 0         if(chain)
471         {
472 0             globus_handler_chain_register_invoke(
473                 chain, 
474                 GLOBUS_HANDLER_TYPE_REQUEST_INIT,
475                 request->client_handle->message,
476                 SetTerminationTime_i_request_done_callback,
477                 request);
478         }
479
480 0         break;
481
482     case RESOURCEPROPERTIESTESTSERVICE_REQUEST_INIT_HANDLERS:
483
484 0         globus_mutex_lock(&request->mutex);
485 0         request->done = 0;
486 0         request->state = RESOURCEPROPERTIESTESTSERVICE_REQUEST_OPENING;
487 0         globus_mutex_unlock(&request->mutex);
488
489 0         result = globus_soap_message_register_open(
490             request->client_handle->message, 
491             request->endpoint,
492             SetTerminationTime_i_request_done_callback,
493             request);
494 0         if(result != GLOBUS_SUCCESS)
495         {
496 0             goto error_exit;
497         }
498
499 0         break;
500
501     case RESOURCEPROPERTIESTESTSERVICE_REQUEST_OPENING:
502
503 0         if(request->done)
504         {
505 0             if(request->result != GLOBUS_SUCCESS)
506             {
507 0                 result = request->result;
508 0                 goto error_exit;
509             }
510
511 0             globus_mutex_lock(&request->mutex);
512 0             request->done = 0;
513 0             request->state = RESOURCEPROPERTIESTESTSERVICE_REQUEST_INVOKING_HANDLERS;
514 0             globus_mutex_unlock(&request->mutex);
515             
516 0             result = globus_soap_message_serialize_envelope(
517                 request->client_handle->message);
518 0             if(result != GLOBUS_SUCCESS)
519             {
520 0                 goto error_exit;
521             }
522
523 0             result = globus_soap_message_serialize_header(
524                 request->client_handle->message);
525 0             if(result != GLOBUS_SUCCESS)
526             {
527 0                 goto error_exit;
528             }
529
530 0             result = globus_soap_message_serialize_header_begin_close(
531                 request->client_handle->message);
532 0             if(result != GLOBUS_SUCCESS)
533             {
534 0                 goto error_exit;
535             }
536            
537 0     result = globus_soap_message_set_marker(
538 request->client_handle->message, 
539 GLOBUS_SOAP_MESSAGE_MARKER_HEADER_CONTENT);
540 0     if(result != GLOBUS_SUCCESS)
541     {   
542 0 goto error_exit;
543     }
544     
545 0             result = globus_soap_message_serialize_header_end(
546                 request->client_handle->message);
547 0             if(result != GLOBUS_SUCCESS)
548             {
549 0                 goto error_exit;
550             }
551
552 0             result = globus_soap_message_serialize_body(
553                 request->client_handle->message);
554 0             if(result != GLOBUS_SUCCESS)
555             {
556 0                 goto error_exit;
557             }
558
559 0             result = globus_soap_message_serialize_body_begin_close(
560                 request->client_handle->message);
561 0             if(result != GLOBUS_SUCCESS)
562             {
563 0                 goto error_exit;
564             }
565
566 0             subelement.Namespace = "http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd";
567 0             subelement.local = "SetTerminationTime";
568
569 0             result = wsrl_SetTerminationTimeType_serialize(
570                 &subelement,
571                 request->SetTerminationTime,
572                 request->client_handle->message,
573                 0);
574 0             if(result != GLOBUS_SUCCESS)
575             {
576 0                 goto error_exit;
577             }
578
579 0             result = globus_soap_message_serialize_body_end(
580                 request->client_handle->message);
581 0             if(result != GLOBUS_SUCCESS)
582             {
583 0                 goto error_exit;
584             }
585
586 0             result = globus_soap_message_serialize_envelope_end(
587                 request->client_handle->message);
588 0             if(result != GLOBUS_SUCCESS)
589             {
590 0                 goto error_exit;
591             }
592
593 0             result = globus_soap_message_set_write_position_to_marker(
594                 request->client_handle->message, 
595                 GLOBUS_SOAP_MESSAGE_MARKER_HEADER_CONTENT);
596 0             if(result != GLOBUS_SUCCESS)
597             {
598 0                 goto error_exit;
599             }
600
601 0             result = globus_soap_message_get_handler_chain(
602                 request->client_handle->message, &chain);
603 0             if(result != GLOBUS_SUCCESS)
604             {
605 0                 goto error_exit;
606             }
607
608 0             if(chain)
609             {
610 0                 globus_handler_chain_register_invoke(
611                     chain, 
612                     GLOBUS_HANDLER_TYPE_REQUEST,
613                     request->client_handle->message,
614                     SetTerminationTime_i_request_done_callback,
615                     request);
616             }
617         }
618
619 0         break;
620
621     case RESOURCEPROPERTIESTESTSERVICE_REQUEST_INVOKING_HANDLERS:
622
623 0         if(request->done)
624         {
625 0             if(request->result != GLOBUS_SUCCESS)
626             {
627 0                 result = request->result;
628 0                 goto error_exit;
629             }
630
631 0             globus_mutex_lock(&request->mutex);
632 0             request->done = 0;
633 0             request->state = RESOURCEPROPERTIESTESTSERVICE_REQUEST_SENDING;
634 0             globus_mutex_unlock(&request->mutex);
635
636 0             result = globus_soap_message_register_write_request(
637                 request->client_handle->message,
638                 SetTerminationTime_i_request_done_callback,
639                 request,
640
641                GLOBUS_TRUE);
642
643 0             if(result != GLOBUS_SUCCESS)
644             {
645 0                 goto error_exit;
646             }
647         }
648
649 0         break;
650
651     case RESOURCEPROPERTIESTESTSERVICE_REQUEST_SENDING:
652
653 0         if(request->done)
654         {
655 0             if(request->result != GLOBUS_SUCCESS)
656             {
657 0                 result = request->result;
658 0                 goto error_exit;
659             }
660
661 0             globus_mutex_lock(&request->mutex);
662 0             request->done = 0;
663 0             request->state = RESOURCEPROPERTIESTESTSERVICE_REQUEST_DESTROY_HANDLERS;
664 0             globus_mutex_unlock(&request->mutex);
665
666 0             result = globus_soap_message_get_handler_chain(
667                 request->client_handle->message, &chain);
668 0             if(result != GLOBUS_SUCCESS)
669             {
670 0                 goto error_exit;
671             }
672
673 0             if(chain)
674             {
675 0                 globus_handler_chain_register_invoke(
676                     chain, 
677                     GLOBUS_HANDLER_TYPE_REQUEST_DESTROY,
678                     request->client_handle->message,
679                     SetTerminationTime_i_request_done_callback,
680                     request);
681             }
682         }
683
684 0         break;
685
686     case RESOURCEPROPERTIESTESTSERVICE_REQUEST_DESTROY_HANDLERS:
687
688 0         if(request->done)
689         {
690 0             if(request->result != GLOBUS_SUCCESS)
691             {
692 0                 result = request->result;
693 0                 goto error_exit;
694             }
695
696 0             globus_mutex_lock(&request->mutex);
697 0             request->done = 0;
698 0             globus_mutex_unlock(&request->mutex);
699
700 0             request->callback(
701                 request->client_handle, 
702                 request->args, GLOBUS_SUCCESS);
703
704 0             SetTerminationTime_i_request_handle_destroy(request);
705         }
706
707 0         break;
708
709     default:
710
711 0         globus_assert_string(NULL, "Unkown request state");
712 0         break;
713     }
714
715 0     return;
716
717  error_exit:
718
719 0     result = GlobusSoapMessageErrorClientRequestFailed(
720         result, "ResourcePropertiesTestPortType_SetTerminationTime");
721     
722 0     globus_mutex_lock(&request->mutex);
723 0     message_handle = request->client_handle->message;
724 0     request->client_handle->message = NULL;
725 0     globus_mutex_unlock(&request->mutex);
726
727 0     request->callback(request->client_handle, request->args, result);
728
729 0     globus_soap_message_handle_destroy(message_handle);
730 0     SetTerminationTime_i_request_handle_destroy(request);
731 }
732     
733 globus_result_t
734 ResourcePropertiesTestPortType_SetTerminationTime_epr_register_request(
735     ResourcePropertiesTestService_client_handle_t client_handle,
736     const wsa_EndpointReferenceType * epr,
737     const wsrl_SetTerminationTimeType * SetTerminationTime,
738     ResourcePropertiesTestPortType_SetTerminationTime_request_callback_func_t callback,
739     void * user_args)
740 0 {
741 0     globus_result_t                     result = GLOBUS_SUCCESS;
742
743 0     globus_assert_string(epr, "NULL EndpointReference");
744 0     globus_assert_string(epr->Address.base_value, "NULL EndpointReference Address");
745
746 0     globus_soap_message_attr_set(
747         client_handle->attrs,
748         WSADDR_EPR_KEY,
749         wsa_EndpointReferenceType_copy_wrapper,
750         wsa_EndpointReferenceType_destroy_wrapper,
751         (void *)epr);
752
753 0     result = ResourcePropertiesTestPortType_SetTerminationTime_register_request(
754         client_handle, 
755         epr->Address.base_value,
756         SetTerminationTime,
757         callback,
758         user_args);
759     
760 0     return result;
761 }
762
763 globus_result_t
764 ResourcePropertiesTestPortType_SetTerminationTime_register_request(
765     ResourcePropertiesTestService_client_handle_t client_handle,
766     const char * endpoint,
767     const wsrl_SetTerminationTimeType * SetTerminationTime,
768     ResourcePropertiesTestPortType_SetTerminationTime_request_callback_func_t callback,
769     void * user_args)
770 0 {
771 0     globus_handler_chain_t              chain = NULL;
772 0     globus_result_t                     result = GLOBUS_SUCCESS;
773 0     SetTerminationTime_i_request_handle_t * request = NULL;
774
775 0     if(client_handle->message != NULL)
776     {
777 0         result = GlobusSoapMessageErrorClientAlreadyInvoked();
778 0         goto exit;
779     }
780
781 0     result = globus_soap_message_handle_init(&client_handle->message, NULL);
782 0     if(result != GLOBUS_SUCCESS)
783     {
784 0         result = GlobusSoapMessageErrorFailedClientInit(
785             result, "ResourcePropertiesTestPortType_SetTerminationTime");
786 0         goto error_exit;
787     }
788
789 0     globus_soap_message_handle_set_registry(
790         client_handle->message, ResourcePropertiesTestService_l_registry);
791
792 0     chain = client_handle->handler_chain;
793 0     if(!chain)
794     {
795 0         result = globus_extension_activate(GLOBUS_HANDLER_WS_ADDRESSING_LIB);
796 0         if(result != GLOBUS_SUCCESS)
797         {
798 0             result = GlobusSoapMessageErrorFailedClientInit(
799                 result, "ResourcePropertiesTestPortType_SetTerminationTime");
800 0             goto exit;
801         }
802
803 0         globus_mutex_lock(&ResourcePropertiesTestService_l_extensions_mutex);
804 0         globus_list_insert(
805             &ResourcePropertiesTestService_l_extensions, 
806             strdup(GLOBUS_HANDLER_WS_ADDRESSING_LIB));
807 0         globus_mutex_unlock(&ResourcePropertiesTestService_l_extensions_mutex);
808
809 0         globus_handler_chain_init(&chain);
810 0         result = globus_handler_chain_push(
811             chain, 
812     GLOBUS_HANDLER_TYPE_REQUEST_ALL,
813             GLOBUS_HANDLER_WS_ADDRESSING_CLIENT);
814 0         if(result != GLOBUS_SUCCESS)
815         {
816 0             result = GlobusSoapMessageErrorFailedClientInit(
817                 result, "ResourcePropertiesTestPortType_SetTerminationTime");
818 0             goto error_exit;
819         }
820
821 0         result = globus_handler_chain_push(
822             chain, 
823     GLOBUS_HANDLER_TYPE_RESPONSE_ALL,
824             GLOBUS_HANDLER_WS_ADDRESSING_CLIENT);
825 0         if(result != GLOBUS_SUCCESS)
826         {
827 0             result = GlobusSoapMessageErrorFailedClientInit(
828                 result, "ResourcePropertiesTestPortType_SetTerminationTime");
829 0             goto error_exit;
830         }
831     }
832
833 0     globus_soap_message_set_handler_chain(
834         client_handle->message, chain);
835
836 0     request = globus_malloc(sizeof(SetTerminationTime_i_request_handle_t));
837 0     globus_assert_string(request, "Memory allocation failed.");
838 0     memset(request, 0, sizeof(SetTerminationTime_i_request_handle_t));
839     
840 0     if(!endpoint)
841     {
842 0         endpoint = (char *)globus_soap_message_attr_get(
843             client_handle->attrs, GLOBUS_SOAP_MESSAGE_SERVICE_ENDPOINT_KEY);
844 0         if(!endpoint)
845         {
846 0             wsa_EndpointReferenceType * epr;
847 0             epr = (wsa_EndpointReferenceType *)
848             globus_soap_message_attr_get(
849                 client_handle->attrs, WSADDR_EPR_KEY);
850 0             if(epr && epr->Address.base_value)
851             {
852 0                 endpoint = epr->Address.base_value;
853             }
854         }
855     }
856
857 0     globus_assert_string(endpoint, "NULL endpoint");
858
859 0     request->endpoint = globus_libc_strdup(endpoint);
860 0     request->callback = callback;
861 0     request->args = user_args;
862 0     request->client_handle = client_handle;
863 0     wsrl_SetTerminationTimeType_copy(&request->SetTerminationTime, SetTerminationTime);
864 0     request->state = RESOURCEPROPERTIESTESTSERVICE_REQUEST_INIT;
865 0     globus_mutex_init(&request->mutex, NULL);
866
867 0     result = globus_soap_message_attr_set(
868         client_handle->attrs, 
869         WSADDR_DESTINATION_KEY, 
870         globus_soap_message_attr_copy_string,
871         globus_libc_free,
872         (void *)endpoint);
873 0     if(result != GLOBUS_SUCCESS)
874     {
875 0         result = GlobusSoapMessageErrorClientRequestFailed(
876             result, "ResourcePropertiesTestPortType_SetTerminationTime");
877 0         goto error_exit;
878     }
879
880 0     result = globus_soap_message_attr_set(
881         client_handle->attrs, 
882         WSADDR_ACTION_REQUEST_KEY, 
883         NULL,
884         NULL, 
885         "http://www.globus.org/namespaces/2004/10/ResourcePropertiesTest/ResourcePropertiesTestPortType/SetTerminationTimeResponse");
886 0     if(result != GLOBUS_SUCCESS)
887     {
888 0         result = GlobusSoapMessageErrorClientRequestFailed(
889             result, "ResourcePropertiesTestPortType_SetTerminationTime");
890 0         goto error_exit;
891     }
892
893 0     result = globus_soap_message_attr_set(
894         client_handle->attrs, 
895         GLOBUS_SOAP_MESSAGE_SOAP_ACTION_KEY, 
896         NULL,
897         NULL, 
898         "http://www.globus.org/namespaces/2004/10/ResourcePropertiesTest/ResourcePropertiesTestPortType/SetTerminationTimeResponse");
899 0     if(result != GLOBUS_SUCCESS)
900     {
901 0         result = GlobusSoapMessageErrorClientRequestFailed(
902             result, "ResourcePropertiesTestPortType_SetTerminationTime");
903 0         goto error_exit;
904     }
905     
906 0     result = globus_soap_message_handle_set_attrs(
907         client_handle->message, client_handle->attrs);
908 0     if(result != GLOBUS_SUCCESS)
909     {
910 0         result = GlobusSoapMessageErrorClientRequestFailed(
911             result, "ResourcePropertiesTestPortType_SetTerminationTime");
912     }
913
914 0     result = globus_callback_register_oneshot(
915         &request->callback_handle,
916         NULL,
917         SetTerminationTime_i_request_callback,
918         request);
919 0     if(result != GLOBUS_SUCCESS)
920     {
921 0         result = GlobusSoapMessageErrorClientRequestFailed(
922             result, "ResourcePropertiesTestPortType_SetTerminationTime");
923         goto error_exit;
924     }
925
926 0     goto exit;
927
928  error_exit:
929
930 0     if(request)
931     {
932 0         globus_mutex_destroy(&request->mutex);
933         
934 0         if(request->SetTerminationTime)
935         {
936 0             wsrl_SetTerminationTimeType_destroy(request->SetTerminationTime);
937         }
938 0         if(request->endpoint)
939         {
940 0             globus_free(request->endpoint);
941         }
942         
943 0         globus_free(request);
944     }
945
946 0     if(client_handle->message)
947     {
948 0         globus_soap_message_handle_destroy(client_handle->message);
949 0         client_handle->message = NULL;
950     }
951
952  exit:
953
954 0     return result;
955 }
956
957 typedef struct SetTerminationTime_i_blocking_request_callback_s
958 {
959
960     ResourcePropertiesTestPortType_SetTerminationTime_response_callback_func_t callback;
961     void * args;
962
963 } SetTerminationTime_i_blocking_request_callback_t;
964
965 static
966 void
967 SetTerminationTime_i_blocking_request_callback(
968     ResourcePropertiesTestService_client_handle_t handle,
969     void * user_args,
970     globus_result_t error)
971 0 {
972 0     globus_soap_message_handle_t        message_handle = NULL;
973 0     globus_result_t result = GLOBUS_SUCCESS;
974 0     SetTerminationTime_i_blocking_request_callback_t * callback_handle;
975
976 0     callback_handle = (SetTerminationTime_i_blocking_request_callback_t *) user_args;
977 0     globus_assert_string(callback_handle, "callback_handle is NULL");
978
979
980 0     if(error != GLOBUS_SUCCESS ||
981        globus_soap_message_is_cancelled(handle->message))
982     {
983 0         message_handle = handle->message;
984 0         handle->message = NULL;
985         
986 0         callback_handle->callback(
987             handle,
988             callback_handle->args,
989             error,
990             NULL,
991             RESOURCEPROPERTIESTESTPORTTYPE_SETTERMINATIONTIME_NOFAULT,
992             NULL);
993
994 0         globus_soap_message_handle_destroy(message_handle);
995     }
996     else
997     {
998 0         result = ResourcePropertiesTestPortType_SetTerminationTime_register_response(
999             handle,
1000             callback_handle->callback,
1001             callback_handle->args);
1002 0         if(result != GLOBUS_SUCCESS)
1003         {
1004 0             callback_handle->callback(
1005                 handle,
1006                 callback_handle->args,
1007                 result,
1008                 NULL,
1009                 RESOURCEPROPERTIESTESTPORTTYPE_SETTERMINATIONTIME_NOFAULT,
1010                 NULL);
1011         }
1012     }
1013
1014 0     free(callback_handle);
1015 }    
1016
1017
1018
1019 typedef struct SetTerminationTime_i_response_handle_s
1020 {
1021     int                                 done;
1022     globus_mutex_t                      mutex;
1023     ResourcePropertiesTestService_response_state_t state;
1024     ResourcePropertiesTestPortType_SetTerminationTime_response_callback_func_t callback;
1025     void *                              args;
1026     ResourcePropertiesTestService_client_handle_t client_handle;
1027     wsrl_SetTerminationTimeResponseType * SetTerminationTimeResponse;
1028     globus_callback_handle_t            callback_handle;
1029     globus_result_t                     result;
1030     globus_result_t                     fault_result;
1031     int                                 fault_type;
1032     xsd_any *                           fault;
1033 } SetTerminationTime_i_response_handle_t;
1034
1035 static void
1036 SetTerminationTime_i_response_callback(
1037     void *                              args);
1038
1039 static void
1040 SetTerminationTime_i_response_done_callback(
1041     globus_result_t                     result,
1042     void *                              args)
1043 0 {
1044 0     SetTerminationTime_i_response_handle_t * response;
1045
1046 0     response = (SetTerminationTime_i_response_handle_t *) args;
1047 0     globus_assert_string(response, "response handle in callback is NULL");
1048
1049 0     globus_mutex_lock(&response->mutex);
1050 0     response->result = result;
1051 0     response->done = 1;
1052 0     globus_mutex_unlock(&response->mutex);
1053
1054 0     SetTerminationTime_i_response_callback(response);
1055 }
1056
1057 static void
1058 SetTerminationTime_i_response_handle_destroy(
1059     void *                              args)
1060 0 {
1061 0     SetTerminationTime_i_response_handle_t * response;
1062
1063 0     response = (SetTerminationTime_i_response_handle_t *) args;
1064 0     globus_assert_string(response, "response handle in callback is NULL");
1065
1066 0     globus_mutex_destroy(&response->mutex);
1067     
1068 0     free(response);
1069 }
1070
1071 static void
1072 SetTerminationTime_i_deserialize_fault(
1073     globus_soap_message_handle_t        handle,
1074     const xsd_QName *                   fault_qname,
1075     int *                               fault_type,
1076     void *                              args)
1077 0 {
1078 0     *fault_type = RESOURCEPROPERTIESTESTPORTTYPE_SETTERMINATIONTIME_NOFAULT;
1079
1080 0     if(fault_qname)
1081     {
1082 0        if(fault_qname == (&wsrl_TerminationTimeChangeRejectedFaultType_qname) ||
1083            fault_qname == (&wsrl_TerminationTimeChangeRejectedFault_qname))
1084          {
1085 0              *fault_type = RESOURCEPROPERTIESTESTPORTTYPE_SETTERMINATIONTIME_TERMINATIONTIMECHANGEREJECTEDFAULT;
1086          }
1087 0         else if(fault_qname == (&wsrl_UnableToSetTerminationTimeFaultType_qname) ||
1088            fault_qname == (&wsrl_UnableToSetTerminationTimeFault_qname))
1089          {
1090 0              *fault_type = RESOURCEPROPERTIESTESTPORTTYPE_SETTERMINATIONTIME_UNABLETOSETTERMINATIONTIMEFAULT;
1091          }
1092 0         else if(fault_qname == (&wsrl_ResourceUnknownFaultType_qname) ||
1093            fault_qname == (&wsrl_ResourceUnknownFault_qname))
1094          {
1095 0              *fault_type = RESOURCEPROPERTIESTESTPORTTYPE_SETTERMINATIONTIME_RESOURCEUNKNOWNFAULT;
1096          }
1097         else
1098         {
1099 0              *fault_type = RESOURCEPROPERTIESTESTPORTTYPE_SETTERMINATIONTIME_UNKNOWN_FAULT;
1100         }
1101     }
1102 }
1103
1104 static void
1105 SetTerminationTime_i_response_callback(
1106     void *                              args)
1107 0 {
1108 0     xsd_QName                           subelement;
1109 0     globus_soap_message_handle_t        message_handle = NULL;
1110 0     globus_soap_message_fault_t         soap_fault;
1111 0     globus_result_t                     result = GLOBUS_SUCCESS;
1112 0     globus_handler_chain_t              chain = NULL;
1113 0     xsd_QName *                         header_element = NULL;
1114 0     int                                 must;
1115 0     SetTerminationTime_i_response_handle_t * response;
1116 0     response = (SetTerminationTime_i_response_handle_t *) args;
1117 0     globus_assert_string(response, "response handle in callback is NULL");
1118     
1119 0     switch(response->state)
1120     {
1121         
1122     case RESOURCEPROPERTIESTESTSERVICE_RESPONSE_INIT:
1123
1124 0         globus_mutex_lock(&response->mutex);
1125 0         response->done = 0;
1126 0         response->state = RESOURCEPROPERTIESTESTSERVICE_RESPONSE_READING;
1127 0         globus_mutex_unlock(&response->mutex);
1128
1129 0         result = globus_soap_message_register_read_response(
1130             response->client_handle->message,
1131             SetTerminationTime_i_response_done_callback,
1132             response);
1133 0         if(result != GLOBUS_SUCCESS)
1134         {
1135 0             goto error_exit;
1136         }
1137
1138 0         break;
1139
1140     case RESOURCEPROPERTIESTESTSERVICE_RESPONSE_READING:
1141
1142 0         if(response->done)
1143         {
1144 0             if(response->result != GLOBUS_SUCCESS)
1145             {
1146 0                 if(GlobusSoapMessageErrorCheckFailedResponse(response->result) ||
1147                    GlobusSoapMessageErrorCheckBadRequest(response->result))
1148                 {
1149 0                     response->result = GLOBUS_SUCCESS;
1150                 }
1151                 else
1152                 {
1153 0                     result = response->result;
1154 0                     goto error_exit;
1155                 }
1156             }
1157                 
1158 0             globus_mutex_lock(&response->mutex);
1159 0             response->done = 0;
1160 0             response->state = RESOURCEPROPERTIESTESTSERVICE_RESPONSE_TRIGGER_HANDLERS;
1161 0             globus_mutex_unlock(&response->mutex);
1162
1163 0             result = globus_soap_message_deserialize_envelope(
1164                 response->client_handle->message);
1165 0             if(result != GLOBUS_SUCCESS)
1166             {
1167 0                 goto error_exit;
1168             }
1169
1170 0             result = globus_soap_message_deserialize_element_begin_close(
1171                 response->client_handle->message);
1172 0             if(result != GLOBUS_SUCCESS)
1173             {
1174 0                 goto error_exit;
1175             }
1176
1177 0             result = globus_soap_message_deserialize_header(
1178                 response->client_handle->message);
1179 0             if(result != GLOBUS_SUCCESS)
1180             {
1181 0                 if(GlobusSoapMessageStatusElementNotFoundCheck(result))
1182                 {
1183 0                     globus_soap_message_deserialize_push_element(
1184                         response->client_handle->message);
1185 0                     result = GLOBUS_SUCCESS;
1186 0                     globus_mutex_lock(&response->mutex);
1187 0                     response->state = 
1188                     RESOURCEPROPERTIESTESTSERVICE_RESPONSE_HEADER_FAILED;
1189 0                     globus_mutex_unlock(&response->mutex);
1190 0                     SetTerminationTime_i_response_done_callback(
1191                         result, response);
1192 0                     break;
1193                 }
1194                 
1195 0                 goto error_exit;
1196             }
1197
1198 0             globus_mutex_lock(&response->mutex);
1199 0             response->done = 1;
1200 0             globus_mutex_unlock(&response->mutex);
1201         }
1202
1203     case RESOURCEPROPERTIESTESTSERVICE_RESPONSE_TRIGGER_HANDLERS:
1204
1205 0         if(response->done)
1206         {
1207 0             if(response->result != GLOBUS_SUCCESS)
1208             {
1209 0                 if(GlobusSoapMessageErrorCheckFailedResponse(
1210                        response->result) ||
1211                    GlobusSoapMessageErrorCheckBadRequest(response->result))
1212                 {
1213 0                     response->result = GLOBUS_SUCCESS;
1214                 }
1215                 else
1216                 {
1217 0                     result = response->result;
1218 0                     goto error_exit;
1219                 }
1220             }
1221                 
1222 0             globus_mutex_lock(&response->mutex);
1223 0             response->done = 0;
1224 0             response->state = RESOURCEPROPERTIESTESTSERVICE_RESPONSE_TRIGGER_HANDLERS;
1225 0             globus_mutex_unlock(&response->mutex);
1226
1227 0             xsd_QName_init(&header_element);
1228                 
1229 0             result = globus_soap_message_deserialize_element_unknown(
1230                 response->client_handle->message,
1231                 header_element);
1232 0             if(result != GLOBUS_SUCCESS)
1233             {
1234 0                 if(!GlobusSoapMessageStatusFailedElementCheck(result))
1235                 {
1236 0                     xsd_QName_destroy(header_element);
1237 0                     goto error_exit;
1238                 }
1239                 else
1240                 {
1241 0                     globus_mutex_lock(&response->mutex);
1242 0                     response->done = 1;
1243 0                     response->state = 
1244                     RESOURCEPROPERTIESTESTSERVICE_RESPONSE_HANDLER_DESERIALIZE;
1245 0                     globus_mutex_unlock(&response->mutex);
1246
1247 0                     globus_callback_register_oneshot(
1248                         NULL,
1249                         &globus_i_reltime_zero,
1250                         SetTerminationTime_i_response_callback,
1251                         (void *)response);
1252 0                     xsd_QName_destroy(header_element);
1253 0                     break;
1254                 }
1255             }
1256
1257 0             result = globus_soap_message_deserialize_int_attribute(
1258                 response->client_handle->message,
1259                 &soap_mustUnderstand_qname,
1260                 &must);
1261 0             if(result == GLOBUS_SUCCESS && (must == 1))
1262             {
1263 0                 globus_soap_message_add_required_header_element(
1264                     response->client_handle->message,
1265                     header_element);
1266             }
1267 0             else if(result != GLOBUS_SUCCESS &&
1268                     !GlobusSoapMessageStatusAttributeNotFoundCheck(result))
1269             {
1270 0                 xsd_QName_destroy(header_element);
1271 0                 goto error_exit;
1272             }
1273
1274 0             globus_soap_message_deserialize_push_element(
1275                 response->client_handle->message);
1276
1277 0             result = globus_soap_message_get_handler_chain(
1278                 response->client_handle->message, &chain);
1279 0             if(result != GLOBUS_SUCCESS)
1280             {
1281 0                 goto error_exit;
1282             }
1283
1284 0             if(chain)
1285             {
1286 0                 result = globus_handler_chain_register_trigger(
1287                     chain,
1288                     response->client_handle->message,
1289                     header_element,
1290                     SetTerminationTime_i_response_done_callback,
1291                     response);
1292 0                 if(result == GLOBUS_SUCCESS)
1293                 {
1294 0                     xsd_QName_destroy(header_element);
1295 0                     break;
1296                 }
1297 0                 else if(!GlobusHandlerStatusNotTriggeredCheck(result))
1298                 {
1299 0                     xsd_QName_destroy(header_element);
1300 0                     goto error_exit;
1301                 }
1302             }
1303
1304 0             xsd_QName_destroy(header_element);
1305 0             result = globus_soap_message_deserialize_skip(
1306                 response->client_handle->message);
1307 0             if(result != GLOBUS_SUCCESS)
1308             {
1309 0                 goto error_exit;
1310             }
1311             
1312 0             globus_mutex_lock(&response->mutex);
1313 0             response->done = 1;
1314 0             globus_mutex_unlock(&response->mutex);
1315 0             globus_callback_register_oneshot(
1316                 NULL,
1317                 &globus_i_reltime_zero,
1318                 SetTerminationTime_i_response_callback,
1319                 (void *)response);
1320         }
1321
1322 0         break;
1323
1324     case RESOURCEPROPERTIESTESTSERVICE_RESPONSE_HANDLER_DESERIALIZE:
1325
1326 0         if(response->done)
1327         {
1328 0             if(response->result != GLOBUS_SUCCESS)
1329             {
1330 0                 result = response->result;
1331 0                 goto error_exit;
1332             }
1333
1334 0             globus_mutex_lock(&response->mutex);
1335 0             response->state = RESOURCEPROPERTIESTESTSERVICE_RESPONSE_INVOKING_HANDLERS;
1336 0             globus_mutex_unlock(&response->mutex);
1337
1338 0             result = globus_soap_message_deserialize_header_end(
1339                 response->client_handle->message);
1340 0             if(result != GLOBUS_SUCCESS)
1341             {
1342 0                 goto error_exit;
1343             }
1344
1345 0             result = globus_soap_message_deserialize_body(
1346                 response->client_handle->message);
1347 0             if(result != GLOBUS_SUCCESS)
1348             {
1349 0                 goto error_exit;
1350             }
1351         }
1352         
1353     case RESOURCEPROPERTIESTESTSERVICE_RESPONSE_HEADER_FAILED:
1354
1355 0         if(response->done)
1356         {
1357 0             if(response->result != GLOBUS_SUCCESS)
1358             {
1359 0                 result = response->result;
1360 0                 goto error_exit;
1361             }
1362
1363 0             globus_mutex_lock(&response->mutex);
1364 0             response->state = RESOURCEPROPERTIESTESTSERVICE_RESPONSE_INVOKING_HANDLERS;
1365 0             globus_mutex_unlock(&response->mutex);
1366             
1367 0             response->fault_type = RESOURCEPROPERTIESTESTPORTTYPE_SETTERMINATIONTIME_NOFAULT;
1368 0             response->fault_result = GLOBUS_SUCCESS;
1369
1370 0             result = globus_soap_message_deserialize_fault(
1371                 response->client_handle->message,
1372                 &soap_fault,
1373                 SetTerminationTime_i_deserialize_fault,
1374                 &response->fault,
1375                 &response->fault_type);
1376 0             if(result != GLOBUS_SUCCESS)
1377             {
1378 0                 if(response->result != GLOBUS_SUCCESS)
1379                 {
1380 0                     result = response->result;
1381                 }
1382 0                 goto error_exit;
1383             }
1384
1385 0             if(!soap_fault && response->fault_type == RESOURCEPROPERTIESTESTPORTTYPE_SETTERMINATIONTIME_NOFAULT)
1386             {
1387 0                 subelement.Namespace = "http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd";
1388 0                 subelement.local = "SetTerminationTimeResponse";
1389                 
1390 0                 result = wsrl_SetTerminationTimeResponseType_deserialize_pointer(
1391                     &subelement,
1392                     &response->SetTerminationTimeResponse,
1393                     response->client_handle->message,
1394                     0);
1395 0                 if(result != GLOBUS_SUCCESS)
1396                 {
1397 0                     goto error_exit;
1398                 }
1399             }
1400             else
1401             {
1402 0                 if(soap_fault)
1403                 {
1404 0                     response->fault_result = GlobusSoapMessageErrorFault(
1405                         soap_fault);
1406                 }                
1407
1408 0                 result = globus_soap_message_deserialize_fault_end(
1409                     response->client_handle->message,
1410                     response->fault
1411                         ? response->fault->element
1412                         : &soap_fault_qname);
1413 0                 if(result != GLOBUS_SUCCESS)
1414                 {
1415 0                     goto error_exit;
1416                 }
1417             }
1418
1419 0             result = globus_soap_message_deserialize_body_end(
1420                 response->client_handle->message);
1421 0             if(result != GLOBUS_SUCCESS)
1422             {
1423 0                 goto error_exit;
1424             }
1425
1426 0             result = globus_soap_message_deserialize_envelope_end(
1427                 response->client_handle->message);
1428 0             if(result != GLOBUS_SUCCESS)
1429             {
1430 0                 goto error_exit;
1431             }
1432
1433
1434 0             if(!soap_fault && response->fault_type == RESOURCEPROPERTIESTESTPORTTYPE_SETTERMINATIONTIME_NOFAULT)
1435             {
1436 0                 result = globus_soap_message_get_handler_chain(
1437                     response->client_handle->message, &chain);
1438 0                 if(result != GLOBUS_SUCCESS)
1439                 {
1440 0                     goto error_exit;
1441                 }
1442                 
1443 0                 if(chain)
1444                 {
1445 0                     globus_handler_chain_register_invoke(
1446                         chain,
1447                         GLOBUS_HANDLER_TYPE_RESPONSE,
1448                         response->client_handle->message,
1449                         SetTerminationTime_i_response_done_callback,
1450                         response);
1451                 }
1452             }
1453             else
1454             {
1455 0                 globus_mutex_lock(&response->mutex);
1456 0                 response->done = 1;
1457 0                 response->state = RESOURCEPROPERTIESTESTSERVICE_RESPONSE_CLOSE;
1458 0                 globus_mutex_unlock(&response->mutex);
1459 0                 globus_callback_register_oneshot(
1460                     NULL,
1461                     &globus_i_reltime_zero,
1462                     SetTerminationTime_i_response_callback,
1463                     (void *)response);
1464             }
1465         }
1466         
1467 0         break;
1468
1469     case RESOURCEPROPERTIESTESTSERVICE_RESPONSE_INVOKING_HANDLERS:
1470
1471 0         if(response->done)
1472         {
1473 0             if(response->result != GLOBUS_SUCCESS)
1474             {
1475 0                 result = response->result;
1476 0                 goto error_exit;
1477             }
1478             
1479 0             result = globus_soap_message_check_required_headers(
1480                 response->client_handle->message);
1481 0             if(result != GLOBUS_SUCCESS)
1482             {
1483                 /* continue on in case fault was returned and
1484                  * no header elements exist
1485                  */
1486 0                 response->result = result;
1487             }
1488         }
1489
1490     case RESOURCEPROPERTIESTESTSERVICE_RESPONSE_CLOSE:
1491
1492 0         if(response->done)
1493         {
1494 0             if(response->result != GLOBUS_SUCCESS)
1495             {
1496 0                 result = response->result;
1497 0                 goto error_exit;
1498             }
1499
1500 0             globus_mutex_lock(&response->mutex);
1501 0             response->done = 0;
1502 0             response->state = RESOURCEPROPERTIESTESTSERVICE_RESPONSE_DONE;
1503 0             globus_mutex_unlock(&response->mutex);
1504             
1505 0             result = globus_soap_message_register_close(
1506                 response->client_handle->message,
1507                 SetTerminationTime_i_response_done_callback,
1508                 response);
1509 0             if(result != GLOBUS_SUCCESS)
1510             {
1511 0                 goto error_exit;
1512             }
1513         }
1514
1515 0         break;
1516
1517     case RESOURCEPROPERTIESTESTSERVICE_RESPONSE_DONE:
1518
1519
1520 0         if(response->done)
1521         {
1522 0             if(response->result != GLOBUS_SUCCESS)
1523             {
1524 0                 result = response->result;
1525 0                 goto error_exit;
1526             }
1527
1528 0             globus_mutex_lock(&response->mutex);
1529 0             response->done = 0;
1530 0             message_handle = response->client_handle->message;
1531 0             response->client_handle->message = NULL;
1532 0             globus_mutex_unlock(&response->mutex);
1533
1534 0             response->callback(
1535                 response->client_handle, 
1536                 response->args, 
1537                 response->fault_result,
1538                 response->SetTerminationTimeResponse,
1539                 response->fault_type,
1540                 response->fault);
1541
1542 0             if(response->SetTerminationTimeResponse)
1543             {
1544 0                 wsrl_SetTerminationTimeResponseType_destroy(response->SetTerminationTimeResponse);
1545             }
1546         
1547 0             if(response->fault)
1548             {
1549 0                 xsd_any_destroy(response->fault);
1550 0                 response->fault_type = RESOURCEPROPERTIESTESTPORTTYPE_SETTERMINATIONTIME_NOFAULT;
1551 0                 response->fault = NULL;
1552             }
1553
1554 0             globus_soap_message_handle_destroy(message_handle);
1555 0             SetTerminationTime_i_response_handle_destroy(response);
1556         }
1557
1558 0         break;
1559
1560     default:
1561
1562 0         globus_assert_string(NULL, "Unknown response state");
1563     }
1564
1565 0     return;
1566
1567  error_exit:
1568
1569 0     if(!GlobusSoapMessageStatusCheck(result))
1570     {
1571 0         result = GlobusSoapMessageErrorClientResponseFailed(
1572             result, "ResourcePropertiesTestPortType_SetTerminationTime");
1573     }
1574
1575 0     globus_mutex_lock(&response->mutex);
1576 0     message_handle = response->client_handle->message;
1577 0     response->client_handle->message = NULL;
1578 0     globus_mutex_unlock(&response->mutex);
1579     
1580 0     response->callback(
1581         response->client_handle,
1582         response->args,
1583         result,
1584         response->SetTerminationTimeResponse,
1585         response->fault_type,
1586         response->fault);
1587
1588 0     if(response->SetTerminationTimeResponse)
1589     {
1590 0         wsrl_SetTerminationTimeResponseType_destroy(response->SetTerminationTimeResponse);
1591     }
1592
1593 0     if(response->fault)
1594     {
1595 0         xsd_any_destroy(response->fault);
1596
1597 0         response->fault_type = RESOURCEPROPERTIESTESTPORTTYPE_SETTERMINATIONTIME_NOFAULT;
1598 0         response->fault = NULL;
1599     }
1600
1601 0     globus_soap_message_handle_destroy(message_handle);
1602 0     SetTerminationTime_i_response_handle_destroy(response);
1603 }
1604
1605 globus_result_t
1606 ResourcePropertiesTestPortType_SetTerminationTime_register_response(
1607     ResourcePropertiesTestService_client_handle_t             client_handle,
1608     ResourcePropertiesTestPortType_SetTerminationTime_response_callback_func_t callback,
1609     void * user_args)
1610 0 {
1611 0     globus_result_t                     result = GLOBUS_SUCCESS;
1612 0     SetTerminationTime_i_response_handle_t * response;
1613
1614 0     response = globus_malloc(
1615         sizeof(SetTerminationTime_i_response_handle_t));
1616 0     globus_assert_string(response, "Memory allocation failed.");
1617 0     memset(response, 0, sizeof(SetTerminationTime_i_response_handle_t));
1618
1619 0     response->callback = callback;
1620 0     response->args = user_args;
1621 0     response->client_handle = client_handle;
1622 0     response->state = RESOURCEPROPERTIESTESTSERVICE_RESPONSE_INIT;
1623 0     globus_mutex_init(&response->mutex, NULL);
1624
1625 0     result = globus_soap_message_handle_set_attr(
1626         client_handle->message, 
1627         WSADDR_ACTION_RESPONSE_KEY, 
1628         globus_soap_message_attr_copy_string,
1629         globus_libc_free,
1630         "http://www.globus.org/namespaces/2004/10/ResourcePropertiesTest/ResourcePropertiesTestPortType/SetTerminationTimeResponse");
1631 0     if(result != GLOBUS_SUCCESS)
1632     {
1633 0         if(!GlobusSoapMessageStatusCheck(result))
1634         {
1635 0             result = GlobusSoapMessageErrorClientRequestFailed(
1636                 result, "ResourcePropertiesTestPortType_SetTerminationTime");
1637 0             goto exit;
1638         }
1639     }
1640
1641 0     result = globus_callback_register_oneshot(
1642         &response->callback_handle,
1643         NULL,
1644         SetTerminationTime_i_response_callback,
1645         response);
1646 0     if(result != GLOBUS_SUCCESS)
1647     {
1648 0         result = GlobusSoapMessageErrorClientResponseFailed(
1649             result, "ResourcePropertiesTestPortType_SetTerminationTime");
1650 0         goto exit;
1651     }
1652
1653 0     return result;
1654     
1655  exit:
1656 0     globus_mutex_destroy(&response->mutex);
1657 0     globus_free(response);
1658 0     return result;
1659 }
1660
1661 globus_result_t
1662 ResourcePropertiesTestPortType_SetTerminationTime_epr_register(
1663     ResourcePropertiesTestService_client_handle_t handle,
1664     const wsa_EndpointReferenceType * epr,
1665     const wsrl_SetTerminationTimeType * SetTerminationTime,
1666     ResourcePropertiesTestPortType_SetTerminationTime_response_callback_func_t callback,
1667     void * user_args)
1668 0 {
1669 0     globus_result_t                     result = GLOBUS_SUCCESS;
1670
1671 0     globus_assert_string(epr, "NULL EndpointReference");
1672 0     globus_assert_string(epr->Address.base_value, "NULL EndpointReference Address");
1673
1674 0     globus_soap_message_attr_set(
1675         handle->attrs,
1676         WSADDR_EPR_KEY,
1677         wsa_EndpointReferenceType_copy_wrapper,
1678         wsa_EndpointReferenceType_destroy_wrapper,
1679         (void *)epr);
1680
1681 0     result = ResourcePropertiesTestPortType_SetTerminationTime_register(
1682         handle, 
1683         epr->Address.base_value,
1684         SetTerminationTime,
1685         callback,
1686         user_args);
1687     
1688 0     return result;
1689 }
1690
1691 globus_result_t
1692 ResourcePropertiesTestPortType_SetTerminationTime_register(
1693     ResourcePropertiesTestService_client_handle_t handle,
1694     const char * endpoint,
1695     const wsrl_SetTerminationTimeType * SetTerminationTime,
1696     ResourcePropertiesTestPortType_SetTerminationTime_response_callback_func_t callback,
1697     void * user_args)
1698 0 {
1699 0     SetTerminationTime_i_blocking_request_callback_t * callback_handle;
1700 0     globus_result_t result = GLOBUS_SUCCESS;
1701
1702 0     callback_handle = globus_malloc(
1703         sizeof(SetTerminationTime_i_blocking_request_callback_t));
1704 0     globus_assert_string(callback_handle, "Memory allocation failed");
1705 0     memset(callback_handle, 0, 
1706            sizeof(SetTerminationTime_i_blocking_request_callback_t));
1707
1708 0     callback_handle->callback = callback;
1709 0     callback_handle->args = user_args;
1710
1711 0     result = ResourcePropertiesTestPortType_SetTerminationTime_register_request(
1712         handle,
1713         endpoint,
1714         SetTerminationTime,
1715         SetTerminationTime_i_blocking_request_callback,
1716         callback_handle);
1717 0     if(result != GLOBUS_SUCCESS)
1718     {
1719 0         globus_free(callback_handle);
1720         goto exit;
1721     }
1722
1723  exit:
1724
1725 0     return result;
1726 }
1727
1728 typedef struct SetTerminationTime_i_blocking_response_callback_s
1729 {
1730     globus_result_t result;
1731     ResourcePropertiesTestPortType_SetTerminationTime_fault_t fault_type;
1732     xsd_any * fault;
1733     wsrl_SetTerminationTimeResponseType * SetTerminationTimeResponse;
1734     int done;
1735     globus_cond_t cond;
1736     globus_mutex_t mutex;
1737 } SetTerminationTime_i_blocking_response_callback_t;
1738
1739 static
1740 void
1741 SetTerminationTime_i_blocking_response_callback(
1742     ResourcePropertiesTestService_client_handle_t handle,
1743     void * user_args,
1744     globus_result_t result,
1745     const wsrl_SetTerminationTimeResponseType * SetTerminationTimeResponse,
1746     ResourcePropertiesTestPortType_SetTerminationTime_fault_t fault_type,
1747     const xsd_any * fault)
1748 0 {
1749 0     SetTerminationTime_i_blocking_response_callback_t * callback_handle;
1750
1751 0     callback_handle = (SetTerminationTime_i_blocking_response_callback_t *) user_args;
1752
1753 0     callback_handle->result = result;
1754 0     if(result == GLOBUS_SUCCESS)
1755     {
1756 0         wsrl_SetTerminationTimeResponseType_copy(
1757             &callback_handle->SetTerminationTimeResponse, SetTerminationTimeResponse);
1758     }
1759     else
1760     {
1761 0         callback_handle->fault_type = fault_type;
1762 0         if(fault_type != GLOBUS_SUCCESS)
1763         {
1764 0             xsd_any_copy(&callback_handle->fault, fault);
1765         }
1766     }
1767
1768 0     globus_mutex_lock(&callback_handle->mutex);
1769 0     globus_cond_signal(&callback_handle->cond);
1770 0     callback_handle->done = 1;
1771 0     globus_mutex_unlock(&callback_handle->mutex);
1772 }
1773
1774
1775 globus_result_t
1776 ResourcePropertiesTestPortType_SetTerminationTime_epr(
1777     ResourcePropertiesTestService_client_handle_t handle,
1778     const wsa_EndpointReferenceType * epr,
1779     const wsrl_SetTerminationTimeType * SetTerminationTime,
1780     wsrl_SetTerminationTimeResponseType * * SetTerminationTimeResponse,
1781     ResourcePropertiesTestPortType_SetTerminationTime_fault_t * fault_type,
1782     xsd_any * * fault)
1783 0 {
1784 0     globus_result_t                     result = GLOBUS_SUCCESS;
1785
1786 0     globus_assert_string(epr, "NULL EndpointReference");
1787 0     globus_assert_string(epr->Address.base_value, "NULL EndpointReference Address");
1788
1789 0     *fault_type = RESOURCEPROPERTIESTESTPORTTYPE_SETTERMINATIONTIME_NOFAULT;
1790
1791 0     globus_soap_message_attr_set(
1792         handle->attrs,
1793         WSADDR_EPR_KEY,
1794         wsa_EndpointReferenceType_copy_wrapper,
1795         wsa_EndpointReferenceType_destroy_wrapper,
1796         (void *)epr);
1797
1798 0     result = ResourcePropertiesTestPortType_SetTerminationTime(
1799         handle, 
1800         epr->Address.base_value,
1801         SetTerminationTime,
1802         SetTerminationTimeResponse,
1803         fault_type,
1804         fault);
1805
1806 0     return result;
1807 }
1808         
1809 globus_result_t
1810 ResourcePropertiesTestPortType_SetTerminationTime(
1811     ResourcePropertiesTestService_client_handle_t handle,
1812     const char * endpoint,
1813     const wsrl_SetTerminationTimeType * SetTerminationTime,
1814     wsrl_SetTerminationTimeResponseType * * SetTerminationTimeResponse,
1815     ResourcePropertiesTestPortType_SetTerminationTime_fault_t * fault_type,
1816     xsd_any * * fault)
1817 0 {
1818 0     globus_result_t result = GLOBUS_SUCCESS;
1819
1820 0     SetTerminationTime_i_blocking_response_callback_t * callback_handle;
1821 0     *fault_type = RESOURCEPROPERTIESTESTPORTTYPE_SETTERMINATIONTIME_NOFAULT;
1822     
1823 0     callback_handle = globus_malloc(
1824         sizeof(SetTerminationTime_i_blocking_response_callback_t));
1825 0     globus_assert_string(callback_handle, "Memory allocation failed");
1826 0     memset(callback_handle, 0, 
1827            sizeof(SetTerminationTime_i_blocking_response_callback_t));
1828
1829 0     globus_mutex_init(&callback_handle->mutex, NULL);
1830 0     globus_cond_init(&callback_handle->cond, NULL);
1831
1832 0     result = ResourcePropertiesTestPortType_SetTerminationTime_register(
1833         handle,
1834         endpoint,
1835         SetTerminationTime,
1836         SetTerminationTime_i_blocking_response_callback,
1837         callback_handle);
1838 0     if(result != GLOBUS_SUCCESS)
1839     {
1840 0         goto exit;
1841     }
1842
1843
1844 0     globus_mutex_lock(&callback_handle->mutex);
1845 0     while(!callback_handle->done)
1846     {
1847 0         globus_cond_wait(&callback_handle->cond, &callback_handle->mutex);
1848     }
1849 0     globus_mutex_unlock(&callback_handle->mutex);
1850
1851 0     result = callback_handle->result;
1852 0     if(result != GLOBUS_SUCCESS)
1853     {
1854
1855 0         *fault_type = callback_handle->fault_type;
1856 0         *fault = callback_handle->fault;
1857
1858 0         goto exit;
1859     }
1860
1861 0     *SetTerminationTimeResponse = callback_handle->SetTerminationTimeResponse;
1862
1863  exit:
1864     
1865 0     globus_mutex_destroy(&callback_handle->mutex);
1866 0     globus_cond_destroy(&callback_handle->cond);
1867
1868 0     free(callback_handle);
1869
1870 0     return result;
1871 }
1872
1873
1874
1875 typedef struct Destroy_i_request_handle_s
1876 {
1877     char * endpoint;
1878     int done;
1879     globus_mutex_t mutex;
1880     ResourcePropertiesTestService_request_state_t state;
1881     ResourcePropertiesTestPortType_Destroy_request_callback_func_t callback;
1882     void * args;
1883     ResourcePropertiesTestService_client_handle_t client_handle;
1884     wsrl_DestroyType * Destroy;
1885     globus_callback_handle_t            callback_handle;
1886     globus_result_t result;
1887 } Destroy_i_request_handle_t;
1888
1889 static void
1890 Destroy_i_request_callback(
1891     void *                              args);
1892
1893 static void
1894 Destroy_i_request_done_callback(
1895     globus_result_t                     result,
1896     void *                              args)
1897 110 {
1898 110     Destroy_i_request_handle_t * request;
1899
1900 110     request = (Destroy_i_request_handle_t *) args;
1901 110     globus_assert_string(request, "request handle in callback is NULL");
1902
1903 110     globus_mutex_lock(&request->mutex);
1904 110     request->result = result;
1905 110     request->done = 1;
1906 110     globus_mutex_unlock(&request->mutex);
1907
1908 110     Destroy_i_request_callback(request);
1909 }
1910
1911 static void
1912 Destroy_i_request_handle_destroy(
1913     void *                              args)
1914 22 {
1915 22     Destroy_i_request_handle_t * request;
1916
1917 22     request = (Destroy_i_request_handle_t *) args;
1918 22     globus_assert_string(request, "request handle in callback is NULL");
1919
1920 22     globus_mutex_destroy(&request->mutex);
1921     
1922 22     if(request->Destroy)
1923     {
1924 22         wsrl_DestroyType_destroy(request->Destroy);
1925     }
1926 22     if(request->endpoint)
1927     {
1928 22         globus_free(request->endpoint);
1929     }
1930
1931 22     globus_free(request);
1932 }
1933
1934 static void
1935 Destroy_i_request_callback(
1936     void *                              args)
1937 132 {
1938 132     globus_soap_message_handle_t        message_handle = NULL;
1939 132     globus_result_t                     result = GLOBUS_SUCCESS;
1940 132     globus_handler_chain_t              chain = NULL;
1941 132     Destroy_i_request_handle_t * request;
1942 132     xsd_QName                           subelement;
1943
1944 132     request = (Destroy_i_request_handle_t *) args;
1945 132     globus_assert_string(request, "request handle is NULL");
1946
1947 132     switch(request->state)
1948     {
1949
1950     case RESOURCEPROPERTIESTESTSERVICE_REQUEST_INIT:
1951
1952 22         globus_mutex_lock(&request->mutex);
1953 22         request->done = 0;
1954 22         request->state = RESOURCEPROPERTIESTESTSERVICE_REQUEST_INIT_HANDLERS;
1955 22         globus_mutex_unlock(&request->mutex);
1956
1957 22         result = globus_soap_message_get_handler_chain(
1958             request->client_handle->message, &chain);
1959 22         if(result != GLOBUS_SUCCESS)
1960         {
1961 0             goto error_exit;
1962         }
1963
1964 22         if(chain)
1965         {
1966 22             globus_handler_chain_register_invoke(
1967                 chain, 
1968                 GLOBUS_HANDLER_TYPE_REQUEST_INIT,
1969                 request->client_handle->message,
1970                 Destroy_i_request_done_callback,
1971                 request);
1972         }
1973
1974 22         break;
1975
1976     case RESOURCEPROPERTIESTESTSERVICE_REQUEST_INIT_HANDLERS:
1977
1978 22         globus_mutex_lock(&request->mutex);
1979 22         request->done = 0;
1980 22         request->state = RESOURCEPROPERTIESTESTSERVICE_REQUEST_OPENING;
1981 22         globus_mutex_unlock(&request->mutex);
1982
1983 22         result = globus_soap_message_register_open(
1984             request->client_handle->message, 
1985             request->endpoint,
1986             Destroy_i_request_done_callback,
1987             request);
1988 22         if(result != GLOBUS_SUCCESS)
1989         {
1990 0             goto error_exit;
1991         }
1992
1993 22         break;
1994
1995     case RESOURCEPROPERTIESTESTSERVICE_REQUEST_OPENING:
1996
1997 22         if(request->done)
1998  &nbs