/
onvifHandleProbe.c
1290 lines (1180 loc) · 46.7 KB
/
onvifHandleProbe.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "soapH.h"
#include "appTools.h"
#include "appCommon.h"
#include "onvifHandle.h"
#include "threads.h"
#include "logInfo.h"
#define METADATA_VERSION 1
#define INTERFACE_NUM 1
#define SOAP_WSA_ID "SOAP-WSA-1.3"
const char soap_wsa_id[] = SOAP_WSA_ID;
static MUTEX_TYPE soap_wsdd_state = MUTEX_INITIALIZER;
static unsigned int soap_wsdd_InstanceId = 0;
static const char *soap_wsdd_SequenceId = NULL;
static unsigned int soap_wsdd_MessageNumber = 1;
#if defined(SOAP_WSA_2003)
/** Anonymous Reply/To endpoint address */
const char *soap_wsa_anonymousURI = "http://schemas.xmlsoap.org/ws/2003/03/addressing/role/anonymous";
/** Specifies no Reply endpoint address (no reply) */
const char *soap_wsa_noneURI = "addressing/none not supported";
const char *soap_wsa_faultAction = "http://schemas.xmlsoap.org/ws/2003/03/addressing/fault";
#elif defined(SOAP_WSA_2004)
/** Anonymous Reply/To endpoint address */
const char *soap_wsa_anonymousURI = "http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous";
/** Specifies no Reply endpoint address (no reply) */
const char *soap_wsa_noneURI = "addressing/none not supported";
const char *soap_wsa_faultAction = "http://schemas.xmlsoap.org/ws/2004/03/addressing/fault";
#elif defined(SOAP_WSA_2005)
/** Anonymous Reply/To endpoint address */
const char *soap_wsa_anonymousURI =
"http://www.w3.org/2005/08/addressing/anonymous";
/** Specifies no Reply endpoint address (no reply) */
const char *soap_wsa_noneURI = "http://www.w3.org/2005/08/addressing/none";
const char *soap_wsa_faultAction =
"http://www.w3.org/2005/08/addressing/soap/fault";
#else
/** Anonymous Reply/To endpoint address */
const char *soap_wsa_anonymousURI = "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous";
/** Specifies no Reply endpoint address (no reply) */
const char *soap_wsa_noneURI = "addressing/none not supported";
const char *soap_wsa_faultAction = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault";
#endif
/** anonymous URI of 2004 and 2005 schemas */
const char *soap_wsa_allAnonymousURI =
"http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous http://www.w3.org/2005/08/addressing/anonymous";
#ifdef SOAP_WSA_2005
/* WS-Discovery 1.0 */
const char *to_ts_URL = "urn:schemas-xmlsoap-org:ws:2005:04:discovery";
#else
/* WS-Discovery 1.1 */
const char *to_ts_URL = "urn:docs-oasis-open-org:ws-dd:ns:discovery:2009:01";
#endif
#if defined(SOAP_WSA_2003)
# define SOAP_WSA(member) wsa3__##member
# define SOAP_WSA_(prefix,member) prefix##_wsa3__##member
# define SOAP_WSA__(prefix,member) prefix##wsa3__##member
#elif defined(SOAP_WSA_2004)
# define SOAP_WSA(member) wsa4__##member
# define SOAP_WSA_(prefix,member) prefix##_wsa4__##member
# define SOAP_WSA__(prefix,member) prefix##wsa4__##member
#elif defined(SOAP_WSA_2005)
# define SOAP_WSA(member) wsa5__##member
# define SOAP_WSA_(prefix,member) prefix##_wsa5__##member
# define SOAP_WSA__(prefix,member) prefix##wsa5__##member
#else
# define SOAP_WSA(member) wsa__##member
# define SOAP_WSA_(prefix,member) prefix##_wsa__##member
# define SOAP_WSA__(prefix,member) prefix##wsa__##member
#endif
typedef enum soap_wsdd_mode {
SOAP_WSDD_MANAGED, SOAP_WSDD_ADHOC
} soap_wsdd_mode;
struct soap_wsa_data { /** fheader callback is invoked immediately after parsing a SOAP Header */
int (*fheader)(struct soap*);
/** fseterror callback is used to inspect and change gSOAP error codes */
void (*fseterror)(struct soap*, const char**, const char**);
/** fresponse callback is used to change a HTTP response into a HTTP POST */
int (*fresponse)(struct soap*, int, size_t);
};
SOAP_FMAC5 int SOAP_FMAC6 soap_wsa_alloc_header(struct soap *soap) {
soap_header(soap);
if (soap->header)
return SOAP_OK;
return soap->error = SOAP_EOM;
}
SOAP_FMAC5 int SOAP_FMAC6 soap_wsa_response(struct soap *soap, int status,
size_t count) {
struct soap_wsa_data *data = (struct soap_wsa_data*) soap_lookup_plugin(
soap, soap_wsa_id);
DBGFUN2("soap_wsa_response", "status=%d", status, "count=%lu",
(unsigned long) count);
if (!data)
return SOAP_PLUGIN_ERROR;
soap->fresponse = data->fresponse; /* reset (HTTP response) */
return soap->fpost(soap, soap_strdup(soap, soap->endpoint), soap->host,
soap->port, soap->path, soap->action, count);
}
SOAP_FMAC5 int SOAP_FMAC6 soap_wsa_fault_subcode_action(struct soap *soap,
int flag, const char *faultsubcode, const char *faultstring,
const char *faultdetail, const char *action) {
struct soap_wsa_data *data = (struct soap_wsa_data*) soap_lookup_plugin(
soap, soap_wsa_id);
struct SOAP_ENV__Header *oldheader, *newheader;
DBGFUN2("soap_wsa_fault_subcode", "faultsubcode=%s",
faultsubcode ? faultsubcode : "(null)", "faultstring=%s",
faultstring ? faultstring : "(null)");
if (!data)
return soap->error = SOAP_PLUGIN_ERROR;
oldheader = soap->header;
/* no FaultTo: use ReplyTo */
if (oldheader && oldheader->SOAP_WSA(ReplyTo)
&& (!oldheader->SOAP_WSA(FaultTo)
|| soap_tagsearch(soap_wsa_allAnonymousURI,
oldheader->SOAP_WSA(FaultTo)->Address))) {
if (!oldheader->SOAP_WSA(FaultTo)) {
oldheader->SOAP_WSA(FaultTo) = (SOAP_WSA_(,FaultTo)*) my_soap_malloc(
soap, sizeof(SOAP_WSA_(,FaultTo)));
SOAP_WSA_(soap_default,EndpointReferenceType)(soap,
soap->header->SOAP_WSA(FaultTo));
}
oldheader->SOAP_WSA(FaultTo)->Address =
oldheader->SOAP_WSA(ReplyTo)->Address;
}
if (oldheader && oldheader->SOAP_WSA(FaultTo)) {
DBGLOG(TEST, SOAP_MESSAGE(fdebug, "WSA FaultTo='%s'\n", oldheader->SOAP_WSA(FaultTo)->Address));
}
if (oldheader && oldheader->SOAP_WSA(FaultTo)
&& !strcmp(oldheader->SOAP_WSA(FaultTo)->Address, soap_wsa_noneURI))
return soap_send_empty_response(soap, SOAP_OK); /* HTTP ACCEPTED */
soap->header = NULL;
/* allocate a new header */
if (soap_wsa_alloc_header(soap))
return soap->error;
newheader = soap->header;
soap_default_SOAP_ENV__Header(soap, newheader); /* remove/clear SOAP Header */
/* check header */
if (oldheader && oldheader->SOAP_WSA(MessageID)) {
newheader->SOAP_WSA(RelatesTo) = (SOAP_WSA_(,RelatesTo)*) my_soap_malloc(
soap, sizeof(SOAP_WSA_(,RelatesTo)));
SOAP_WSA_(soap_default_, RelatesTo)
(soap, newheader->SOAP_WSA(RelatesTo));
newheader->SOAP_WSA(RelatesTo)->__item = oldheader->SOAP_WSA(MessageID);
}
/* header->wsa__MessageID = "..."; */
newheader->SOAP_WSA(Action) = (char*) soap_wsa_faultAction;
if (oldheader && oldheader->SOAP_WSA(FaultTo)
&& oldheader->SOAP_WSA(FaultTo)->Address
&& !soap_tagsearch(soap_wsa_allAnonymousURI,
oldheader->SOAP_WSA(FaultTo)->Address)) {
newheader->SOAP_WSA(To) = oldheader->SOAP_WSA(FaultTo)->Address;
/* (re)connect to FaultTo endpoint if From != FaultTo */
if (!oldheader->SOAP_WSA(From) || !oldheader->SOAP_WSA(From)->Address
|| strcmp(oldheader->SOAP_WSA(From)->Address,
oldheader->SOAP_WSA(FaultTo)->Address)) {
soap->keep_alive = 0;
soap_send_empty_response(soap, SOAP_OK); /* HTTP ACCEPTED */
if (soap_connect(soap, newheader->SOAP_WSA(To),
newheader->SOAP_WSA(Action)))
return soap->error = SOAP_STOP; /* nowhere to go */
soap_set_endpoint(soap, newheader->SOAP_WSA(To));
if (action)
soap->action = (char*) action;
else
soap->action = newheader->SOAP_WSA(Action);
data->fresponse = soap->fresponse;
soap->fresponse = soap_wsa_response; /* response will be a POST */
}
} else if (oldheader && oldheader->SOAP_WSA(From))
newheader->SOAP_WSA(To) = oldheader->SOAP_WSA(From)->Address;
else
newheader->SOAP_WSA(To) = (char*) soap_wsa_anonymousURI;
soap->header = newheader;
if (flag)
return soap_sender_fault_subcode(soap, faultsubcode, faultstring,
faultdetail);
return soap_receiver_fault_subcode(soap, faultsubcode, faultstring,
faultdetail);
}
SOAP_FMAC5 int SOAP_FMAC6 soap_wsa_fault_subcode(struct soap *soap, int flag,
const char *faultsubcode, const char *faultstring,
const char *faultdetail) {
return soap_wsa_fault_subcode_action(soap, flag, faultsubcode, faultstring,
faultdetail, NULL);
}
SOAP_FMAC5 int SOAP_FMAC6 soap_wsa_sender_fault(struct soap *soap,
const char *faultstring, const char *faultdetail) {
return soap_wsa_fault_subcode(soap, 1, NULL, faultstring, faultdetail);
}
SOAP_FMAC5 int SOAP_FMAC6 soap_wsdd_http(struct soap *soap,
const char *endpoint, const char *host, int port, const char *path,
const char *action, size_t count) {
return soap->fresponse(soap, SOAP_OK, count);
}
char* getUUId() {
char* uuid = onvifRunParam.urnHardwareId;
return uuid + 4;
}
char* soap_wsa_rand_uuid(struct soap *soap) {
char *uuid = (char*) my_soap_malloc(soap, 48);
int r1, r2, r3, r4;
#ifdef WITH_OPENSSL
r1 = soap_random;
r2 = soap_random;
#else
static int k = 0xFACEB00B;
int lo = k % 127773;
int hi = k / 127773;
# ifdef HAVE_GETTIMEOFDAY
struct timeval tv;
gettimeofday(&tv, NULL);
r1 = 10000000 * tv.tv_sec + tv.tv_usec;
#else
r1 = (int) time(NULL);
# endif
k = 16807 * lo - 2836 * hi;
if (k <= 0)
k += 0x7FFFFFFF;
r2 = k;
k &= 0x8FFFFFFF;
r2 += *((int*) soap->buf);
#endif
r3 = soap_random;
r4 = soap_random;
sprintf(uuid, "urn:uuid:%8.8x-%4.4hx-4%3.3hx-%4.4hx-%4.4hx%8.8x", r1,
(short) (r2 >> 16), ((short) r2 >> 4) & 0x0FFF,
((short) (r3 >> 16) & 0x3FFF) | 0x8000, (short) r3, r4);
DBGFUN1("soap_wsa_rand_uuid", "%s", uuid);
return uuid;
}
SOAP_FMAC5 int SOAP_FMAC6 soap_wsa_receiver_fault_subcode(struct soap *soap,
const char *faultsubcode, const char *faultstring,
const char *faultdetail) {
return soap_wsa_fault_subcode(soap, 0, faultsubcode, faultstring,
faultdetail);
}
SOAP_FMAC5 int SOAP_FMAC6 soap_wsa_sender_fault_subcode(struct soap *soap,
const char *faultsubcode, const char *faultstring,
const char *faultdetail) {
return soap_wsa_fault_subcode(soap, 1, faultsubcode, faultstring,
faultdetail);
}
#if defined(SOAP_WSA_2005)
/**
@fn SOAP_FMAC5 int SOAP_FMAC6 soap_wsa_error(struct soap *soap, SOAP_WSA(FaultCodesType) fault, const char *info)
@brief Sets SOAP Fault (sub)code for server WS-Addressing fault response.
@param soap context
@param[in] fault is one of wsa:FaultCodesType enumeration values
@param[in] info is the value of the element in the Fault detail field
@return SOAP_FAULT
*/
SOAP_FMAC5 int SOAP_FMAC6 soap_wsa_error(struct soap *soap,
SOAP_WSA(FaultCodesType) fault, const char *info) {
const char *code = SOAP_WSA_(soap,FaultCodesType2s)(soap, fault);
/* populate the SOAP Fault as per WS-Addressing spec */
switch (fault) {
case SOAP_WSA(InvalidAddressingHeader):
soap_faultdetail(soap);
if (soap->version == 1) {
soap->fault->detail->__type =
SOAP_WSA_(SOAP_TYPE_,ProblemHeaderQName);
soap->fault->detail->fault = (void*) info;
} else {
soap->fault->SOAP_ENV__Detail->__type =
SOAP_WSA_(SOAP_TYPE_,ProblemHeaderQName);
soap->fault->SOAP_ENV__Detail->fault = (void*) info;
}
soap_wsa_sender_fault_subcode(soap, code,
"A header representing a Message Addressing Property is not valid and the message cannot be processed.",
NULL);
break;
case SOAP_WSA(InvalidAddress):
soap_wsa_sender_fault_subcode(soap, code, "Invalid address.", NULL);
break;
case SOAP_WSA(InvalidEPR):
soap_wsa_sender_fault_subcode(soap, code, "Invalid EPR.", NULL);
break;
case SOAP_WSA(InvalidCardinality):
soap_wsa_sender_fault_subcode(soap, code,
"Invalid cardinality of headers.", NULL);
break;
case SOAP_WSA(MissingAddressInEPR):
soap_wsa_sender_fault_subcode(soap, code, "Missing EPR address.", NULL);
break;
case SOAP_WSA(DuplicateMessageID):
soap_wsa_sender_fault_subcode(soap, code,
"Message contains the message ID of a message already received.",
NULL);
break;
case SOAP_WSA(ActionMismatch):
soap_wsa_sender_fault_subcode(soap, code,
"Action and SOAP action of the message do not match.", NULL);
break;
case SOAP_WSA(MessageAddressingHeaderRequired):
soap_faultdetail(soap);
if (soap->version == 1) {
soap->fault->detail->__type =
SOAP_WSA_(SOAP_TYPE_,ProblemHeaderQName);
soap->fault->detail->fault = (void*) info;
} else {
soap->fault->SOAP_ENV__Detail->__type =
SOAP_WSA_(SOAP_TYPE_,ProblemHeaderQName);
soap->fault->SOAP_ENV__Detail->fault = (void*) info;
}
soap_wsa_sender_fault_subcode(soap, code,
"A required header representing a Message Addressing Property is not present.",
NULL);
break;
case SOAP_WSA(DestinationUnreachable):
soap_faultdetail(soap);
if (soap->version == 1) {
soap->fault->detail->__type = SOAP_WSA_(SOAP_TYPE_,ProblemIRI);
soap->fault->detail->fault = (void*) info;
} else {
soap->fault->SOAP_ENV__Detail->__type =
SOAP_WSA_(SOAP_TYPE_,ProblemIRI);
soap->fault->SOAP_ENV__Detail->fault = (void*) info;
}
soap_wsa_sender_fault_subcode(soap, code,
"No route can be determined to reach [destination]", NULL);
break;
case SOAP_WSA(ActionNotSupported):
soap_faultdetail(soap);
if (soap->version == 1) {
soap->fault->detail->__type = SOAP_WSA_(SOAP_TYPE_,ProblemAction);
soap->fault->detail->fault = (void*) my_soap_malloc(soap,
sizeof(SOAP_WSA_(,ProblemAction)));
SOAP_WSA_(soap_default_, ProblemAction)
(soap, (SOAP_WSA_(,ProblemAction)*)soap->fault->detail->fault);
((SOAP_WSA_(,ProblemAction)*) soap->fault->detail->fault)->Action =
(char*) info;
} else {
soap->fault->SOAP_ENV__Detail->__type =
SOAP_WSA_(SOAP_TYPE_,ProblemAction);
soap->fault->SOAP_ENV__Detail->fault = (void*) my_soap_malloc(soap,
sizeof(SOAP_WSA_(,ProblemAction)));
SOAP_WSA_(soap_default_, ProblemAction)
(soap, (SOAP_WSA_(,ProblemAction)*)soap->fault->SOAP_ENV__Detail->fault);
((SOAP_WSA_(,ProblemAction)*) soap->fault->SOAP_ENV__Detail->fault)->Action =
(char*) info;
}
soap_wsa_sender_fault_subcode(soap, code,
"The [action] cannot be processed at the receiver.", NULL);
break;
case SOAP_WSA(EndpointUnavailable):
soap_faultdetail(soap);
if (soap->version == 1) {
soap->fault->detail->__type = SOAP_WSA_(SOAP_TYPE_,ProblemIRI);
soap->fault->detail->fault = (void*) info;
} else {
soap->fault->SOAP_ENV__Detail->__type =
SOAP_WSA_(SOAP_TYPE_,ProblemIRI);
soap->fault->SOAP_ENV__Detail->fault = (void*) info;
}
soap_wsa_receiver_fault_subcode(soap, code,
"The endpoint is unable to process the message at this time.",
NULL);
break;
default:
break;
}
return SOAP_FAULT;
}
#elif defined(SOAP_WSA_2003)
SOAP_FMAC5 int SOAP_FMAC6 soap_wsa_error(struct soap *soap, const char *fault)
{ return soap_wsa_sender_fault_subcode(soap, NULL, fault, NULL);
}
#else
/**
@fn SOAP_FMAC5 int SOAP_FMAC6 soap_wsa_error(struct soap *soap, SOAP_WSA(FaultSubcodeValues) fault)
@brief Sets SOAP Fault (sub)code for server WS-Addressing fault response.
@param soap context
@param[in] fault is one of wsa:FaultSubcodeValues
@return SOAP_FAULT
*/
SOAP_FMAC5 int SOAP_FMAC6 soap_wsa_error(struct soap *soap, SOAP_WSA(FaultSubcodeValues) fault)
{ const char *code = SOAP_WSA_(soap,FaultSubcodeValues2s)(soap, fault);
/* populate the SOAP Fault as per WS-Addressing spec */
switch (fault)
{ case SOAP_WSA(InvalidMessageInformationHeader):
return soap_wsa_sender_fault_subcode(soap, code, "A message information header is not valid and the message cannot be processed. The validity failure can be either structural or semantic, e.g. a [destination] that is not a URI or a [relationship] to a [message id] that was never issued.", "Invalid header");
case SOAP_WSA(MessageInformationHeaderRequired):
return soap_wsa_sender_fault_subcode(soap, code, "A required message information header, To, MessageID, or Action, is not present.", "Missing Header QName");
case SOAP_WSA(DestinationUnreachable):
return soap_wsa_sender_fault_subcode(soap, code, "No route can be determined to reach the destination role defined by the WS-Addressing To.", NULL);
case SOAP_WSA(ActionNotSupported):
return soap_wsa_sender_fault_subcode(soap, code, "The [action] cannot be processed at the receiver.", soap->action);
case SOAP_WSA(EndpointUnavailable):
return soap_wsa_receiver_fault_subcode(soap, code, "The endpoint is unable to process the message at this time.", NULL);
default:
break;
}
return SOAP_FAULT;
}
#endif
SOAP_FMAC5 int SOAP_FMAC6 soap_wsa_check(struct soap *soap) {
logInfo("soap_wsa_check");
if (!soap->header || !soap->header->SOAP_WSA(Action))
#if defined(SOAP_WSA_2005)
return soap_wsa_error(soap, wsa5__MessageAddressingHeaderRequired, NULL);
#elif defined(SOAP_WSA_2003)
return soap_wsa_error(soap, "WS-Addressing header missing");
#else
return soap_wsa_error(soap, SOAP_WSA(MessageInformationHeaderRequired));
#endif
return SOAP_OK;
}
SOAP_FMAC5 int SOAP_FMAC6 soap_wsa_add_ReplyTo(struct soap *soap,
const char *replyTo) {
if (!soap->header)
return SOAP_ERR;
#ifndef SOAP_WSA_2005
if (!replyTo)
replyTo = soap_wsa_anonymousURI;
#endif
if (replyTo) {
soap->header->SOAP_WSA(ReplyTo) = (SOAP_WSA_(,ReplyTo)*) my_soap_malloc(
soap, sizeof(SOAP_WSA_(,ReplyTo)));
SOAP_WSA_(soap_default,EndpointReferenceType)(soap,
soap->header->SOAP_WSA(ReplyTo));
soap->header->SOAP_WSA(ReplyTo)->Address = soap_strdup(soap, replyTo);
} else
soap->header->SOAP_WSA(ReplyTo) = NULL;
return SOAP_OK;
}
SOAP_FMAC5 int SOAP_FMAC6 soap_wsa_request(struct soap *soap, const char *id,
const char *to, const char *action) {
DBGFUN3("soap_wsa_request", "id=%s", id ? id : "(null)", "to=%s",
to ? to : "(null)", "action=%s", action ? action : "(null)");
if (soap_wsa_alloc_header(soap))
return soap->error;
soap->header->SOAP_WSA(MessageID) = soap_strdup(soap, id);
if (to)
soap->header->SOAP_WSA(To) = soap_strdup(soap, to);
else
/* this is optional */
soap->header->SOAP_WSA(To) = (char*) soap_wsa_anonymousURI;
soap->header->SOAP_WSA(Action) = soap_strdup(soap, action);
soap->header->SOAP_WSA(RelatesTo) = NULL;
soap->header->SOAP_WSA(From) = NULL;
soap->header->SOAP_WSA(FaultTo) = NULL;
soap_wsa_add_ReplyTo(soap, NULL);
return soap_wsa_check(soap);
}
SOAP_FMAC5 int SOAP_FMAC6 soap_wsa_add_RelatesTo(struct soap *soap,
const char *relatesTo) {
if (!soap->header)
return SOAP_ERR;
if (relatesTo) {
soap->header->SOAP_WSA(RelatesTo) =
(SOAP_WSA_(,RelatesTo)*) my_soap_malloc(soap,
sizeof(SOAP_WSA_(,RelatesTo)));
SOAP_WSA_(soap_default_, RelatesTo)
(soap, soap->header->SOAP_WSA(RelatesTo));
soap->header->SOAP_WSA(RelatesTo)->__item = soap_strdup(soap,
relatesTo);
}
return SOAP_OK;
}
SOAP_FMAC5 void SOAP_FMAC6 soap_wsdd_set_AppSequence(struct soap *soap) {
soap_header(soap);
if (!soap->header->wsdd__AppSequence) {
soap->header->wsdd__AppSequence = (wsdd__AppSequenceType*) my_soap_malloc(
soap, sizeof(wsdd__AppSequenceType));
soap_default_wsdd__AppSequenceType(soap,
soap->header->wsdd__AppSequence);
}
MUTEX_LOCK(soap_wsdd_state);
soap->header->wsdd__AppSequence->InstanceId = soap_wsdd_InstanceId;
soap->header->wsdd__AppSequence->SequenceId = (char*) soap_wsdd_SequenceId;
soap->header->wsdd__AppSequence->MessageNumber = soap_wsdd_MessageNumber++;
MUTEX_UNLOCK(soap_wsdd_state);
}
SOAP_FMAC5 int SOAP_FMAC6 soap_wsa_reply(struct soap *soap, const char *id,
const char *action) {
struct soap_wsa_data *data = (struct soap_wsa_data*) soap_lookup_plugin(
soap, soap_wsa_id);
struct SOAP_ENV__Header *oldheader, *newheader;
DBGFUN1("soap_wsa_reply", "action=%s", action ? action : "(null)");
if (!data)
return soap->error = SOAP_PLUGIN_ERROR;
oldheader = soap->header;
soap->header = NULL;
/* if endpoint address for reply is 'none' return immediately */
if (oldheader && oldheader->SOAP_WSA(ReplyTo)
&& oldheader->SOAP_WSA(ReplyTo)->Address
&& !strcmp(oldheader->SOAP_WSA(ReplyTo)->Address, soap_wsa_noneURI))
return soap_send_empty_response(soap, SOAP_OK);
/* allocate a new header */
if (soap_wsa_alloc_header(soap))
return soap->error;
newheader = soap->header;
/* copy members to new header, except WSA data */
if (oldheader)
*newheader = *oldheader;
newheader->SOAP_WSA(MessageID) = soap_strdup(soap, id);
newheader->SOAP_WSA(Action) = soap_strdup(soap, action);
newheader->SOAP_WSA(RelatesTo) = NULL;
newheader->SOAP_WSA(From) = NULL;
newheader->SOAP_WSA(To) = NULL;
newheader->SOAP_WSA(ReplyTo) = NULL;
newheader->SOAP_WSA(FaultTo) = NULL;
/* check current header content */
if (oldheader && oldheader->SOAP_WSA(MessageID)) {
newheader->SOAP_WSA(RelatesTo) = (SOAP_WSA_(,RelatesTo)*) my_soap_malloc(
soap, sizeof(SOAP_WSA_(,RelatesTo)));
SOAP_WSA_(soap_default_, RelatesTo)
(soap, newheader->SOAP_WSA(RelatesTo));
newheader->SOAP_WSA(RelatesTo)->__item = oldheader->SOAP_WSA(MessageID);
}
#ifdef SOAP_WSA_2005
/* WCF Interoperability:
ChannelInstance is required when the WCF Application hosts multiple
Callback Channels within the same application. The
ReferenceParameters->ChannelInstance element serves as a hint to the WCF
Client dispatcher, as to which WCF callback instance a received SOAP
Envelope belongs to ChannelInstance is declared as a pointer, so it is
essentially an optional element. Tests with Applications not requiring
ChannelInstance have also been done for the following fix.
*/
if (oldheader && oldheader->SOAP_WSA(ReplyTo)
&& oldheader->SOAP_WSA(ReplyTo)->ReferenceParameters
&& oldheader->SOAP_WSA(ReplyTo)->ReferenceParameters->chan__ChannelInstance) {
if (newheader) {
if (!newheader->chan__ChannelInstance) {
newheader->chan__ChannelInstance =
(struct chan__ChannelInstanceType*) my_soap_malloc(soap,
sizeof(struct chan__ChannelInstanceType));
if (newheader->chan__ChannelInstance) {
soap_default_chan__ChannelInstanceType(soap,
newheader->chan__ChannelInstance);
newheader->chan__ChannelInstance->__item =
*(oldheader->SOAP_WSA(ReplyTo)->ReferenceParameters->chan__ChannelInstance);
newheader->chan__ChannelInstance->wsa5__IsReferenceParameter =
_wsa5__IsReferenceParameter__true;
}
} else {
newheader->chan__ChannelInstance->__item =
*(oldheader->SOAP_WSA(ReplyTo)->ReferenceParameters->chan__ChannelInstance);
newheader->chan__ChannelInstance->wsa5__IsReferenceParameter =
_wsa5__IsReferenceParameter__true;
}
}
}
#endif
if (oldheader && oldheader->SOAP_WSA(ReplyTo)
&& oldheader->SOAP_WSA(ReplyTo)->Address
&& !soap_tagsearch(soap_wsa_allAnonymousURI,
oldheader->SOAP_WSA(ReplyTo)->Address)) {
newheader->SOAP_WSA(To) = oldheader->SOAP_WSA(ReplyTo)->Address;
/* (re)connect to ReplyTo endpoint if From != ReplyTo */
if (!oldheader->SOAP_WSA(From) || !oldheader->SOAP_WSA(From)->Address
|| strcmp(oldheader->SOAP_WSA(From)->Address,
oldheader->SOAP_WSA(ReplyTo)->Address)) {
struct soap *reply_soap = soap_copy(soap);
if (reply_soap) {
soap_copy_stream(reply_soap, soap);
soap_free_stream(soap); /* prevents close in soap_connect() below */
if (soap_connect(soap, newheader->SOAP_WSA(To),
newheader->SOAP_WSA(Action))) {
int err;
soap_copy_stream(soap, reply_soap);
soap_free_stream(reply_soap);
soap_end(reply_soap);
soap_free(reply_soap);
soap->header = oldheader;
#if defined(SOAP_WSA_2005)
err = soap_wsa_error(soap, SOAP_WSA(DestinationUnreachable),
newheader->SOAP_WSA(To));
#elif defined(SOAP_WSA_2003)
err = soap_wsa_error(soap, "WS-Addessing destination unreachable");
#else
err = soap_wsa_error(soap, SOAP_WSA(DestinationUnreachable));
#endif
soap->header = NULL;
return err;
}
if (soap_valid_socket(reply_soap->socket))
soap_send_empty_response(reply_soap, SOAP_OK); /* HTTP ACCEPTED */
soap->header = newheader;
soap_end(reply_soap);
soap_free(reply_soap);
data->fresponse = soap->fresponse;
soap->fresponse = soap_wsa_response; /* response will be a POST */
}
}
} else if (oldheader && oldheader->SOAP_WSA(From))
newheader->SOAP_WSA(To) = oldheader->SOAP_WSA(From)->Address;
else
newheader->SOAP_WSA(To) = (char*) soap_wsa_anonymousURI;
soap->header = newheader;
soap->action = newheader->SOAP_WSA(Action);
return SOAP_OK;
}
SOAP_FMAC5 int SOAP_FMAC6 soap_send___wsdd__ProbeMatches(struct soap *soap,
const char *soap_endpoint, const char *soap_action,
struct wsdd__ProbeMatchesType *wsdd__ProbeMatches) {
struct __wsdd__ProbeMatches soap_tmp___wsdd__ProbeMatches;
if (!soap_action)
soap_action =
"http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ProbeMatches";
soap->encodingStyle = NULL;
soap_tmp___wsdd__ProbeMatches.wsdd__ProbeMatches = wsdd__ProbeMatches;
soap_begin(soap);
soap_serializeheader(soap);
soap_serialize___wsdd__ProbeMatches(soap, &soap_tmp___wsdd__ProbeMatches);
if (soap_begin_count(soap))
return soap->error;
if (soap->mode & SOAP_IO_LENGTH) {
if (soap_envelope_begin_out(soap) || soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put___wsdd__ProbeMatches(soap,
&soap_tmp___wsdd__ProbeMatches, "-wsdd:ProbeMatches",
NULL) || soap_body_end_out(soap)
|| soap_envelope_end_out(soap))
return soap->error;
}
if (soap_end_count(soap))
return soap->error;
if (soap_connect(soap, soap_endpoint, soap_action)
|| soap_envelope_begin_out(soap) || soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put___wsdd__ProbeMatches(soap,
&soap_tmp___wsdd__ProbeMatches, "-wsdd:ProbeMatches", NULL)
|| soap_body_end_out(soap) || soap_envelope_end_out(soap)
|| soap_end_send(soap))
return soap_closesock(soap);
return SOAP_OK;
}
void getWSA__EndpointReferenceInfo(struct soap* soap, wsa__EndpointReferenceType* info) {
info->ReferenceProperties =
(struct wsa__ReferencePropertiesType*) my_soap_malloc(soap,
sizeof(struct wsa__ReferencePropertiesType));
info->ReferenceProperties->__size = 0;
info->ReferenceProperties->__any = NULL;
info->ReferenceParameters = (struct wsa__ReferenceParametersType*) my_soap_malloc(soap,
sizeof(struct wsa__ReferenceParametersType));
info->ReferenceParameters->__size = 0;
info->ReferenceParameters->__any = NULL;
info->PortType = (char **) my_soap_malloc(soap, sizeof(char*) * SMALL_INFO_LENGTH);
info->PortType[0] = soap_strdup(soap, "ttl");
info->ServiceName = (struct wsa__ServiceNameType*) my_soap_malloc(soap,
sizeof(struct wsa__ServiceNameType));
info->ServiceName->__item = NULL;
info->ServiceName->PortName = NULL;
info->ServiceName->__anyAttribute = NULL;
//ws-discovery鹿忙露篓 脦陋驴脡脩隆脧卯 , __any
info->__any = (char **) my_soap_malloc(soap, sizeof(char*) * SMALL_INFO_LENGTH);
info->__any[0] = soap_strdup(soap, "Any");
//ws-discovery鹿忙露篓 脦陋驴脡脩隆脧卯 , __anyAttribute
info->__anyAttribute = soap_strdup(soap, "Attribute");
info->__size = 0;
//ws-discovery鹿忙露篓 脦陋驴脡脩隆脧卯 , Address
info->Address =soap_strdup(soap, onvifRunParam.urnHardwareId);
}
void getProbeMatchesInfo(struct soap* soap, wsdd__ProbeMatchesType* info, int size, char* xaddr) {
info->__sizeProbeMatch = size;
info->ProbeMatch = (struct wsdd__ProbeMatchType *) my_soap_malloc(soap,
sizeof(struct wsdd__ProbeMatchType) * size);
int i = 0;
for (i = 0; i < size; i++) {
info->ProbeMatch[i].MetadataVersion = METADATA_VERSION;
// should be onvif device mgmt address
info->ProbeMatch[i].XAddrs = soap_strdup(soap, xaddr);
// probe type
info->ProbeMatch[i].Types = soap_strdup(soap, DEVICE_TYPE);
// Scope
info->ProbeMatch[i].Scopes =
(struct wsdd__ScopesType*) my_soap_malloc(soap,
sizeof(struct wsdd__ScopesType));
info->ProbeMatch[i].Scopes->__item = soap_strdup(soap, ONVIF_SCOPE_NAME);
info->ProbeMatch[i].Scopes->MatchBy = NULL;
getWSA__EndpointReferenceInfo(soap, &(info->ProbeMatch[i].wsa__EndpointReference));
}
}
SOAP_FMAC5 int SOAP_FMAC6 __wsdd__Probe(struct soap* soap,
struct wsdd__ProbeType *wsdd__Probe) {
logInfo("__wsdd__Probe %s", onvifRunParam.ip);
char _serviceURL[256] = { 0 };
if (RET_CODE_SUCCESS != getServiceURL(_serviceURL, onvifRunParam.ip, onvifRunParam.servicePort)) {
return getOnvifSoapActionFailedCode(soap, "__wsdd__Probe",
"getServiceURL failed");
}
logInfo("service url %s", _serviceURL);
wsdd__ProbeMatchesType wProbeMatches;
getProbeMatchesInfo(soap, &wProbeMatches, INTERFACE_NUM, _serviceURL);
if (soap->header == NULL) {
soap->header = (struct SOAP_ENV__Header*) my_soap_malloc(soap,
sizeof(struct SOAP_ENV__Header));
soap->header->wsa__RelatesTo = (struct wsa__Relationship*) my_soap_malloc(
soap, sizeof(struct wsa__Relationship));
//it's here
soap->header->wsa__MessageID = soap_strdup(soap, getUUId());
soap->header->wsa__RelatesTo->__item = soap->header->wsa__MessageID;
soap->header->wsa__RelatesTo->RelationshipType = NULL;
soap->header->wsa__RelatesTo->__anyAttribute = NULL;
} else {
soap->header->wsa__RelatesTo = (struct wsa__Relationship*) my_soap_malloc(
soap, sizeof(struct wsa__Relationship));
//it's here
soap->header->wsa__RelatesTo->__item = soap->header->wsa__MessageID;
soap->header->wsa__RelatesTo->RelationshipType = NULL;
soap->header->wsa__RelatesTo->__anyAttribute = NULL;
soap->header->wsa__MessageID = soap_strdup(soap, getUUId());
}
soap->header->wsa__From = 0;
soap->header->wsa__ReplyTo = 0;
soap->header->wsa__FaultTo = 0;
soap->header->wsdd__AppSequence = 0;
/*注释的部分为可选,注释掉onvif test也能发现ws-d*/
soap->header->wsa__To = soap_strdup(soap, "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous");
soap->header->wsa__Action = soap_strdup(soap, "http://schemas.xmlsoap.org/ws/2005/04/discovery/ProbeMatches");
/* send over current socket as HTTP OK response: */
/*测试过,第二参数必须http,action随意*/
soap_send___wsdd__ProbeMatches(soap, "http://", NULL, &wProbeMatches);
logInfo("__wsdd__Probe end");
return SOAP_OK;
}
SOAP_FMAC5 int SOAP_FMAC6 __dn__Probe(struct soap* soap,
struct wsdd__ProbeType dn__Probe,
struct wsdd__ProbeMatchesType* dn__ProbeResponse) {
logInfo("__dn__Probe");
char _serviceURL[256] = { 0 };
if (RET_CODE_SUCCESS != getServiceURL(_serviceURL, onvifRunParam.ip, onvifRunParam.servicePort)) {
return getOnvifSoapActionFailedCode(soap, "__tdn__Probe",
"getServiceURL failed");
}
logInfo("service url %s", _serviceURL);
getProbeMatchesInfo(soap, dn__ProbeResponse, INTERFACE_NUM, _serviceURL);
return SOAP_OK;
}
SOAP_FMAC5 int SOAP_FMAC6 soap_send___wsdd__Hello(struct soap *soap,
const char *soap_endpoint, const char *soap_action,
struct wsdd__HelloType *wsdd__Hello) {
struct __wsdd__Hello soap_tmp___wsdd__Hello;
if (!soap_action)
soap_action =
"http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/Hello";
soap->encodingStyle = NULL;
soap_tmp___wsdd__Hello.wsdd__Hello = wsdd__Hello;
soap_begin(soap);
soap_serializeheader(soap);
soap_serialize___wsdd__Hello(soap, &soap_tmp___wsdd__Hello);
if (soap_begin_count(soap))
return soap->error;
if (soap->mode & SOAP_IO_LENGTH) {
if (soap_envelope_begin_out(soap) || soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put___wsdd__Hello(soap, &soap_tmp___wsdd__Hello,
"-wsdd:Hello", NULL) || soap_body_end_out(soap)
|| soap_envelope_end_out(soap))
return soap->error;
}
if (soap_end_count(soap))
return soap->error;
if (soap_connect(soap, soap_endpoint, soap_action)) {
return soap_closesock(soap);
}
soap_set_endpoint(soap, soap_endpoint);
soap->error = SOAP_OK;
struct sockaddr_in peer;
peer.sin_family = AF_INET;
peer.sin_port = htons(soap->port);
peer.sin_addr.s_addr = inet_addr(soap->host);
memcpy(&soap->peer, &peer, sizeof(struct sockaddr_in));
soap->peerlen = sizeof(peer);
if (soap_envelope_begin_out(soap) || soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put___wsdd__Hello(soap, &soap_tmp___wsdd__Hello,
"-wsdd:Hello", NULL) || soap_body_end_out(soap)
|| soap_envelope_end_out(soap) || soap_end_send(soap))
return soap_closesock(soap);
return SOAP_OK;
}
int soap_wsdd_Hello(struct soap *soap, soap_wsdd_mode mode,
const char *endpoint, const char *MessageID, const char *RelatesTo,
const char *EndpointReference, const char *Types, const char *Scopes,
const char *MatchBy, const char *XAddrs, unsigned int MetadataVersion) {
struct wsdd__HelloType req;
struct wsdd__ScopesType scopes;
const char *Action =
"http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/Hello";
const char *To = endpoint;
/* SOAP Header */
if (mode == SOAP_WSDD_ADHOC)
To = to_ts_URL;
soap_wsa_request(soap, MessageID, To, Action);
soap_wsa_add_RelatesTo(soap, RelatesTo);
#ifdef SOAP_WSA_2005
soap_wsdd_set_AppSequence(soap);
#else
if (mode == SOAP_WSDD_ADHOC)
soap_wsdd_set_AppSequence(soap);
else
soap_wsdd_reset_AppSequence(soap);
#endif
/* Hello */
soap_default_wsdd__HelloType(soap, &req);
#ifdef SOAP_WSA_2005
req.wsa__EndpointReference.Address = (char*) EndpointReference;
#else
req.wsa__EndpointReference.Address = (char*)EndpointReference;
#endif
req.Types = (char*) Types;
if (Scopes) {
soap_default_wsdd__ScopesType(soap, &scopes);
scopes.__item = (char*) Scopes;
scopes.MatchBy = (char*) MatchBy;
req.Scopes = &scopes;
}
req.XAddrs = (char*) XAddrs;
req.MetadataVersion = MetadataVersion;
if (soap_send___wsdd__Hello(soap, endpoint, Action, &req))
return soap->error;
/* HTTP(S) POST expects an HTTP OK response */
if (endpoint && !strncmp(endpoint, "http", 4))
return soap_recv_empty_response(soap);
return SOAP_OK;
}
void wsdd_event_Hello(struct soap *soap, unsigned int InstanceId,
const char *SequenceId, unsigned int MessageNumber,
const char *MessageID, const char *RelatesTo,
const char *EndpointReference, const char *Types, const char *Scopes,
const char *MatchBy, const char *XAddrs, unsigned int MetadataVersion) {
}
SOAP_FMAC5 int SOAP_FMAC6 __wsdd__Hello(struct soap* soap,
struct wsdd__HelloType *wsdd__Hello) {
unsigned int InstanceId = 0;
const char *SequenceId = NULL;
unsigned int MessageNumber = 0;
logInfo("__wsdd__Hello");
/* check for WSA */
if (soap_wsa_check(soap))
return soap->error;
/* check WSDD */
if (!wsdd__Hello
#ifdef SOAP_WSA_2005
|| !wsdd__Hello->wsa__EndpointReference.Address
#else
|| !wsdd__Hello->wsa__EndpointReference.Address
#endif
)
return soap_wsa_sender_fault(soap, "WSDD Hello incomplete", NULL);
#ifdef SOAP_WSA_2005
DBGLOG(TEST, SOAP_MESSAGE(fdebug, "EndpointReference=%s\n", wsdd__Hello->wsa__EndpointReference.Address));
#else
DBGLOG(TEST, SOAP_MESSAGE(fdebug, "EndpointReference=%s\n", wsdd__Hello->wsa__EndpointReference.Address));
#endif
if (soap->header->wsdd__AppSequence) {
wsdd__AppSequenceType *seq = soap->header->wsdd__AppSequence;
InstanceId = seq->InstanceId;
SequenceId = seq->SequenceId;
MessageNumber = seq->MessageNumber;
DBGLOG(TEST, SOAP_MESSAGE(fdebug, "AppSeq id=%u seq=%s msg=%u\n", InstanceId, SequenceId ? SequenceId : "(null)", MessageNumber));
}
/* pass on to user-defined event handler */
wsdd_event_Hello(soap, InstanceId, SequenceId, MessageNumber,
soap->header->SOAP_WSA(MessageID),
soap->header->SOAP_WSA(RelatesTo) ?
soap->header->SOAP_WSA(RelatesTo)->__item : NULL,
wsdd__Hello->wsa__EndpointReference.Address, wsdd__Hello->Types,
wsdd__Hello->Scopes ? wsdd__Hello->Scopes->__item : NULL,
wsdd__Hello->Scopes ? wsdd__Hello->Scopes->MatchBy : NULL,
wsdd__Hello->XAddrs, wsdd__Hello->MetadataVersion);
/* one-way HTTP(S) POST message requires an HTTP OK response message */
if (!strncmp(soap->endpoint, "http", 4))
return soap_send_empty_response(soap, SOAP_OK);
return SOAP_OK;
}
SOAP_FMAC5 int SOAP_FMAC6 __dn__Hello(struct soap* soap,
struct wsdd__HelloType dn__Hello,
struct wsdd__ResolveType* dn__HelloResponse) {
logInfo("__dn__Hello");
getWSA__EndpointReferenceInfo(soap, &dn__HelloResponse->wsa__EndpointReference);
return SOAP_OK;
}
SOAP_FMAC5 int SOAP_FMAC6 soap_send___wsdd__Bye(struct soap *soap,
const char *soap_endpoint, const char *soap_action,
struct wsdd__ByeType *wsdd__Bye) {
struct __wsdd__Bye soap_tmp___wsdd__Bye;
if (soap_action == NULL)
soap_action =
"http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/Bye";
soap->encodingStyle = NULL;
soap_tmp___wsdd__Bye.wsdd__Bye = wsdd__Bye;
soap_begin(soap);
soap_serializeheader(soap);
soap_serialize___wsdd__Bye(soap, &soap_tmp___wsdd__Bye);
if (soap_begin_count(soap))
return soap->error;
if (soap->mode & SOAP_IO_LENGTH) {
if (soap_envelope_begin_out(soap) || soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put___wsdd__Bye(soap, &soap_tmp___wsdd__Bye,
"-wsdd:Bye", NULL) || soap_body_end_out(soap)
|| soap_envelope_end_out(soap))
return soap->error;
}
if (soap_end_count(soap))
return soap->error;
if (soap_connect(soap, soap_endpoint, soap_action)
|| soap_envelope_begin_out(soap) || soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put___wsdd__Bye(soap, &soap_tmp___wsdd__Bye, "-wsdd:Bye",
NULL) || soap_body_end_out(soap)
|| soap_envelope_end_out(soap) || soap_end_send(soap))
return soap_closesock(soap);
return SOAP_OK;
}
int soap_wsdd_Bye(struct soap *soap, soap_wsdd_mode mode, const char *endpoint,
const char *MessageID, const char *EndpointReference, const char *Types,
const char *Scopes, const char *MatchBy, const char *XAddrs,
unsigned int MetadataVersion) {
struct wsdd__ByeType req;
struct wsdd__ScopesType scopes;
const char *Action =
"http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/Bye";
const char *To = endpoint;
/* SOAP Header */
if (mode == SOAP_WSDD_ADHOC)
To = to_ts_URL;
soap_wsa_request(soap, MessageID, To, Action);
#ifdef SOAP_WSA_2005
soap_wsdd_set_AppSequence(soap);
#else
if (mode == SOAP_WSDD_ADHOC)
soap_wsdd_set_AppSequence(soap);
else
soap_wsdd_reset_AppSequence(soap);
#endif
/* Bye */
soap_default_wsdd__ByeType(soap, &req);
#ifdef SOAP_WSA_2005
req.wsa__EndpointReference.Address = (char*) EndpointReference;