我使用gSOAP生成了ONVIF協議的C的代碼框架,我準備實作第一步,設備發現,但是呼叫result = soap_recv___wsdd__ProbeMatches(soap, &rep);時,回傳值result=-1,不知道怎么回事,我已經修改了username和password。
代碼如下:
SOAP_ASSERT(NULL != (soap = ONVIF_soap_new(SOAP_SOCK_TIMEOUT)));
ONVIF_init_header(soap); // 設定訊息頭描述
ONVIF_init_ProbeType(soap, &req); // 設定尋找的設備的范圍和型別
result = soap_send___wsdd__Probe(soap, SOAP_MCAST_ADDR, NULL, &req); // 向組播地址廣播Probe訊息
while (SOAP_OK == result) // 開始回圈接收設備發送過來的訊息
{
memset(&rep, 0x00, sizeof(rep));
result = soap_recv___wsdd__ProbeMatches(soap, &rep);
if (SOAP_OK == result) {
if (soap->error) {
soap_perror(soap, "ProbeMatches");
} else { // 成功接收到設備的應答訊息
dump__wsdd__ProbeMatches(&rep);
if (NULL != rep.wsdd__ProbeMatches) {
count += rep.wsdd__ProbeMatches->__sizeProbeMatch;
for(i = 0; i < rep.wsdd__ProbeMatches->__sizeProbeMatch; i++) {
probeMatch = rep.wsdd__ProbeMatches->ProbeMatch + i;
if (NULL != cb) {
cb(probeMatch->XAddrs); // 使用設備服務地址執行函式回呼
}
}
}
}
} else if (soap->error) {
break;
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/172962.html
標籤:Web Services
