int ns__wsademoResult(struct soap *soap, char *out) { if (soap_wsa_check(soap)) return soap_send_empty_response(soap, 500); /* HTTP 500 error */ printf("Received Result = %s\n", out?out:""); return soap_send_empty_response(soap, SOAP_OK); /* HTTP 202 */ }
int Service::DivideBy(_mssadh__DivideBy *req) { /* check for WS-RM/WSA */ if (soap_wsrm_check(soap)) return soap->error; if (req && req->n) { result /= *req->n; equation << " / " << *req->n; } else return soap_wsrm_sender_fault(soap, "Invalid data in DivideBy", NULL); /* this is a one-way operation over HTTP, so we're done with client */ soap_send_empty_response(soap, 202); /* get the handle to the current sequence of the inbound message */ soap_wsrm_sequence_handle seq = soap_wsrm_seq(soap); /* TODO: send acknowledgement(s) immediately? */ /* soap_wsrm_acknowledgement(soap, seq, NULL); */ if (soap_wsrm_request_acks(callback.soap, seq, soap_wsa_rand_uuid(callback.soap), "http://Microsoft.Samples.DualHttp/ICalculatorDuplex/Result")) { callback.soap_stream_fault(std::cerr); soap_wsrm_seq_release(soap, seq); return callback.soap->error; } callback.soap_endpoint = soap_wsrm_to(seq); soap_wsrm_seq_release(soap, seq); if (callback.soap_endpoint) { _mssadh__Result res; res.result = &result; if (callback.send_Result(&res) == SOAP_OK) std::cout << "Result(" << result << ")" << std::endl; else callback.soap_stream_fault(std::cerr); } callback.destroy(); return SOAP_OK; }
int SOAP_ENV__Fault(struct soap *soap, char *faultcode, char *faultstring, char *faultactor, struct SOAP_ENV__Detail *detail, struct SOAP_ENV__Code *SOAP_ENV__Code, struct SOAP_ENV__Reason *SOAP_ENV__Reason, char *SOAP_ENV__Node, char *SOAP_ENV__Role, struct SOAP_ENV__Detail *SOAP_ENV__Detail) { printf("Received Fault:\n"); /* populate the fault struct from the operation arguments to print it */ soap_fault(soap); /* SOAP 1.1 */ soap->fault->faultcode = faultcode; soap->fault->faultstring = faultstring; soap->fault->faultactor = faultactor; soap->fault->detail = detail; /* SOAP 1.2 */ soap->fault->SOAP_ENV__Code = SOAP_ENV__Code; soap->fault->SOAP_ENV__Reason = SOAP_ENV__Reason; soap->fault->SOAP_ENV__Node = SOAP_ENV__Node; soap->fault->SOAP_ENV__Role = SOAP_ENV__Role; soap->fault->SOAP_ENV__Detail = SOAP_ENV__Detail; /* set error */ soap->error = SOAP_FAULT; soap_print_fault(soap, stdout); return soap_send_empty_response(soap, SOAP_OK); /* HTTP 202 Accepted */ }
int SOAP_ENV__Fault(struct soap *soap, _QName faultcode, // SOAP 1.1 char *faultstring, // SOAP 1.1 char *faultactor, // SOAP 1.1 struct SOAP_ENV__Detail *detail, // SOAP 1.1 struct SOAP_ENV__Code *Code, // SOAP 1.2 struct SOAP_ENV__Reason *Reason, // SOAP 1.2 char *Node, // SOAP 1.2 char *Role, // SOAP 1.2 struct SOAP_ENV__Detail *Detail // SOAP 1.2 ) { soap_send_empty_response(soap, 202); printf("\n**** Fault Received ****\n"); if (faultstring) printf("reason: %s\n", faultstring); else if (Reason && Reason->SOAP_ENV__Text) printf("reason: %s\n", Reason->SOAP_ENV__Text); if (!detail) detail = Detail; if (detail && detail->__type == SOAP_TYPE__wsrm__Identifier) { /* the sequence id is in the Fault Detail __type and fault members */ char *id = (char*)detail->fault; printf("id: %s\n", id); /* we opt to treat all faults fatal, so let's terminate the sequence */ soap_wsrm_sequence_handle seq = soap_wsrm_seq_lookup_id(soap, id); if (seq) { soap_wsrm_error(soap, seq, wsrm__SequenceTerminated); soap_wsrm_seq_release(soap, seq); return soap->error; } } return SOAP_OK; }