Tereius / libONVIF

Yet another ONVIF library
GNU General Public License v3.0
164 stars 47 forks source link

No IPv4Address found while executing GetNTP #13

Closed dix75 closed 3 years ago

dix75 commented 3 years ago

Hello!

IPv4Address is empty (IPv4Address is nullptr) when I try to use GetNTP. soap responce <SOAP-ENV:Body><tds:GetNTPResponse><tds:NTPInformation><tt:FromDHCP>false</tt:FromDHCP><tt:NTPManual><tt:Type>IPv4</tt:Type><tt:IPv4Address>172.17.4.51</tt:IPv4Address></tt:NTPManual></tds:NTPInformation></tds:GetNTPResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

Code ` auto builder = SoapCtx::Builder(); auto ctx = builder.EnableOMode(SOAP_XML_INDENT) .SetConnectTimeout(1000) .Build();

        ctx->EnablePrintRawSoap();

        OnvifDeviceClient onf(dev.onvifAddress(), ctx);
        onf.SetAuth(dev.login(), dev.pass(), AUTO);

        Request<_tds__GetNTP> req;
        auto const res = onf.GetNTP(req);
        if(res)
            auto ntp = res.GetResultObject()->NTPInformation;
            qDebug() << ntp->FromDHCP;
            qDebug() << ntp->Extension;
            for(auto h: ntp->NTPFromDHCP) {
                qDebug() << "dhcp";
                qDebug() << (int)h->Type;
                qDebug() << h->DNSname;
                qDebug() << h->IPv4Address;
                qDebug() << h->IPv6Address;
            }
            for(auto h: ntp->NTPManual) {
                qDebug() << "manual";
                qDebug() << (int)h->Type;
                qDebug() << h->DNSname;
                qDebug() << h->Extension;
                qDebug() << h->IPv4Address;    // is NULL
                qDebug() << h->IPv6Address;
            }`
Tereius commented 3 years ago

Hi,

you are right. The IP address doesn't get serialized. It's a gsoap bug. Please switch to the dev branch with a more recent gsoap version.