int Redirect_Pull_EP(WsContextH cntx, WsEnumerateInfo* enumInfo, WsmanStatus *status, void *opaqueData) { WsXmlDocH doc=NULL,response=NULL; WsManClient *cl=NULL; int retVal=0; cl = setup_redirect_client( cntx, enumInfo->auth_data.username, enumInfo->auth_data.password); wsman_send_request(cl,cntx->indoc); if (wsmc_get_last_error(cl) != WS_LASTERR_OK ){ //CURL or HTTP errors enumInfo->pullResultPtr = NULL; status->fault_code = WSMAN_INTERNAL_ERROR; status->fault_detail_code = 0; status->fault_msg = redirect_fault_msg( wsman_transport_get_last_error_string( wsmc_get_last_error(cl) ) ); return 1; } response = ws_xml_duplicate_doc(wsmc_build_envelope_from_response(cl)); if ( ! wsman_is_fault_envelope(response) ) enumInfo->pullResultPtr = response; else{ //If there a fault, return the status code. enumInfo->pullResultPtr = NULL; wsman_get_fault_status_from_doc (response, status); retVal=1; } wsmc_release(cl); return retVal; }
int Redirect_Release_EP(WsContextH cntx, WsEnumerateInfo* enumInfo, WsmanStatus *status, void *opaqueData) { WsManClient *cl=NULL; WsXmlDocH response=NULL; cl = setup_redirect_client(cntx, enumInfo->auth_data.username, enumInfo->auth_data.password); wsman_send_request(cl,cntx->indoc); if (wsmc_get_last_error(cl) != WS_LASTERR_OK ){ //just return for now, as the release_stub is not handling the status codes. return 1; } response=wsmc_build_envelope_from_response(cl); //The status value is not used in the release stub. So, just return, if fault or not. return wsman_is_fault_envelope(response); }
int Redirect_Enumerate_EP(WsContextH cntx, WsEnumerateInfo* enumInfo, WsmanStatus *status, void *opaqueData) { WsXmlNodeH r_header=NULL, r_node=NULL, r_body=NULL, r_opt=NULL; WsXmlDocH r_response=NULL; char *resource_uri, *remote_enumContext; int op; WsManClient *cl=NULL; //The redirected Enumeration request must have RequestTotalItemsCountEstimate enabled r_header = ws_xml_get_soap_header(cntx->indoc); if ( (r_node = ws_xml_get_child(r_header,0,XML_NS_WS_MAN, WSM_REQUEST_TOTAL )) == NULL ) ws_xml_add_child(r_header, XML_NS_WS_MAN, WSM_REQUEST_TOTAL, NULL); cl = setup_redirect_client(cntx, enumInfo->auth_data.username, enumInfo->auth_data.password); //Set the enumInfo flags based on the indoc. This is required while handling the response in wsenum_eunmerate_stub r_body=ws_xml_get_soap_body(cntx->indoc); if ( ( r_node = ws_xml_get_child(r_body ,0, XML_NS_ENUMERATION, WSENUM_ENUMERATE )) != NULL ) { if ( (r_opt = ws_xml_get_child(r_node,0,XML_NS_WS_MAN,WSM_OPTIMIZE_ENUM )) != NULL ) enumInfo->flags |= WSMAN_ENUMINFO_OPT ; } wsman_send_request(cl,cntx->indoc); if (wsmc_get_last_error(cl) != WS_LASTERR_OK ){ //CURL or HTTP errors enumInfo->pullResultPtr = NULL; status->fault_code = WSMAN_INTERNAL_ERROR; status->fault_detail_code = 0; status->fault_msg = redirect_fault_msg( wsman_transport_get_last_error_string( wsmc_get_last_error(cl) ) ); return 1; } r_response = ws_xml_duplicate_doc(wsmc_build_envelope_from_response(cl)); if ( wsman_is_fault_envelope(r_response)){ enumInfo->pullResultPtr = NULL; wsman_get_fault_status_from_doc(r_response, status); return 1; } //Get the Estimated Total No.of Items from the response. r_header=ws_xml_get_soap_header(r_response); r_node=ws_xml_get_child(r_header,0,XML_NS_WS_MAN, WSM_TOTAL_ESTIMATE ); enumInfo->totalItems=(!r_node) ? 0: atoi(ws_xml_get_node_text(r_node)); //Get the remote context remote_enumContext = wsmc_get_enum_context(r_response); //Set the pullResultPtr only if some Enum Items are returned, in optimized mode. r_body= ws_xml_get_soap_body(r_response); if ( (r_node = ws_xml_get_child(r_body,0,XML_NS_ENUMERATION, WSENUM_ENUMERATE_RESP )) != NULL && ( ws_xml_get_child(r_node,0,XML_NS_WS_MAN,WSENUM_ITEMS) != NULL) ) { enumInfo->pullResultPtr = r_response; if( strlen(remote_enumContext) != 0 ) strncpy(enumInfo->enumId, remote_enumContext, strlen(remote_enumContext)+1); else // If all the instances are returned, the context will be NULL enumInfo->enumId[0]='\0'; } else{ //If not items are returned, set the context and return. strncpy(enumInfo->enumId, remote_enumContext, strlen(remote_enumContext)+1); ws_xml_destroy_doc(r_response); } wsmc_release(cl); return 0; }
static int process_inbound_operation(op_t * op, WsmanMessage * msg, void *opaqueData) { int retVal = 1; char *buf = NULL; int len; msg->http_code = WSMAN_STATUS_OK; op->out_doc = NULL; if (op->dispatch->serviceCallback == NULL) { wsman_set_fault(msg, WSA_ACTION_NOT_SUPPORTED, OWSMAN_NO_DETAILS, NULL); debug("op service callback is null"); goto GENERATE_FAULT; } if (process_filters(op, 1, opaqueData)) { if (op->out_doc == NULL) { error("doc is null"); wsman_set_fault(msg, WSMAN_INTERNAL_ERROR, OWSMAN_NO_DETAILS, NULL); goto GENERATE_FAULT; } if (wsman_is_fault_envelope(op->out_doc)) { msg->http_code = wsman_find_httpcode_for_value(op->out_doc); } else { error("not fault envelope"); } ws_xml_dump_memory_enc(op->out_doc, &buf, &len, msg->charset); u_buf_set(msg->response, buf, len); ws_xml_destroy_doc(op->out_doc); op->out_doc = NULL; u_free(buf); return 1; } retVal = op->dispatch->serviceCallback((SoapOpH) op, op->dispatch->serviceData, opaqueData); if (op->out_doc == NULL) { // XXX (correct fault?) wsman_set_fault(msg, WSA_DESTINATION_UNREACHABLE, WSMAN_DETAIL_INVALID_RESOURCEURI, NULL); error("output doc is null"); goto GENERATE_FAULT; } process_filters(op, 0, opaqueData); if (op->out_doc == NULL) { error("doc is null"); wsman_set_fault(msg, WSMAN_INTERNAL_ERROR, OWSMAN_NO_DETAILS, NULL); goto GENERATE_FAULT; } if (wsman_is_fault_envelope(op->out_doc)) { msg->http_code = wsman_find_httpcode_for_value(op->out_doc); } else { wsman_add_fragement_for_header(op->in_doc, op->out_doc); } ws_xml_dump_memory_enc(op->out_doc, &buf, &len, msg->charset); u_buf_set(msg->response, buf, len); ws_xml_destroy_doc(op->out_doc); op->out_doc = NULL; u_free(buf); return 0; GENERATE_FAULT: return retVal; }