Onvif Digest 验证方式代码编写

首先将Gsoap plugin目录下的md5evp.h, md5evp.c, httpda.h,httpda.c,threads.h,threads.c文件加入到项目工程中

在实际编写代码的cpp文件中引入头文件 #include “httpda.h”

在编译的过程中会提示soap_memcpy 和 SOAP_SNPRINTF的相关错误,只需要在gsoap下找到对应的声明添加到 stdsoap2.h即可

在使用WS-UsernameToken方式进行权限验证时,如果验证不通过,那么将会返回400错误。 在使用Digest方式进行权限验证时,如果验证不通过,那么将返回401错误。

soap_call___ns_method(&soap, ...);
if (soap.status == 400)
    {
        soap_register_plugin(&soap, http_da);
        soap.userid = "username";
        soap.passwd = "password";
        soap_call___ns_method(&soap, ...);
        if (soap.status == 401)
        {
            struct http_da_info info; // to store userid and passwd
            //soap.authrealm在验证失败从服务器返回
            http_da_save(&soap, &info, soap.authrealm, "username", "password");
            soap_call___ns_method(&soap, ...);
            http_da_restore(&soap, &info);
            http_da_release(&soap, &info);
        }
    }

大多设备支持ws-usernameToken方式,少些设备不支持,当权限验证存在冲突时则需要兼容处理。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值