int __ns1__dtx(struct soap *soap, _XML x, struct _ns2__commingtotown *response) { struct soap *csoap = soap_copy(soap); struct tm tm; time_t now, xmas; double sec, days; soap_set_namespaces(csoap, gmt_namespaces); if (soap_call_t__gmt(csoap, "http://www.cs.fsu.edu/~engelen/gmtlitserver.cgi", NULL, &now)) { soap_end(csoap); soap_free(csoap); return soap_receiver_fault(soap, "Cannot connect to GMT server", NULL); } tm.tm_sec = 0; tm.tm_min = 0; tm.tm_hour = 0; tm.tm_mday = 25; tm.tm_mon = 11; tm.tm_year = gmtime(&now)->tm_year; /* this year */ tm.tm_isdst = 0; tm.tm_zone = NULL; xmas = soap_timegm(&tm); if (xmas < now) { tm.tm_year++; /* xmas just passed, go to next year */ xmas = soap_timegm(&tm); } sec = difftime(xmas, now); soap_set_namespaces(csoap, calc_namespaces); if (soap_call_ns__add(csoap, NULL, NULL, sec, 86400, &days)) { soap_end(csoap); soap_free(csoap); return soap_receiver_fault(soap, "Cannot connect to calc server", NULL); } soap_end(csoap); soap_free(csoap); response->days = (int)days; return SOAP_OK; }
int main(int argc, char* argv[]) { ns2BikeList bl; struct soap *soap = soap_new(); char search[MAX_POST_FIELD] = ""; char type [MAX_POST_FIELD] = ""; uint32_t priceFrom = 0; uint32_t priceTo = 0; parseArgs(argc, argv, search, MAX_POST_FIELD, type, MAX_POST_FIELD, &priceFrom, &priceTo); if(soap_call_ns2__bikeGet(soap, NULL, NULL, search, type, priceFrom, priceTo, bl) == SOAP_OK) { logList(bl); } else { soap_print_fault(soap, stderr); } soap_end(soap); soap_free(soap); return 0; }
//监听指定端口,事件参考event.c //用于监听IPC上线或下线、或响应客户探测 //timeout设置超时时间,>0单位为秒 =0 用不超时 <0单位为微秒 static int listenPort(int port,int timeout) { struct soap *serv = soap_new1(SOAP_IO_UDP); // to invoke messages int ret; //绑定端口号 if (!soap_valid_socket(soap_bind(serv,NULL,port, 100))) { soap_print_fault(serv, stderr); printf("soap_bind error\n"); ret = -1; goto ERR0; } //加入多播地址 struct ip_mreq mreq; mreq.imr_multiaddr.s_addr = inet_addr("239.255.255.250"); mreq.imr_interface.s_addr = htonl(INADDR_ANY); if (setsockopt(serv->socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) { printf("add multiaddr is error\n"); goto ERR0; } //监听 ret = soap_wsdd_listen(serv,timeout); if(ret!=SOAP_OK) { soap_print_fault(serv, stderr); printf("soap_wsdd_listen error,ret=%d\n",ret); goto ERR0; } printf("soap_wsdd_listen return\n"); ERR0: soap_end(serv); soap_free(serv); return ret; }
Root::~Root() { if (soap_call_ns__release(soap, endpoint, "", status)) soap_print_fault(soap, stderr); // for demo, just print soap_destroy(soap); soap_end(soap); soap_free(soap); }
//采用单播形式发送probe,发送会马上阻塞等待一个事件响应,事件参考event.c //只能接收一个event,用于指定地址probe,比如手动添加IPC static int probeUnicast(const char *endpoint, const char * types, const char *scopes,int timeout) { struct soap *soap = soap_new1(SOAP_IO_UDP); // to invoke messages int ret; const char *id = soap_wsa_rand_uuid(soap); //设置超时时间,>0单位为秒 =0 用不超时 <0单位为微秒 soap->accept_timeout = soap->recv_timeout = soap->send_timeout = timeout; ret = soap_wsdd_Probe(soap, SOAP_WSDD_MANAGED,//SOAP_WSDD_ADHOC, // ad-hoc mode SOAP_WSDD_TO_TS, // to a TS endpoint, // address of TS; "soap.udp://239.255.255.250:3702" id, // message ID NULL, // ReplyTo,表示回应的message ID,因为是主动回发起,所以没有,填NULL types, //types,搜寻的设备类型"dn:NetworkVideoTransmitter tds:Device" scopes, //scopes,指定搜索范围,无填 NULL NULL); //match by,匹配规则,无填 NULL if(ret!=SOAP_OK) { soap_print_fault(soap, stderr); printf("soap_wsdd_Probe error,ret=%d\n",ret); } soap_end(soap); soap_free(soap); return ret; }
int main(int argc, char **argv) { if (argc < 2) { fprintf(stderr, "Usage: json-GitHub hostname [username password]\nFor example: json-GitHub https://api.github.com/orgs/Genivia/repos\n\n"); exit(1); } else { soap *ctx = soap_new1(SOAP_C_UTFSTRING | SOAP_XML_INDENT); value response(ctx); if (argc > 3) { /* Basic authentication with username password */ if (strncmp(argv[1], "https", 5)) { fprintf(stderr, "Basic authentication over http is not secure: use https\n"); exit(1); } ctx->userid = argv[2]; ctx->passwd = argv[3]; } if (json_call(ctx, argv[1], NULL, &response)) soap_print_fault(ctx, stderr); else json_write(ctx, response); printf("\n\nOK\n"); soap_end(ctx); soap_free(ctx); } return 0; }
void ptz_ctrl_release() { /*资源释放*/ soap_destroy(soap); soap_end(soap); soap_free(soap); }
/** Forward event callbacks to the SOAP remote server, if configured and connected. */ static DSL_Error_t SOAP_EventCallback(DSL_void_t *pContext, DSL_char_t *pMessage) { Soap_env_t *env = pContext; char *pResult = NULL; if (sSoapRemoteServer == DSL_NULL || pMessage == DSL_NULL || env->client.bInit == DSL_FALSE) { /** Not connected, silent ignore! */ return DSL_ERROR; } if(DSL_CPE_LockTimedGet(&env->callBackSem, DSL_SOAPCBWAIT_TIMEOUT, DSL_NULL) != DSL_SUCCESS) { return DSL_ERROR; } soap_call_ifx__DslCpeEventCallback(&env->client.soap, sSoapRemoteServer, "", pMessage , &pResult); /* free the result pointer */ soap_free(&env->client.soap); soap_end(&env->client.soap); DSL_CPE_LockSet(&env->callBackSem); if (env->client.soap.error) { soap_print_fault(&env->client.soap, stderr); } return DSL_SUCCESS; }
void cleanup(struct soap* soap) { /* release our connection and context */ xmpp_conn_release(conn); xmpp_ctx_free(ctx); /* final shutdown of the library */ xmpp_shutdown(); if (rsa_private_key) { EVP_PKEY_free(rsa_private_key); } if (cert) { X509_free(cert); } if (soap) { soap_end(soap); soap_done(soap); soap_free(soap); } ERR_remove_state(0); ENGINE_cleanup(); CONF_modules_unload(1); ERR_free_strings(); EVP_cleanup(); CRYPTO_cleanup_all_ex_data(); }
int run_serve(int port) { struct soap *soap = soap_new1(SOAP_ENC_MTOM); /* enable MTOM */ int ret; if (!soap_valid_socket(soap_bind(soap, NULL, port, 100))) soap_print_fault(soap, stderr); else { fprintf(stderr, "Bind to port %d successful\n", port); soap->accept_timeout = 3600; /* let server time out after one hour */ for (;;) { int sock = soap_accept(soap); if (!soap_valid_socket(sock)) { if (soap->errnum) soap_print_fault(soap, stderr); else fprintf(stderr, "Server timed out\n"); break; } fprintf(stderr, "Accepting socket %d connection from IP %d.%d.%d.%d... ", sock, (int)(soap->ip>>24)&0xFF, (int)(soap->ip>>16)&0xFF, (int)(soap->ip>>8)&0xFF, (int)soap->ip&0xFF); if (soap_serve(soap)) soap_print_fault(soap, stderr); fprintf(stderr, "done\n"); soap_destroy(soap); soap_end(soap); } } ret = soap->error; soap_free(soap); /* done and free */ return ret; }
static void ProcessRequest(void *soap) { int32_t Ret; struct soap *tsoap = (struct soap*)soap; //pthread_detach(pthread_self()); //guoqiang.lu mask,11/20/2013 l_ThreadCnt++; Ret = soap_serve(tsoap); if (SOAP_OK != Ret && (tsoap->error != SOAP_EOF || (tsoap->errnum != 0 && !(tsoap->omode & SOAP_IO_KEEPALIVE)))) { fprintf(stderr, "Thread %d completed with failure %d, Ret %d\n", \ (int)(SOAP_SOCKET)tsoap->user, tsoap->error, Ret); DEBUG_LOG(g_DefaultLogClient, e_DebugLogLevel_Exception, "Thread %d completed with failure %d\n", (int)(SOAP_SOCKET)tsoap->user, tsoap->error); soap_print_fault(tsoap, stderr); } soap_destroy(tsoap); soap_end(tsoap); soap_done(tsoap); soap_free(tsoap); close((SOAP_SOCKET)tsoap->user); l_ThreadCnt--; ONVIF_INFO("======>%s %d exit, Total ThreadCnt %d\n", __func__, __LINE__, l_ThreadCnt); //mask by guoqiang.lu,2014/1/8 //pthread_exit(NULL); }
int run_tests(int argc, char **argv) { struct soap *soap = soap_new1(SOAP_XML_INDENT); struct ns__echoString r; char *endpoint, *arg; int ret; soap_register_plugin(soap, http_da); endpoint = argv[1]; arg = argv[2]; if (strchr(arg, 'c')) soap_set_omode(soap, SOAP_IO_CHUNK); if (strchr(arg, 'z')) soap_set_omode(soap, SOAP_ENC_ZLIB); if (soap_call_ns__echoString(soap, endpoint, NULL, arg, &r)) { if (soap->error == 401) { if (!strcmp(soap->authrealm, authrealm)) { /* save userid and passwd for basic or digest authentication */ struct http_da_info info; http_da_save(soap, &info, authrealm, "Mufasa", "Circle Of Life"); if (!soap_call_ns__echoString(soap, endpoint, NULL, arg, &r)) { soap_end(soap); /* need to restore for authentication */ http_da_restore(soap, &info); if (!soap_call_ns__echoString(soap, endpoint, NULL, arg, &r)) { if (!strcmp(arg, r.arg)) printf("EchoString test OK\n"); else printf("Transmission error\n"); } } http_da_release(soap, &info); /* regular calls may follow */ } } } if (soap->error) soap_print_fault(soap, stderr); ret = soap->error; soap_destroy(soap); soap_end(soap); soap_free(soap); return ret; }
void soap_parser_destroy(void *handle) { struct soap_parser *parser = (struct soap_parser *)handle; soap_end(parser->soap); soap_free(parser->soap); LOGI(parser->tag, "destroy"); if (parser->soap_header != NULL) { _soap_header_destroy(parser->soap_header); parser->soap_header = NULL; } if (parser->soap_fault != NULL) { _soap_fault_free(parser->soap_fault); parser->soap_fault = NULL; } free(parser); }
static void *_working_proc(void *param) #endif // win32 { struct soap *soap = (struct soap*)param; #ifdef WIN32 #else pthread_detach(pthread_self()); #endif// soap_serve((struct soap*)soap); soap_destroy((struct soap*)soap); // dealloc C++ data soap_end((struct soap*)soap); // dealloc data and clean up soap_done((struct soap*)soap); // detach soap struct soap_free(soap); return NULL; }
void getNetworks() { struct soap *soap = soap_new(); soap->userid = "u1"; soap->passwd = "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8"; struct ns1__getNetworksResponse networksResponse; if (soap_call_ns1__getNetworks(soap, NULL, NULL, "u1", &networksResponse) == SOAP_OK) { ArrayOf_USCORExsd_USCOREanyType* networks = networksResponse._getNetworksReturn; for ( int i = 0; i < networks->size; ++i ) { struct ns2__Network* nsNetwork = networks->_ptr[i]; printf( "Network %d\n", nsNetwork->name ); } } else { soap_print_fault(soap, stderr); } soap_end(soap); soap_free(soap); }
void *process_request(void *soap) { #ifdef _POSIX_THREADS pthread_detach(pthread_self()); #endif soap_ssl_accept((struct soap*)soap); // serve request (or multiple requests with keep-alive enabled) soap_serve((struct soap*)soap); // cleanup class instances soap_destroy((struct soap*)soap); // cleanup soap_end((struct soap*)soap); // detach and free thread's copy of soap environment soap_free((struct soap*)soap); return NULL; }
//采用多播形式发送probe,立即返回不阻塞等待事件响应,获取事件响应要主动接下对应的sock或调用soap_wsdd_listen函数,事件参考event.c //可以接收多个event,用于探测网络中存在的IPC static int probeMulticast(const char *endpoint, const char * types, const char *scopes,int timeout) { struct soap *serv = soap_new1(SOAP_IO_UDP); // to invoke messages int ret; const char *id = soap_wsa_rand_uuid(serv); ret = soap_wsdd_Probe(serv, SOAP_WSDD_ADHOC,//SOAP_WSDD_ADHOC, // ad-hoc mode SOAP_WSDD_TO_TS, // to a TS endpoint, // address of TS; "soap.udp://239.255.255.250:3702" id, // message ID NULL, // ReplyTo,表示回应的message ID,因为是主动回发起,所以没有,填NULL types, //types,搜寻的设备类型"dn:NetworkVideoTransmitter tds:Device" scopes, //scopes,指定搜索范围,无填 NULL NULL); //match by,匹配规则,无填 NULL if(ret!=SOAP_OK) { soap_print_fault(serv, stderr); printf("soap_wsdd_Probe error,ret=%d\n",ret); goto ERR0; } if (!soap_valid_socket(serv->socket)) { soap_print_fault(serv, stderr); printf("sock is error\n"); ret = -1; goto ERR0; } serv->master = serv->socket;//必须指定,否则无法监听 ret = soap_wsdd_listen(serv,timeout); if(ret!=SOAP_OK) { soap_print_fault(serv, stderr); printf("soap_wsdd_listen error,ret=%d\n",ret); goto ERR0; } ERR0: soap_end(serv); soap_free(serv); return ret; }
void soap_parser_cleanup(void *handle) { SoapParser *parser = (SoapParser *)handle; if (parser == NULL) { return; } if (parser->_namespaces != NULL) { soap_namespaces_free(parser->_namespaces); parser->_namespaces = NULL; } if (parser->soap != NULL) { soap_end(parser->soap); soap_done(parser->soap); soap_free(parser->soap); parser->soap = NULL; } free(parser); LOGI(LOG_TAG, "cleanup"); }
int run_serve(int port) { struct soap *soap = soap_new1(SOAP_XML_INDENT); int ret; if (soap_register_plugin(soap, http_da)) exit(1); if (!soap_valid_socket(soap_bind(soap, NULL, port, 100))) soap_print_fault(soap, stderr); else { fprintf(stderr, "Bind to port %d successful\n", port); soap->accept_timeout = 3600; /* let server time out after one hour */ for (;;) { SOAP_SOCKET sock = soap_accept(soap); if (!soap_valid_socket(sock)) { if (soap->errnum) soap_print_fault(soap, stderr); else { fprintf(stderr, "Server timed out\n"); break; } } fprintf(stderr, "Accepting socket %d connection from IP %d.%d.%d.%d\n", sock, (int)(soap->ip>>24)&0xFF, (int)(soap->ip>>16)&0xFF, (int)(soap->ip>>8)&0xFF, (int)soap->ip&0xFF); if (soap_serve(soap)) soap_print_fault(soap, stderr); fprintf(stderr, "Served\n\n"); soap_destroy(soap); soap_end(soap); } } ret = soap->error; soap_destroy(soap); soap_end(soap); soap_free(soap); return ret; }
BaseClient::~BaseClient() { if (m_pDevClient) delete m_pDevClient; if (m_pDevIOClient) delete m_pDevIOClient; if (m_pDispClient) delete m_pDispClient; if (m_pRecvClient) delete m_pRecvClient; if (m_pRecordingClient) delete m_pRecordingClient; if (m_pNotsConsumer) delete m_pNotsConsumer; if(m_pSoap) { soap_destroy(m_pSoap); soap_end(m_pSoap); soap_free(m_pSoap); } }
void *process_request(struct soap *soap) { #if defined(_POSIX_THREADS) || defined(_SC_THREADS) pthread_detach(pthread_self()); #endif #ifdef WITH_OPENSSL if (soap_ssl_accept(soap) != SOAP_OK) { /* when soap_ssl_accept() fails, socket is closed and SSL data reset */ pmesg_safe(&global_flag, LOG_ERROR, __FILE__, __LINE__, "SSL request failed, continue with next call...\n"); soap_print_fault(soap, stderr); } else #endif soap_serve(soap); soap_destroy(soap); /* for C++ */ soap_end(soap); soap_free(soap); mysql_thread_end(); return NULL; }
void *process_request(void *soap) { pthread_detach(pthread_self()); ((struct soap*)soap)->recv_timeout = 300; // Timeout after 5 minutes stall on recv ((struct soap*)soap)->send_timeout = 60; // Timeout after 1 minute stall on send ((struct soap*)soap)->fget = http_get; ((struct soap*)soap)->fpost = http_post; ((struct soap*)soap)->foptions = soap_foptions; old_freponse = ((struct soap*)soap)->fresponse; ((struct soap*)soap)->fresponse = soap_fresponse; ((struct soap*)soap)->fhead = soap_fhead; //std::cout << "DEBUG process_request pt1" << std::endl; soap_serve((struct soap*)soap); soap_destroy((struct soap*)soap); soap_end((struct soap*)soap); soap_free((struct soap*)soap); return NULL; }
AmazonS3SoapBindingService::~AmazonS3SoapBindingService() { if (this->own) soap_free(this->soap); }
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 main() { struct soap *ctx = soap_new1(SOAP_XML_INDENT); soap_set_namespaces(ctx, nosoap_nsmap); // a tree: Graph tree; // with 5 branches: for (int i = 0; i < 4; ++i) { Graph *branch = soap_new_Graph(ctx); tree.edges.push_back(branch); // each branch has a couple of leaves: for (int j = 0; j < i; ++j) branch->edges.push_back(soap_new_Graph(ctx)); } std::cout << "**** XML TREE FROM C++ TREE ****" << std::endl; soap_write_Graph(ctx, &tree); std::cout << std::endl << std::endl; std::cout << "**** XML TREE FROM C++ DIGRAPH ****" << std::endl; tree.edges[0] = tree.edges[1]; // first pair of edges point to shared node tree.edges[2] = tree.edges[3]; // second pair of edges point to shared node soap_write_Graph(ctx, &tree); std::cout << std::endl << std::endl; std::cout << "**** XML ID-REF DIGRAPH FROM C++ DIGRAPH ****" << std::endl; soap_set_omode(ctx, SOAP_XML_GRAPH); soap_write_Graph(ctx, &tree); std::cout << std::endl << std::endl; soap_clr_omode(ctx, SOAP_XML_GRAPH); std::cout << "**** XML ID-REF DIGRAPH FROM C++ CYCLIC GRAPH ****" << std::endl; tree.edges[0]->edges = tree.edges; // create cycle soap_set_omode(ctx, SOAP_XML_GRAPH); soap_write_Graph(ctx, &tree); std::cout << std::endl << std::endl; soap_clr_omode(ctx, SOAP_XML_GRAPH); std::cout << "**** XML TREE (PRUNED CYCLIC BRANCHES) FROM C++ CYCLIC GRAPH ****" << std::endl; soap_set_omode(ctx, SOAP_XML_TREE); soap_write_Graph(ctx, &tree); std::cout << std::endl << std::endl; soap_clr_omode(ctx, SOAP_XML_TREE); std::cout << "**** SOAP 1.1 ENCODED GRAPH FROM C++ CYCLIC GRAPH ****" << std::endl; soap_set_namespaces(ctx, soap11_nsmap); soap_set_version(ctx, 1); // enable SOAP 1.1 soap_write_Graph(ctx, &tree); std::cout << std::endl << std::endl; std::cout << "**** SOAP 1.2 ENCODED GRAPH FROM C++ CYCLIC GRAPH ****" << std::endl; soap_set_namespaces(ctx, soap12_nsmap); soap_set_version(ctx, 2); // enable SOAP 1.2 soap_write_Graph(ctx, &tree); std::cout << std::endl << std::endl; soap_destroy(ctx); // delete objects soap_end(ctx); // free temp data soap_free(ctx); // release context return 0; }
int main(int argc, char* argv[]) { std::string indevice = "/dev/video0"; std::string inpath = "unicast"; std::string outdevice = "/dev/video10"; std::string outpath = "rtsp://127.0.0.1:8554/unicast"; std::string username; std::string password; int port = 8080; int c = 0; while ((c = getopt (argc, argv, "h" "u:p:" "P:" "i:I:o:O:")) != -1) { switch (c) { case 'P': port = atoi(optarg); break; case 'u': username = optarg; break; case 'p': password = optarg; break; case 'i': indevice = optarg; break; case 'I': inpath = optarg; break; case 'o': outdevice = optarg; break; case 'O': outpath = optarg; break; case 'h': std::cout << argv[0] << " [-u username] [-p password] [-i v4l2 input device] [-I rtsp server] [-o v4l2 output device] [-O rtsp client]" << std::endl; exit(0); break; } } std::cout << "Listening to " << port << std::endl; ServiceContext deviceCtx; deviceCtx.m_devices.insert(std::pair<std::string,std::string>(indevice, inpath)); deviceCtx.m_port = port; deviceCtx.m_user = username; deviceCtx.m_password = password; deviceCtx.m_outdevice = outdevice; deviceCtx.Manufacturer = "Manufacturer"; deviceCtx.Model = "Model"; deviceCtx.FirmwareVersion = "FirmwareVersion"; deviceCtx.SerialNumber = "SerialNumber"; deviceCtx.HardwareId = "HardwareId"; deviceCtx.m_scope.push_back("onvif://www.onvif.org/name/Name"); deviceCtx.m_scope.push_back("onvif://www.onvif.org/location/Here"); deviceCtx.m_scope.push_back("onvif://www.onvif.org/Profile/Streaming"); deviceCtx.m_scope.push_back("onvif://www.onvif.org/Profile/G"); struct soap *soap = soap_new(); soap->user = (void*)&deviceCtx; soap->fget = http_get; { FOREACH_SERVICE(DECLARE_SERVICE,soap) if (!soap_valid_socket(soap_bind(soap, NULL, deviceCtx.m_port, 100))) { soap_stream_fault(soap, std::cerr); } else { while (soap_accept(soap) != SOAP_OK) { if (soap_begin_serve(soap)) { soap_stream_fault(soap, std::cerr); } FOREACH_SERVICE(DISPATCH_SERVICE,soap) else { std::cout << "Unknown service" << std::endl; } } } } soap_destroy(soap); soap_end(soap); soap_free(soap); return 0; }
int llamar_servicio_get(char *proxyHost) { struct value resJSON; struct soap *soap = soap_new(); soap_register_plugin(soap, http_get); if (proxyHost && strlen(proxyHost) > 0) soap->proxy_host = proxyHost; printf("Ejemplo de llamada get recuperando JSON\n"); printf("---------------------------------------\n"); if (soap_get_connect(soap, "http://jsonplaceholder.typicode.com/posts/1", NULL)) { soap_print_fault(soap, stderr); printf("Error en la conexión con la API get.\n"); goto finalizar; } if (soap_begin_recv(soap)) { soap_print_fault(soap, stderr); printf("Error en la llamada a la API get.\n"); goto finalizar; } if (json_recv(soap, &resJSON)) { soap_print_fault(soap, stderr); printf("Error en la obtención del JSON en la API get.\n"); goto finalizar; } if (soap_end_recv(soap)) { soap_print_fault(soap, stderr); printf("Error en la finalización de la API get.\n"); goto finalizar; } if (resJSON.__type == SOAP_TYPE__struct) { struct _struct *estructuraJSON; estructuraJSON = (struct _struct *)resJSON.ref; int i; for (i=0; i < estructuraJSON->__size; i++) { printf("%s: ", (estructuraJSON->member + i)->name); if ((estructuraJSON->member + i)->value.__type == SOAP_TYPE__string) { printf("%s\n", (estructuraJSON->member + i)->value.ref); } else if ((estructuraJSON->member + i)->value.__type == SOAP_TYPE__int) { printf("%ld\n", (estructuraJSON->member + i)->value.ref); } } } else { printf("Se recibe un JSON no esperado.\n"); goto finalizar; } printf("Ha finalizado correctamente la llamada get\n"); printf("------------------------------------------\n"); finalizar: soap_destroy(soap); soap_end(soap); soap_free(soap); return 0; }
int llamar_servicio_post(char *proxyHost) { struct value resJSON; struct soap *soap = soap_new(); struct value jsonRequest; struct _struct estructuraPoC; struct value title, body, userId; struct member miembrosPoC[3]; if (proxyHost && strlen(proxyHost) > 0) soap->proxy_host = proxyHost; printf("Ejemplo de llamada get recuperando JSON\n"); printf("---------------------------------------\n"); if (soap_post_connect(soap, "http://jsonplaceholder.typicode.com/posts", NULL, "application/json")) { soap_print_fault(soap, stderr); printf("Error en la conexión con la API post.\n"); goto finalizar; } // JSON con 3 miembros // Title title.__type = SOAP_TYPE__string; char sTitle[10] = "foo"; title.ref = sTitle; // body body.__type = SOAP_TYPE__string; char sBody[10] = "bar"; body.ref = sBody; // userId userId.__type = SOAP_TYPE__int; int iUserId = 1; userId.ref = &iUserId; miembrosPoC[0].name = "title"; miembrosPoC[0].value = title; miembrosPoC[1].name = "body"; miembrosPoC[1].value = body; miembrosPoC[2].name = "userId"; miembrosPoC[2].value = userId; estructuraPoC.__size = 3; estructuraPoC.member = miembrosPoC; jsonRequest.__type = SOAP_TYPE__struct; jsonRequest.ref = &estructuraPoC; if (json_send(soap, &jsonRequest)) { soap_print_fault(soap, stderr); printf("Error en el envío JSON en la llamada post.\n"); goto finalizar; } if (soap_end_send(soap)) { soap_print_fault(soap, stderr); printf("Error al finalizar envío JSON en la llamada post."); goto finalizar; } if (soap_begin_recv(soap)) { soap_print_fault(soap, stderr); printf("Error en el inicio de la recepción JSON en la API post."); goto finalizar; } if (json_recv(soap, &resJSON)) { soap_print_fault(soap, stderr); printf("Error en la obtención del JSON en la API post.\n"); goto finalizar; } if (soap_end_recv(soap)) { soap_print_fault(soap, stderr); printf("Error en la finalización de la API post.\n"); goto finalizar; } if (resJSON.__type == SOAP_TYPE__struct) { struct _struct *estructuraJSON; estructuraJSON = (struct _struct *)resJSON.ref; int i; for (i=0; i < estructuraJSON->__size; i++) { printf("%s: ", (estructuraJSON->member + i)->name); if ((estructuraJSON->member + i)->value.__type == SOAP_TYPE__string) { printf("Cadena: %s\n", (estructuraJSON->member + i)->value.ref); } else if ((estructuraJSON->member + i)->value.__type == SOAP_TYPE__int) { printf("Entero: %ld\n", *(int*)((estructuraJSON->member + i)->value.ref)); } } } else { printf("Se recibe un JSON no esperado.\n"); goto finalizar; } printf("Ha finalizado correctamente la llamada post\n"); printf("------------------------------------------\n"); finalizar: soap_destroy(soap); soap_end(soap); soap_free(soap); return 0; }
RemoteDiscoveryBindingProxy::~RemoteDiscoveryBindingProxy() { if (this->own) soap_free(this->soap); }
RuleEngineBindingProxy::~RuleEngineBindingProxy() { if (this->soap_own) soap_free(this->soap); }