void UserGetProfiles(struct soap *soap, struct _tds__GetCapabilitiesResponse *capa_resp) { struct _trt__GetProfiles trt__GetProfiles; struct _trt__GetProfilesResponse trt__GetProfilesResponse; int result= SOAP_OK ; printf("\n-------------------Getting Onvif Devices Profiles--------------\n\n"); soap_wsse_add_UsernameTokenDigest(soap,"user", ONVIF_USER, ONVIF_PASSWORD); result = soap_call___trt__GetProfiles(soap, capa_resp->Capabilities->Media->XAddr, NULL, &trt__GetProfiles, &trt__GetProfilesResponse); if (result==-1) //NOTE: it may be regular if result isn't SOAP_OK.Because some attributes aren't supported by server. { printf("soap error: %d, %s, %s\n", soap->error, *soap_faultcode(soap), *soap_faultstring(soap)); result = soap->error; exit(-1); } else{ printf("\n-------------------Profiles Get OK--------------\n\n"); if(trt__GetProfilesResponse.Profiles!=NULL) { int profile_cnt = trt__GetProfilesResponse.__sizeProfiles; printf("the number of profiles are: %d\n", profile_cnt); if(trt__GetProfilesResponse.Profiles->Name!=NULL) printf("Profiles Name:%s \n",trt__GetProfilesResponse.Profiles->Name); if(trt__GetProfilesResponse.Profiles->token!=NULL) printf("Profiles Taken:%s\n",trt__GetProfilesResponse.Profiles->token); UserGetUri(soap, &trt__GetProfilesResponse, capa_resp); } else printf("Profiles Get inner Error\n"); } printf("Profiles Get Procedure over\n"); }
SOAP_FMAC1 void SOAP_FMAC2 soap_print_fault(struct soap *soap, std::ostream& msg) { if (soap->error) { if (!*soap_faultcode(soap)) soap_set_fault(soap); if (!*soap_faultstring(soap)) *soap_faultstring(soap) = ""; msg << "SOAP FAULT: " << *soap_faultcode(soap) << std::endl << "\"" << *soap_faultstring(soap) << "\"" << std::endl; if (*soap_faultdetail(soap)) msg << "Detail: " << *soap_faultdetail(soap) << std::endl; } }
static void _fault_to_error(glite_delegation_ctx *ctx, const char *method) { const char **code, **string, **detail; struct soap *soap = ctx->soap; soap_set_fault(soap); if (soap->fault) { /* Look for a SOAP 1.1 fault */ if (soap->fault->detail) decode_exception(ctx, soap->fault->detail, method); /* Look for a SOAP 1.2 fault */ if (soap->fault->SOAP_ENV__Detail) decode_exception(ctx, soap->fault->SOAP_ENV__Detail, method); } /* If we did not manage to decode the exception, try generic error * decoding */ if (!ctx->error) { code = soap_faultcode(soap); string = soap_faultstring(soap); detail = soap_faultdetail(soap); /* If the SOAP 1.1 detail is empty, try the SOAP 1.2 detail */ if (!detail && soap->fault && soap->fault->SOAP_ENV__Detail) detail = (const char **)&soap->fault->SOAP_ENV__Detail->__any; /* Provide default messages */ if (!code || !*code) { code = alloca(sizeof(*code)); *code = "(SOAP fault code missing)"; } if (!string || !*string) { string = alloca(sizeof(*string)); *string = "(SOAP fault string missing)"; } if (detail && *detail) glite_delegation_set_error(ctx, "%s: SOAP fault: %s - %s (%s)", method, *code, *string, *detail); else glite_delegation_set_error(ctx, "%s: SOAP fault: %s - %s", method, *code, *string); } soap_end(soap); }
static int my_soap_set_error(struct soap *soap, const char *faultcode, const char *faultsubcodeQName, const char *faultstring, const char *faultdetailXML, int soaperror) { *soap_faultcode(soap) = faultcode; if (faultsubcodeQName) *soap_faultsubcode(soap) = faultsubcodeQName; *soap_faultstring(soap) = faultstring; if (faultdetailXML && *faultdetailXML) { register const char **s = soap_faultdetail(soap); if (s) *s = faultdetailXML; } return soap->error = soaperror; }
/* * This method is used to print the SOAP fault to a string */ void soap_sprint_fault(struct soap *soap, char *fd) { if (soap->error) { const char *c, *v = NULL, *s, **d; d = soap_faultcode(soap); if (!*d) soap_set_fault(soap); c = *d; if (soap->version == 2) v = *soap_faultsubcode(soap); s = *soap_faultstring(soap); d = soap_faultdetail(soap); sprintf(fd, "%s%d fault: %s [%s]\n\"%s\"\nDetail: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, c, v ? v : "no subcode", s ? s : "[no reason]", d && *d ? *d : "[no detail]"); } }
void Request::Execute() { try { this->setEndpoint(); this->setHeader(); try { this->getRequest(); } catch (soap* soap) { if (soap_check_state(soap)) std::clog << "Error: soap struct state not initialized\n"; else if (soap->error) { const char *c, *v = NULL, *s, **d; d = soap_faultcode(soap); if (!*d) soap_set_fault(soap); c = *d; if (soap->version == 2) v = *soap_faultsubcode(soap); s = *soap_faultstring(soap); d = soap_faultdetail(soap); std::clog << (soap->version ? "SOAP 1." : "Error ") << (soap->version ? (int) soap->version : soap->error) << " fault: " << c << "[" << (v ? v : "no subcode") << "]" << std::endl << "\"" << (s ? s : "[no reason]") << "\"" << std::endl << "Detail: " << (d && *d ? *d : "[no detail]") << std::endl; ; } } } catch (int a) { if (a == 100) std::clog << "ERRORE: endpoint non trovato" << std::endl; } }
void UserGetUri(struct soap *soap, struct _trt__GetProfilesResponse *trt__GetProfilesResponse,struct _tds__GetCapabilitiesResponse *capa_resp) { struct _trt__GetStreamUri *trt__GetStreamUri = (struct _trt__GetStreamUri *)malloc(sizeof(struct _trt__GetStreamUri)); struct _trt__GetStreamUriResponse *trt__GetStreamUriResponse = (struct _trt__GetStreamUriResponse *)malloc(sizeof(struct _trt__GetStreamUriResponse)); int result=0 ; trt__GetStreamUri->StreamSetup = (struct tt__StreamSetup*)soap_malloc(soap,sizeof(struct tt__StreamSetup));//初始化,分配空间 trt__GetStreamUri->StreamSetup->Stream = 0;//stream type trt__GetStreamUri->StreamSetup->Transport = (struct tt__Transport *)soap_malloc(soap, sizeof(struct tt__Transport));//初始化,分配空间 trt__GetStreamUri->StreamSetup->Transport->Protocol = 0; trt__GetStreamUri->StreamSetup->Transport->Tunnel = 0; trt__GetStreamUri->StreamSetup->__size = 1; trt__GetStreamUri->StreamSetup->__any = NULL; trt__GetStreamUri->StreamSetup->__anyAttribute =NULL; trt__GetStreamUri->ProfileToken = trt__GetProfilesResponse->Profiles->token ; printf("\n\n---------------Getting Uri----------------\n\n"); soap_wsse_add_UsernameTokenDigest(soap,"user", ONVIF_USER, ONVIF_PASSWORD); soap_call___trt__GetStreamUri(soap, capa_resp->Capabilities->Media->XAddr, NULL, trt__GetStreamUri, trt__GetStreamUriResponse); if (soap->error) { printf("soap error: %d, %s, %s\n", soap->error, *soap_faultcode(soap), *soap_faultstring(soap)); result = soap->error; } else{ printf("!!!!NOTE: RTSP Addr Get Done is :%s \n",trt__GetStreamUriResponse->MediaUri->Uri); //最后我们使用vlc -vvv命令来打开一个rstp网络流 char cmd_str[256]; memset(cmd_str, 0, sizeof(cmd_str)); sprintf(cmd_str, "vlc %s --sout=file/ps:device%d.mp4", trt__GetStreamUriResponse->MediaUri->Uri, HasDev); popen((const char *)cmd_str, "r"); } }
int soap_fresponse(struct soap *soap, int status, size_t count) { //int err; //std::cout << "DEBUG soap_fresponse" << std::endl; //if ((err = soap->fposthdr(soap, "Access-Control-Allow-Origin", "*"))) // return err; //if ((err = soap->fposthdr(soap, "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, CONNECT"))) // return err; //if ((err = soap->fposthdr(soap, "Access-Control-Allow-Headers", "X-Requested-With, Content-Type"))) // return err; //if ((err = soap->fposthdr(soap, "Access-Control-Allow-Credentials", "true"))) // return err; //int ret = old_freponse(soap, soap_error_code, count); //return ret; std::cout << "debug status=" << status << std::endl; status = 200; register int err; #ifdef WMW_RPM_IO if (soap->rpmreqid) httpOutputEnable(soap->rpmreqid); #endif if (strlen(soap->http_version) > 4) return soap->error = SOAP_EOM; if (!status || status == SOAP_HTML || status == SOAP_FILE) { const char *s; if (count || ((soap->omode & SOAP_IO) == SOAP_IO_CHUNK)) s = "200 OK"; else s = "202 ACCEPTED"; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Status = %s\n", s)); #ifdef WMW_RPM_IO if (soap->rpmreqid || soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* RPM behaves as if standalone */ #else if (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* standalone application (socket) or CGI (stdin/out)? */ #endif { sprintf(soap->tmpbuf, "HTTP/%s %s", soap->http_version, s); if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL))) return err; } else if ((err = soap->fposthdr(soap, "Status", s))) /* CGI header */ return err; } else if (status >= 200 && status < 600) { sprintf(soap->tmpbuf, "HTTP/%s %d %s", soap->http_version, status, http_error(soap, status)); if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL))) return err; #ifndef WITH_LEAN if (status == 401) { sprintf(soap->tmpbuf, "Basic realm=\"%s\"", (soap->authrealm && strlen(soap->authrealm) < sizeof(soap->tmpbuf) - 14) ? soap->authrealm : "gSOAP Web Service"); if ((err = soap->fposthdr(soap, "WWW-Authenticate", soap->tmpbuf))) return err; } else if ((status >= 301 && status <= 303) || status == 307) { if ((err = soap->fposthdr(soap, "Location", soap->endpoint))) return err; } #endif } else { const char *s = *soap_faultcode(soap); //std::cout << "DEBUG status=" << status << std::endl; //std::cout << "DEBUG SOAP_GET_METHOD=" << SOAP_GET_METHOD << std::endl; //std::cout << "DEBUG SOAP_HTTP_METHOD=" << SOAP_HTTP_METHOD << std::endl; if (status >= SOAP_GET_METHOD && status <= SOAP_HTTP_METHOD) s = "405 Method Not Allowed"; else if (soap->version == 2 && (!s || !strcmp(s, "SOAP-ENV:Sender"))) s = "400 Bad Request"; else s = "500 Internal Server Error"; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Error %s (status=%d)\n", s, status)); #ifdef WMW_RPM_IO if (soap->rpmreqid || soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* RPM behaves as if standalone */ #else if (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* standalone application */ #endif { sprintf(soap->tmpbuf, "HTTP/%s %s", soap->http_version, s); if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL))) return err; } else if ((err = soap->fposthdr(soap, "Status", s))) /* CGI */ return err; } if ((err = soap->fposthdr(soap, "Server", "gSOAP/2.7")) || (err = soap_puthttphdr(soap, status, count))) return err; #ifdef WITH_COOKIES if (soap_putsetcookies(soap)) return soap->error; #endif //if ((err = soap->fposthdr(soap, "Access-Control-Allow-Origin", "*"))) // return err; //if ((err = soap->fposthdr(soap, "Access-Control-Allow-Credentials", "true"))) // return err; //if ((err = soap->fposthdr(soap, "Access-Control-Allow-Headers", "origin,x-requested-with,access-control-request-headers,content-type,access-control-request-method,accept"))) // return err; //if ((err = soap->fposthdr(soap, "Access-Control-Allow-Methods", "POST,HEAD,GET,PUT,DELETE,OPTIONS"))) // return err; //if ((err = soap->fposthdr(soap, "Allow", "HEAD,GET,PUT,DELETE,OPTIONS"))) // return err; return soap->fposthdr(soap, NULL, NULL); }
int main(int argc, char *argv[]) { /* 变量声明 */ struct soap *soap; //soap环境变量 struct wsdd__ProbeType req; //用于发送消息描述 struct wsdd__ProbeType wsdd__Probe; struct __wsdd__ProbeMatches resp; //struct wsdd__ProbeMatchesType resp; //请求消息的回应 struct wsdd__ScopesType sScope; //描述查找哪类的Web服务 struct SOAP_ENV__Header header; //soap消息头描述 int count = 0; //获得的设信息备个数 int result = 0; //返回值 unsigned char macaddr[6]; char _HwId[1024]; unsigned int Flagrand; // Create SessionID randomly srand((int)time(0)); Flagrand = rand()%9000 + 8888; macaddr[0] = 0x1; macaddr[1] = 0x2; macaddr[2] = 0x3; macaddr[3] = 0x4; macaddr[4] = 0x5; macaddr[5] = 0x6; sprintf(_HwId,"urn:uuid:%ud68a-1dd2-11b2-a105-%02X%02X%02X%02X%02X%02X", Flagrand, macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]); /************初始化*************/ soap = soap_new(); //为soap申请变量空间,并初始化 if ( soap == NULL) { return -1; } soap_set_namespaces(soap, namespaces); //设置soap的namespaces soap->recv_timeout = 5; //超过5秒钟没有数据就退出 soap_default_SOAP_ENV__Header(soap, &header);//将header设置为soap消息 头属性 header.wsa__MessageID = _HwId; header.wsa__To = "urn:schemas-xmlsoap-org:ws:2005:04:discovery"; header.wsa__Action = "http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe"; soap->header = &header; //设置soap头消息的ID //设置soap消息的请求服务属性 soap_default_wsdd__ScopesType(soap, &sScope); sScope.__item = ""; //sScope.__item = "onvif://www.onvif.org"; soap_default_wsdd__ProbeType(soap, &req); req.Scopes = &sScope; //req.Types = "tdn:NetworkVideoTransmitter"; req.Types = "tds:Device"; //调用gSoap接口 //soap_wsdd_Probe result = soap_send___wsdd__Probe(soap, "soap.udp://239.255.255.250:3702", NULL, &req); printf("%s: %d, send probe request success!\n",__FUNCTION__, __LINE__); if ( result == -1 ) { printf ( "soap error: %d, %s, %s\n", soap->error, *soap_faultcode(soap), *soap_faultstring(soap)); result = soap->error; } else { do { printf("%s: %d, begin receive probematch... \n",__FUNCTION__, __LINE__); printf("count=%d \n",count); //接收ProbeMatches,成功返回0,否则-1 result = soap_recv___wsdd__ProbeMatches(soap, &resp); printf(" --soap_recv___wsdd__ProbeMatches() result=%d \n",result); if (result==-1) { printf("Find %d devices!\n", count); break; } else { //读取服务端回应的Probematch消息 if ( resp.wsdd__ProbeMatches){ /*** printf("soap_recv___wsdd__Probe: __sizeProbeMatch=%d\r\n",resp.wsdd__ProbeMatches->__sizeProbeMatch); printf("Target EP Address : %s\r\n", resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.Address); printf("Target Type : %s\r\n", resp.wsdd__ProbeMatches->ProbeMatch->Types); printf("Target Service Address : %s\r\n", resp.wsdd__ProbeMatches->ProbeMatch->XAddrs); printf("Target Metadata Version : %d\r\n",resp.wsdd__ProbeMatches->ProbeMatch->MetadataVersion); printf("Target Scopes Address : %s\r\n", resp.wsdd__ProbeMatches->ProbeMatch->Scopes->__item); **/ DeviceInfo device; device.dev_uuid = resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.Address; device.dev_server_address = resp.wsdd__ProbeMatches->ProbeMatch->XAddrs; char duplicate = 0; int index = 0; while ( index < MAX_DEVICE) { char *uuid = g_device_list[ index].dev_uuid; if ( uuid != NULL && strcmp( uuid, device.dev_uuid) == 0 ) { duplicate = 1; break; } ++index; } if ( duplicate == 0) { printf ( " find device no :%d \n" , ( count +1)); printf ( " uuid : %s \n" , device.dev_uuid); printf ( " server address : %s \n" , device.dev_server_address); g_device_list[ count] = device; count += 1; } } } } while ( 1); } //清除soap soap_end(soap); // clean up and remove deserialized data soap_free(soap);//detach and free runtime context soap_done(soap); // detach context (last use and no longer in scope) return result; }
int ONVIF_ClientDiscovery( ) { int retval = SOAP_FAULT; wsdd__ProbeType req; struct __wsdd__ProbeMatches resp; wsdd__ScopesType sScope; struct soap *soap = NULL; struct SOAP_ENV__Header header; const char *was_To = "urn:schemas-xmlsoap-org:ws:2005:04:discovery"; const char *was_Action = "http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe"; //这个就是传递过去的组播的ip地址和对应的端口发送广播信息 const char *soap_endpoint = "soap.udp://239.255.255.250:3702/"; //这个接口填充一些信息并new返回一个soap对象,本来可以不用额外接口, // 但是后期会作其他操作,此部分剔除出来后面的操作就相对简单了,只是调用接口就好 soap = ONVIF_Initsoap(&header, was_To, was_Action, 5); soap_default_SOAP_ENV__Header(soap, &header); soap->header = &header; soap_default_wsdd__ScopesType(soap, &sScope); sScope.__item = ""; soap_default_wsdd__ProbeType(soap, &req); req.Scopes = &sScope; req.Types = "tdn:NetworkVideoTransmitter"; retval = soap_send___wsdd__Probe(soap, soap_endpoint, NULL, &req); //发送组播消息成功后,开始循环接收各位设备发送过来的消息 while (retval == SOAP_OK) { retval = soap_recv___wsdd__ProbeMatches(soap, &resp);//这个函数用来接受probe消息,存在resp里面 if (retval == SOAP_OK) { if (soap->error) { printf("[%d]: recv soap error :%d, %s, %s\n", __LINE__, soap->error, *soap_faultcode(soap), *soap_faultstring(soap)); retval = soap->error; } else //成功接收某一个设备的消息 { HasDev ++; if (resp.wsdd__ProbeMatches->ProbeMatch != NULL && resp.wsdd__ProbeMatches->ProbeMatch->XAddrs != NULL) { printf(" ################ recv %d devices info #### \n", HasDev ); printf("Target Service Address : %s\n", resp.wsdd__ProbeMatches->ProbeMatch->XAddrs); printf("Target EP Address : %s\n", resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.Address); printf("Target Type : %s\n", resp.wsdd__ProbeMatches->ProbeMatch->Types); printf("Target Metadata Version : %d\n", resp.wsdd__ProbeMatches->ProbeMatch->MetadataVersion); ONVIF_Capabilities(&resp);//这里可以调用能力值获取函数 sleep(1); } } } else if (soap->error) { if (HasDev == 0) { printf("[%s][%s][Line:%d] Thers Device discovery or soap error: %d, %s, %s \n",__FILE__, __func__, __LINE__, soap->error, *soap_faultcode(soap), *soap_faultstring(soap)); retval = soap->error; } else { printf(" [%s]-[%d] Search end! It has Searched %d devices! \n", __func__, __LINE__, HasDev); retval = 0; } break; } } soap_destroy(soap); soap_end(soap); soap_free(soap); return retval; }
int ONVIF_Capabilities(struct __wsdd__ProbeMatches *resp) { struct _tds__GetCapabilities capa_req; struct _tds__GetCapabilitiesResponse capa_resp; struct soap *soap = NULL; struct SOAP_ENV__Header header; int retval = 0; soap = ONVIF_Initsoap(&header, NULL, NULL, 5); char *soap_endpoint = (char *)malloc(256); memset(soap_endpoint, '\0', 256); //海康的设备,固定ip连接设备获取能力值 ,实际开发的时候,"172.18.14.22"地址以及80端口号需要填写在动态搜索到的具体信息 sprintf(soap_endpoint, resp->wsdd__ProbeMatches->ProbeMatch->XAddrs); capa_req.Category = (enum tt__CapabilityCategory *)soap_malloc(soap, sizeof(int)); capa_req.__sizeCategory = 1; *(capa_req.Category) = (enum tt__CapabilityCategory)0; //此句也可以不要,因为在接口soap_call___tds__GetCapabilities中判断了,如果此值为NULL,则会给它赋值 const char *soap_action = "http://www.onvif.org/ver10/device/wsdl/GetCapabilities"; capa_resp.Capabilities = (struct tt__Capabilities*)soap_malloc(soap,sizeof(struct tt__Capabilities)) ; //这里处理鉴权函数 soap_wsse_add_UsernameTokenDigest(soap, "user", ONVIF_USER, ONVIF_PASSWORD); do { int result = soap_call___tds__GetCapabilities(soap, soap_endpoint, soap_action, &capa_req, &capa_resp); if (soap->error) { printf("[%s][%d]--->>> soap error: %d, %s, %s\n", __func__, __LINE__, soap->error, *soap_faultcode(soap), *soap_faultstring(soap)); retval = soap->error; break; } else //获取参数成功 { // 走到这里的时候,已经就是验证成功了,可以获取到参数了, // 在实际开发的时候,可以把capa_resp结构体的那些需要的值匹配到自己的私有协议中去,简单的赋值操作就好 printf("[%s][%d] Get capabilities success !\n", __func__, __LINE__); if(capa_resp.Capabilities == NULL) printf("GetCapabilities failed! result = %d\n", result); else { printf(" Media->XAddr=%s \n", capa_resp.Capabilities->Media->XAddr); UserGetProfiles(soap, &capa_resp);// } } }while(0); free(soap_endpoint); soap_endpoint = NULL; soap_destroy(soap); return retval; }
/** * List all replicas of a given InputDataType. A replica needs to contain * a valid SEId that is registered with the Information Service. * * @param inputDataType Defines one of the following InputDataTypes: * lfn ... LogicalFileName * guid ... GUID Global Unique Idenifier * lds ... LogicalDataSet * query ... generic query to the catalogue * Further InputDataTypes can be extended in the future but need to * be understood by the remote catalogue. * Note that a catalogue does not need to implement all of the four * InputDataTypes but is free to support any subset. * @param inputData Actutual InputData variable * * @returns a vector of URLs that represent the locations of where * the InputData is located. The URL can either be a full URL * of the form protocol://hostname/pathname * or hostname * where hostname is a registered SEId. */ std::vector<std::string> dli::DataLocationInterfaceSOAP::listReplicas(std::string inputDataType, std::string inputData, const classad::ClassAd & ad, const std::string& endpoint) { ///////////////////...for using secure endpoint bool proxyInJdl = true; std::string proxy; try { proxy = jdl::get_x509_user_proxy(ad); } catch(...) { proxyInJdl = false; } if(0 == strncasecmp(endpoint.c_str(), "https://", 8)) { if (proxyInJdl) { if (!m_ctx) { if ( glite_gsplugin_init_context(&m_ctx) ) { throw DLIerror("gsplugin_init_context FAILED"); } } if (glite_gsplugin_set_credential(m_ctx, proxy.c_str(), proxy.c_str())) { std::string gss_err(m_ctx->error_msg); glite_gsplugin_free_context(m_ctx); m_ctx = NULL; throw DLIerror("Cannot set credentials in the gsoap-plugin context: " + gss_err); } } else { throw DLIerror("UserProxy not specified in the ClassAd"); } if (soap_register_plugin_arg(&m_soap, glite_gsplugin, m_ctx)) { std::stringstream ss; ss << m_soap.error; std::string soap_err = ss.str(); throw DLIerror("soap_register_plugin_arg FAILED: " + soap_err); } } std::vector<std::string> urlVector; struct datalocationinterface__listReplicasResponse theList; // Call listReplicas and handle potential SOAP Faults if (soap_call_datalocationinterface__listReplicas( &m_soap, endpoint.c_str(), "", inputDataType, inputData, theList)) { std::string ex; if (m_soap.error) { soap_set_fault(&m_soap); const char** faultdetail_ptr = soap_faultdetail(&m_soap); std::string faultdetail; if (*faultdetail_ptr != NULL) { faultdetail = *faultdetail_ptr; } else { faultdetail = "unknown"; } const char** faultcode_ptr = soap_faultcode(&m_soap); std::string faultcode; if ( *faultcode_ptr != NULL ) faultcode = *faultcode_ptr; else faultcode = "unknown"; const char** faultstring_ptr = soap_faultstring(&m_soap); std::string faultstring; if (*faultstring_ptr != NULL ) faultstring = *faultstring_ptr; else faultstring = "unknown"; std::string SOAP_FAULTCODE = "SOAP_FAULTCODE: "; std::string SOAP_FAULTSTRING = "SOAP_FAULTSTRING: "; std::string SOAP_FAULT_DETAIL = "SOAP_FAULT_DETAIL: "; std::string new_line = "\n"; ex = new_line + SOAP_FAULTCODE + faultcode + new_line + SOAP_FAULTSTRING + faultstring + new_line + SOAP_FAULT_DETAIL + faultdetail + new_line; } else { ex = "Error in soap request towards StorageIndex Catalog. Unknown error."; } throw DLIerror(ex); } for (int i = 0; i < (theList.urlList)->__size; i++) { #ifdef GSOAP_279_TRICK std::string *thisS = *(theList.urlList->__ptritem); #else std::string *thisS = (theList.urlList->__ptritem); #endif //std::string str( ((theList.urlList)->__ptritem)[i] ); std::string str( *(thisS + i) ); urlVector.push_back( str ); } return urlVector; } // listReplicas
int ONVIF_DEVICEIO_GetServiceCapabilities(char *username, char *password, char *deviceioService) { int retval = 0; struct soap *soap = NULL; struct _tmd__GetServiceCapabilities deviceio_GetServiceCapabilities_req; struct _tmd__GetServiceCapabilitiesResponse deviceio_GetServiceCapabilities_resp; struct SOAP_ENV__Header header; UserInfo_S stUserInfo; memset(&stUserInfo, 0, sizeof(UserInfo_S)); strcpy(stUserInfo.username, username); strcpy(stUserInfo.password, password); memset(&header,0,sizeof(header)); soap = ONVIF_Initsoap(&header, NULL, NULL, 5, &stUserInfo); char *soap_endpoint = (char *)malloc(256); memset(soap_endpoint, '\0', 256); sprintf(soap_endpoint, "%s", deviceioService); const char *soap_action = "http://www.onvif.org/ver10/deviceIO/wsdl/GetServiceCapabilities"; do { soap_call___tmd__GetServiceCapabilities(soap, soap_endpoint, soap_action, &deviceio_GetServiceCapabilities_req, &deviceio_GetServiceCapabilities_resp); if (soap->error) { printf("[%s][%d]--->>> soap error: %d, %s, %s\n", __func__, __LINE__, soap->error, *soap_faultcode(soap), *soap_faultstring(soap)); retval = soap->error; return retval; } else { printf("[%s][%d] success !\n", __func__, __LINE__); } }while(0); free(soap_endpoint); soap_endpoint = NULL; soap_destroy(soap); return retval; }