Soap Error: WSWS3147E: Error: no SOAPAction header!

本文讨论了在SOAP请求中遇到的错误提示'WSWS3147E: Error:noSOAPAction header!',主要原因是请求头中缺乏SOAPAction信息。通过在Java中添加此信息,可以成功解决该问题。

当soap请求的发出的时候,报如下错误:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soapenv:Header/>

<soapenv:Body>

<soapenv:Fault>

<faultcode>Client.NoSOAPAction</faultcode>

<faultstring>WSWS3147E: Error: no SOAPAction header!</faultstring>

</soapenv:Fault>

</soapenv:Body>

</soapenv:Envelope>

主要是因为在soap的请求头中缺少SOAPAction: "" 的信息,加上这个信息就可以了,

java中添加这条信息如下:


out.println("SOAPAction: \"\"");




根据httpd模块中http/https服务还有onvif模块事件服务的实现,原onvif模块只支持http不支持https,所以我给该模块提供了tls支持,已经对代码做了一些修改,目前事件订阅上pull-point正常但是basic-notify接口测试不通过,为什么其他功能都正常唯独basic notify会报错?为什么http连接下basic notify接口测试正常但是https连接下会报错?能不能详细分析一下pull-point和basic-notify的处理流程?以及究竟是什么地方出了问题会导致该错误?不能分析出具体原因的话也请给出详细的调试方法(比如说应该在什么地方/步骤加log),以下分别为http和https连接下basic notify接口测试时终端的log: [2025-10-25 21:31:32] [ERROR] http_handle():554 - [HTTPD]HTTP_HANDLE [2025-10-25 21:31:32] [ERROR] socket_handle():446 - [HTTPD]SOCKET_HANDLE STRAT [2025-10-25 21:31:32] [ERROR] socket_handle():447 - [HTTPD]sock: 36 [2025-10-25 21:31:32] [ERROR] socket_handle():543 - [HTTPD]SOCKET_HANDLE SUCCESS [2025-10-25 21:31:32] [ERROR] match_group_port():157 - [HTTPD]match_group_port: port=2020, group=3 [2025-10-25 21:31:32] [ERROR] http_post_handle():2321 - [HTTPD]http_post_handle [2025-10-25 21:31:32] [ERROR] onvif_proc_data_srv():380 - [ONVIF]context->is_https = 0, context->is_ssl_success = 0 [2025-10-25 21:31:32] [ERROR] onvif_proc_data_srv():411 - [ONVIF]not digest header [2025-10-25 21:31:32] [ERROR] onvif_proc_data_srv():457 - [ONVIF]soap->is_https = 0 [2025-10-25 21:31:32] [ERROR] soap_get_namespace():460 - [ONVIF]Not a namespace: Type [2025-10-25 21:31:32] [ERROR] soap_out_tds_get_services_rsp():264 - [ONVIF]x_addr:http://192.168.137.165:2020/onvif/service [2025-10-25 21:31:32] [ERROR] onvif_make_response():529 - [ONVIF]context->is_https = 0 [2025-10-25 21:31:32] [ERROR] onvif_make_response():559 - [ONVIF]Onvif_make_response return onvif_send_http_rsp_packet. [2025-10-25 21:31:32] [ERROR] http_send_onvif_rsp_header():91 - [ONVIF]HTTP Response Header: HTTP/1.1 200 OK Connection: close Content-Type: application/soap+xml; charset=utf-8 Content-Length: 3351 [2025-10-25 21:31:32] [ERROR] http_send_block():163 - [HTTPD]Use HTTP [2025-10-25 21:31:32] [ERROR] http_send_onvif_content():140 - [ONVIF]ONVIF Message Content (Length: 3351): <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><tds:GetServicesResponse><tds:Service><tds:Namespace>http://www.onvif.org/ver10/device/wsdl</tds:Namespace><tds:XAddr>http://192.168.137.165:2020/onvif/service</tds:XAddr><tds:Version><tt:Major>2</tt:Major><tt:Minor>20</tt:Minor></tds:Version></tds:Service><tds:Service><tds:Namespace>http://www.onvif.org/ver10/media/wsdl</tds:Namespace><tds:XAddr>http://192.168.137.165:2020/onvif/service</tds:XAddr><tds:Version><tt:Major>2</tt:Major><tt:Minor>20</tt:Minor></tds:Version></tds:Service><tds:Service><tds:Namespace>http://www.onvif.org/ver10/events/wsdl</tds:Namespace><tds:XAddr>http://192.168.137.165:2020/onvif/service</tds:XAddr><tds:Version><tt:Major>2</tt:Major><tt:Minor>20</tt:Minor></tds:Version></tds:Service><tds:Service><tds:Namespace>http://www.onvif.org/ver20/analytics/wsdl</tds:Namespace><tds:XAddr>http://192.168.137.165:2020/onvif/service</tds:XAddr><tds:Version><tt:Major>2</tt:Major><tt:Minor>20</tt:Minor></tds:Version></tds:Service><tds:Service><tds:Namespace>http://www.onvif.org/ver20/imaging/wsdl</tds:Namespace><tds:XAddr>http://192.168.137.165:2020/onvif/service</tds:XAddr><tds:Version><tt:Major>2</tt:Major><tt:Minor>20</tt:Minor></tds:Version></tds:Service><tds:Service><tds:Namespace>http://www.onvif.org/ver20/ptz/wsdl</tds:Namespace><tds:XAddr>http://192.168.137.165:2020/onvif/service</tds:XAddr><tds:Version><tt:Major>2</tt:Major><tt:Minor>20</tt:Minor></tds:Version></tds:Service><tds:Service><tds:Namespace>http://www.onvif.org/ver10/deviceIO/wsdl</tds:Namespace><tds:XAddr>http://192.168.137.165:2020/onvif/service</tds:XAddr><tds:Version><tt:Major>2</tt:Major><tt:Minor>20</tt:Minor></tds:Version></tds:Service></tds:GetServicesResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> [2025-10-25 21:31:32] [ERROR] http_send_block():163 - [HTTPD]Use HTTP [2025-10-25 21:31:32] tcp_connect_timeout_handle():548 - [tpssl][89366.535]ip:3.0.247.235 ssl connecting --> ssl connected. [2025-10-25 21:31:32] [ERROR] http_handle():554 - [HTTPD]HTTP_HANDLE [2025-10-25 21:31:32] [ERROR] socket_handle():446 - [HTTPD]SOCKET_HANDLE STRAT [2025-10-25 21:31:32] [ERROR] socket_handle():447 - [HTTPD]sock: 36 [2025-10-25 21:31:32] [ERROR] socket_handle():543 - [HTTPD]SOCKET_HANDLE SUCCESS [2025-10-25 21:31:32] [ERROR] match_group_port():157 - [HTTPD]match_group_port: port=2020, group=3 [2025-10-25 21:31:32] [ERROR][CloudIot]cloud_iot_ipc.c:3017(http_auth_recv_cb) - HTTP Status Code: 403, not OK payload: {"code":10006,"message":"[1b48a93361fc469286147e1c6d7eac4e.459.17613990931790477] your deviceId is invalid, or not registered in current tp-cloud, please check it"} [2025-10-25 21:31:32] [ERROR] http_auth_recv_cb():3145 - [CloudIot]http parse err: -2, retry 256s [2025-10-25 21:31:32] [ERROR][CloudIot]cloud_iot_ipc.c:3201(cloud_http_message_handler) - HTTP resp handle failed, reqType: 0. [2025-10-25 21:31:32] [ERROR] http_post_handle():2321 - [HTTPD]http_post_handle [2025-10-25 21:31:32] [ERROR] onvif_proc_data_srv():380 - [ONVIF]context->is_https = 0, context->is_ssl_success = 0 [2025-10-25 21:31:32] [ERROR] onvif_proc_data_srv():411 - [ONVIF]not digest header [2025-10-25 21:31:32] [ERROR] onvif_proc_data_srv():457 - [ONVIF]soap->is_https = 0 [2025-10-25 21:31:32] [ERROR] soap_get_namespace():460 - [ONVIF]Not a namespace: s:mustUnderstand [2025-10-25 21:31:32] [ERROR] soap_get_namespace():460 - [ONVIF]Not a namespace: Type [2025-10-25 21:31:32] [ERROR] soap_get_namespace():460 - [ONVIF]Not a namespace: s:mustUnderstand [ONVIF Test] Using third_account to auth [2025-10-25 21:31:32] [ERROR] soap_subscribe():1826 - [ONVIF]protocol = http, port = 2020 [2025-10-25 21:31:32] [ERROR] soap_subscribe():1832 - [ONVIF]prototol = http, port = 2020 [2025-10-25 21:31:32] [ERROR] onvif_make_response():529 - [ONVIF]context->is_https = 0 [2025-10-25 21:31:32] [ERROR] onvif_make_response():559 - [ONVIF]Onvif_make_response return onvif_send_http_rsp_packet. [2025-10-25 21:31:32] [ERROR] http_send_onvif_rsp_header():91 - [ONVIF]HTTP Response Header: HTTP/1.1 200 OK Connection: close Content-Type: application/soap+xml; charset=utf-8 Content-Length: 2272 [2025-10-25 21:31:32] [ERROR] http_send_block():163 - [HTTPD]Use HTTP [2025-10-25 21:31:32] [ERROR] http_send_onvif_content():140 - [ONVIF]ONVIF Message Content (Length: 2272): <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl"><SOAP-ENV:Header><wsa5:MessageID>urn:uuid:f8e1609a-f789-420a-8cf4-a6dbc2bbdb76</wsa5:MessageID><wsa5:To SOAP-ENV:mustUnderstand="true">http://192.168.137.165:2020/onvif/service</wsa5:To><wsa5:Action SOAP-ENV:mustUnderstand="true">http://docs.oasis-open.org/wsn/bw-2/NotificationProducer/SubscribeResponse</wsa5:Action></SOAP-ENV:Header><SOAP-ENV:Body><wsnt:SubscribeResponse><wsnt:SubscriptionReference><wsa5:Address>http://192.168.137.165:2020/event-0_2020</wsa5:Address></wsnt:SubscriptionReference><wsnt:CurrentTime>2025-10-25T13:31:32Z</wsnt:CurrentTime><wsnt:TerminationTime>2025-10-25T13:31:42Z</wsnt:TerminationTime></wsnt:SubscribeResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> [2025-10-25 21:31:32] [ERROR] http_send_block():163 - [HTTPD]Use HTTP [2025-10-25 21:31:33] [ERROR] http_handle():554 - [HTTPD]HTTP_HANDLE [2025-10-25 21:31:33] [ERROR] socket_handle():446 - [HTTPD]SOCKET_HANDLE STRAT [2025-10-25 21:31:33] [ERROR] socket_handle():447 - [HTTPD]sock: 36 [2025-10-25 21:31:33] [ERROR] socket_handle():543 - [HTTPD]SOCKET_HANDLE SUCCESS [2025-10-25 21:31:33] [ERROR] match_group_port():157 - [HTTPD]match_group_port: port=2020, group=3 [2025-10-25 21:31:33] [ERROR] http_post_handle():2321 - [HTTPD]http_post_handle [2025-10-25 21:31:33] [ERROR] onvif_proc_data_srv():380 - [ONVIF]context->is_https = 0, context->is_ssl_success = 0 [2025-10-25 21:31:33] [ERROR] onvif_proc_data_srv():411 - [ONVIF]not digest header [2025-10-25 21:31:33] [ERROR] onvif_proc_data_srv():457 - [ONVIF]soap->is_https = 0 [2025-10-25 21:31:33] [ERROR] soap_get_namespace():460 - [ONVIF]Not a namespace: s:mustUnderstand [2025-10-25 21:31:33] [ERROR] soap_get_namespace():460 - [ONVIF]Not a namespace: Type [2025-10-25 21:31:33] [ERROR] soap_get_namespace():460 - [ONVIF]Not a namespace: s:mustUnderstand [ONVIF Test] Using third_account to auth [2025-10-25 21:31:33] [ERROR] onvif_make_response():529 - [ONVIF]context->is_https = 0 [2025-10-25 21:31:33] [ERROR] onvif_make_response():559 - [ONVIF]Onvif_make_response return onvif_send_http_rsp_packet. [2025-10-25 21:31:33] [ERROR] http_send_onvif_rsp_header():91 - [ONVIF]HTTP Response Header: HTTP/1.1 200 OK Connection: close Content-Type: application/soap+xml; charset=utf-8 Content-Length: 2028 [2025-10-25 21:31:33] [ERROR] http_send_block():163 - [HTTPD]Use HTTP [2025-10-25 21:31:33] [ERROR] http_send_onvif_content():140 - [ONVIF]ONVIF Message Content (Length: 2028): <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl"><SOAP-ENV:Header><wsa5:MessageID>urn:uuid:29bf73e3-8e2b-4532-8989-4ad121a2dd10</wsa5:MessageID><wsa5:To SOAP-ENV:mustUnderstand="true">http://192.168.137.165:2020/event-0_2020</wsa5:To><wsa5:Action SOAP-ENV:mustUnderstand="true">http://docs.oasis-open.org/wsn/bw-2/SubscriptionManager/UnsubscribeResponse</wsa5:Action></SOAP-ENV:Header><SOAP-ENV:Body><wsnt:UnsubscribeResponse></wsnt:UnsubscribeResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> [2025-10-25 21:31:33] [ERROR] http_send_block():163 - [HTTPD]Use HTTP [2025-10-25 21:33:01] [ERROR] https_handle():568 - [HTTPD]HTTPS_HANDLE [2025-10-25 21:33:01] [ERROR] socket_handle():446 - [HTTPD]SOCKET_HANDLE STRAT [2025-10-25 21:33:01] [ERROR] socket_handle():447 - [HTTPD]sock: 30 [2025-10-25 21:33:01] [ERROR] socket_handle():543 - [HTTPD]SOCKET_HANDLE SUCCESS [2025-10-25 21:33:01] [ERROR] https_handle():604 - [HTTPD]ret = -0x6900 [2025-10-25 21:33:01] [ERROR] match_group_port():157 - [HTTPD]match_group_port: port=443, group=1 [2025-10-25 21:33:01] [ERROR] http_call_handle():353 - [HTTPD]is_https is 1, is_ssl_success is 0 [2025-10-25 21:33:01] [ERROR] http_call_handle():357 - [HTTPD]ssl handshake fail, ssl handshake num 0, continue. [2025-10-25 21:33:01] [ERROR] http_read_line():1018 - [HTTPD]http_recv_block fail, ret: RESERVE. [2025-10-25 21:33:01] [ERROR] http_call_handle():377 - [HTTPD]context parser reserve. [2025-10-25 21:33:01] [ERROR] http_post_handle():2321 - [HTTPD]http_post_handle [2025-10-25 21:33:01] [ERROR] http_post_handle():2471 - [HTTPD]context->group_srv = GROUP_ONVIF_HTTPS [2025-10-25 21:33:01] [ERROR] http_post_handle():2472 - [HTTPD]Request form 443 to onvif [2025-10-25 21:33:01] [ERROR] onvif_proc_data_srv():380 - [ONVIF]context->is_https = 1, context->is_ssl_success = 1 [2025-10-25 21:33:01] [ERROR] onvif_proc_data_srv():383 - [ONVIF]SSL handshake sUccess [2025-10-25 21:33:01] [ERROR] onvif_proc_data_srv():411 - [ONVIF]not digest header [2025-10-25 21:33:01] [ERROR] onvif_proc_data_srv():457 - [ONVIF]soap->is_https = 1 [2025-10-25 21:33:01] [ERROR] soap_get_namespace():460 - [ONVIF]Not a namespace: Type [2025-10-25 21:33:01] [ERROR] soap_out_tds_get_services_rsp1():370 - [ONVIF]x_addr:https://192.168.137.165:443/onvif/service [2025-10-25 21:33:01] [ERROR] onvif_make_response():529 - [ONVIF]context->is_https = 1 [2025-10-25 21:33:01] [ERROR] onvif_make_response():559 - [ONVIF]Onvif_make_response return onvif_send_http_rsp_packet. [2025-10-25 21:33:01] [ERROR] http_send_onvif_rsp_header():91 - [ONVIF]HTTP Response Header: HTTP/1.1 200 OK Connection: close Content-Type: application/soap+xml; charset=utf-8 Content-Length: 3351 [2025-10-25 21:33:01] [ERROR] http_send_block():146 - [HTTPD]Use HTTPS [2025-10-25 21:33:01] [ERROR] http_send_onvif_content():140 - [ONVIF]ONVIF Message Content (Length: 3351): <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><tds:GetServicesResponse><tds:Service><tds:Namespace>http://www.onvif.org/ver10/device/wsdl</tds:Namespace><tds:XAddr>https://192.168.137.165:443/onvif/service</tds:XAddr><tds:Version><tt:Major>2</tt:Major><tt:Minor>20</tt:Minor></tds:Version></tds:Service><tds:Service><tds:Namespace>http://www.onvif.org/ver10/media/wsdl</tds:Namespace><tds:XAddr>https://192.168.137.165:443/onvif/service</tds:XAddr><tds:Version><tt:Major>2</tt:Major><tt:Minor>20</tt:Minor></tds:Version></tds:Service><tds:Service><tds:Namespace>http://www.onvif.org/ver10/events/wsdl</tds:Namespace><tds:XAddr>https://192.168.137.165:443/onvif/service</tds:XAddr><tds:Version><tt:Major>2</tt:Major><tt:Minor>20</tt:Minor></tds:Version></tds:Service><tds:Service><tds:Namespace>http://www.onvif.org/ver20/analytics/wsdl</tds:Namespace><tds:XAddr>https://192.168.137.165:443/onvif/service</tds:XAddr><tds:Version><tt:Major>2</tt:Major><tt:Minor>20</tt:Minor></tds:Version></tds:Service><tds:Service><tds:Namespace>http://www.onvif.org/ver20/imaging/wsdl</tds:Namespace><tds:XAddr>https://192.168.137.165:443/onvif/service</tds:XAddr><tds:Version><tt:Major>2</tt:Major><tt:Minor>20</tt:Minor></tds:Version></tds:Service><tds:Service><tds:Namespace>http://www.onvif.org/ver20/ptz/wsdl</tds:Namespace><tds:XAddr>https://192.168.137.165:443/onvif/service</tds:XAddr><tds:Version><tt:Major>2</tt:Major><tt:Minor>20</tt:Minor></tds:Version></tds:Service><tds:Service><tds:Namespace>http://www.onvif.org/ver10/deviceIO/wsdl</tds:Namespace><tds:XAddr>https://192.168.137.165:443/onvif/service</tds:XAddr><tds:Version><tt:Major>2</tt:Major><tt:Minor>20</tt:Minor></tds:Version></tds:Service></tds:GetServicesResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> [2025-10-25 21:33:02] [ERROR] http_send_block():146 - [HTTPD]Use HTTPS [2025-10-25 21:33:02] [ERROR] https_handle():568 - [HTTPD]HTTPS_HANDLE [2025-10-25 21:33:02] [ERROR] socket_handle():446 - [HTTPD]SOCKET_HANDLE STRAT [2025-10-25 21:33:02] [ERROR] socket_handle():447 - [HTTPD]sock: 30 [2025-10-25 21:33:02] [ERROR] socket_handle():543 - [HTTPD]SOCKET_HANDLE SUCCESS [2025-10-25 21:33:02] [ERROR] https_handle():604 - [HTTPD]ret = -0x6900 [2025-10-25 21:33:02] [ERROR] match_group_port():157 - [HTTPD]match_group_port: port=443, group=1 [2025-10-25 21:33:02] [ERROR] http_call_handle():353 - [HTTPD]is_https is 1, is_ssl_success is 0 [2025-10-25 21:33:02] [ERROR] http_call_handle():357 - [HTTPD]ssl handshake fail, ssl handshake num 0, continue. [2025-10-25 21:33:02] [ERROR] http_call_handle():366 - [HTTPD]tpssl_svr_handshake err ret: -0x7900, free context. [2025-10-25 21:33:03] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200 [2025-10-25 21:33:05] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200 [2025-10-25 21:33:07] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200 [2025-10-25 21:33:08] [ERROR] wlan_timer_handle():3229 - detect wlan0 bridging, no need to handle! [2025-10-25 21:33:09] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200 [2025-10-25 21:33:11] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200 [2025-10-25 21:33:13] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200 [2025-10-25 21:33:15] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200 [2025-10-25 21:33:17] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200 [2025-10-25 21:33:19] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200 [2025-10-25 21:33:21] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200 [2025-10-25 21:33:23] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200 [2025-10-25 21:33:25] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200 [2025-10-25 21:33:27] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200 [2025-10-25 21:33:29] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200 [2025-10-25 21:33:31] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200 [2025-10-25 21:33:32] [ERROR] https_handle():568 - [HTTPD]HTTPS_HANDLE [2025-10-25 21:33:32] [ERROR] socket_handle():446 - [HTTPD]SOCKET_HANDLE STRAT [2025-10-25 21:33:32] [ERROR] socket_handle():447 - [HTTPD]sock: 30 [2025-10-25 21:33:32] [ERROR] socket_handle():543 - [HTTPD]SOCKET_HANDLE SUCCESS [2025-10-25 21:33:32] [ERROR] https_handle():604 - [HTTPD]ret = -0x6900 [2025-10-25 21:33:32] [ERROR] match_group_port():157 - [HTTPD]match_group_port: port=443, group=1 [2025-10-25 21:33:32] [ERROR] http_call_handle():353 - [HTTPD]is_https is 1, is_ssl_success is 0 [2025-10-25 21:33:32] [ERROR] http_call_handle():357 - [HTTPD]ssl handshake fail, ssl handshake num 0, continue. [2025-10-25 21:33:32] [ERROR] http_call_handle():366 - [HTTPD]tpssl_svr_handshake err ret: -0x7900, free context. [2025-10-25 21:33:33] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200 [2025-10-25 21:33:35] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200 [2025-10-25 21:33:37] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200 [2025-10-25 21:33:39] [ERROR][tapoCare]tapo_care.c:275(attach_tapocare_ringbuffer) - ringbuffer_attach error: rb_id:10200
最新发布
10-27
我在onvif模块中实现了事件订阅功能,但通过onvif官方测试工具进行测试时发现除了GetEventProperties和GetServiceCapabilities能返回200 OK外,其他接口包括CreatPullPointSubcription、PullMessages、Renew、SetSynchronizationPoint和Unsubscribe都返回了400 Bad Request:HTTP/1.1 400 Bad Request Connection: close Content-Type: application/soap+xml; charset=utf-8 Content-Length: 2096 <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl"> <SOAP-ENV:Header> <wsa5:Action SOAP-ENV:mustUnderstand="true">http://www.onvif.org/ver10/events/wsdl/PullPointSubscription/PullMessagesRequest</wsa5:Action> </SOAP-ENV:Header> <SOAP-ENV:Body> <SOAP-ENV:Fault> <SOAP-ENV:Code> <SOAP-ENV:Value>SOAP-ENV:Sender</SOAP-ENV:Value> <SOAP-ENV:Subcode> <SOAP-ENV:Value>ter:InvalidArgVal</SOAP-ENV:Value> </SOAP-ENV:Subcode> </SOAP-ENV:Code> <SOAP-ENV:Reason> <SOAP-ENV:Text xml:lang="en">error</SOAP-ENV:Text> </SOAP-ENV:Reason> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope> _请根据我前面发给你的相关代码soap_event.c和soap_tev.c分析代码中是否有实现相应接口及报错400 Bad Request的最大可能问题是什么?
10-18
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="urn:rmyy:service" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" targetNamespace="urn:rmyy:service"> <wsdl:documentation>rmyy</wsdl:documentation> <wsdl:types> <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="urn:rmyy:service"> <xs:element name="rmyyService"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="userName" nillable="true" type="xs:string"/> <xs:element minOccurs="0" name="password" nillable="true" type="xs:string"/> <xs:element minOccurs="0" name="svcCode" nillable="true" type="xs:string"/> <xs:element minOccurs="0" name="inputXml" nillable="true" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="rmyyServiceResponse"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> </wsdl:types> <wsdl:message name="rmyyServiceRequest"> <wsdl:part name="parameters" element="ns:rmyyService"/> </wsdl:message> <wsdl:message name="rmyyServiceResponse"> <wsdl:part name="parameters" element="ns:rmyyServiceResponse"/> </wsdl:message> <wsdl:portType name="rmyyPortType"> <wsdl:operation name="rmyyService"> <wsdl:input message="ns:rmyyServiceRequest" wsaw:Action="urn:rmyyService"/> <wsdl:output message="ns:rmyyServiceResponse" wsaw:Action="urn:rmyyServiceResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="rmyySoap11Binding" type="ns:rmyyPortType"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <wsdl:operation name="rmyyService"> <soap:operation soapAction="urn:rmyyService" style="document"/> <wsdl:input> <soap:body use="literal"/> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:binding name="rmyySoap12Binding" type="ns:rmyyPortType"> <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <wsdl:operation name="rmyyService"> <soap12:operation soapAction="urn:rmyyService" style="document"/> <wsdl:input> <soap12:body use="literal"/> </wsdl:input> <wsdl:output> <soap12:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:binding name="rmyyHttpBinding" type="ns:rmyyPortType"> <http:binding verb="POST"/> <wsdl:operation name="rmyyService"> <http:operation location="rmyyService"/> <wsdl:input> <mime:content type="application/xml" part="parameters"/> </wsdl:input> <wsdl:output> <mime:content type="application/xml" part="parameters"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="rmyy"> <wsdl:port name="rmyyHttpSoap11Endpoint" binding="ns:rmyySoap11Binding"> <soap:address location="http://172.17.0.87:8090/ws/services/rmyy.rmyyHttpSoap11Endpoint/"/> </wsdl:port> <wsdl:port name="rmyyHttpSoap12Endpoint" binding="ns:rmyySoap12Binding"> <soap12:address location="http://172.17.0.87:8090/ws/services/rmyy.rmyyHttpSoap12Endpoint/"/> </wsdl:port> <wsdl:port name="rmyyHttpEndpoint" binding="ns:rmyyHttpBinding"> <http:address location="http://172.17.0.87:8090/ws/services/rmyy.rmyyHttpEndpoint/"/> </wsdl:port> </wsdl:service> </wsdl:definitions>怎么在postman请求这个接口
06-25
#include <assert.h> #include "soapH.h" //#include "wsdd.nsmap" #include "soapStub.h" #include "wsseapi.h" #include "wsaapi.h" #include <map> #define USERNAME "admin" #define PASSWORD "admin888" #define MEDIA_GET_PROFILES_ACTION "http://www.onvif.org/ver10/media/wsdl/GetProfiles". #define SOAP_ASSERT assert #define SOAP_DBGLOG printf #define SOAP_DBGERR printf #define SOAP_TO "urn:schemas-xmlsoap-org:ws:2005:04:discovery" #define SOAP_ACTION "http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe" #define SOAP_MCAST_ADDR "soap.udp://239.255.255.250:3702" // onvif规定的组播地址 #define SOAP_ITEM "" // 寻找的设备范围 #define SOAP_TYPES "dn:NetworkVideoTransmitter" // 寻找的设备类型 #define SOAP_SOCK_TIMEOUT (3) // socket超时时间(单秒秒) #define ONVIF_ADDRESS_SIZE (128) // URI地址长度 #define ONVIF_TOKEN_SIZE (65) // token长度 #define SOAP_CHECK_ERROR(result, soap, str) \ do { \ if (SOAP_OK != (result) || SOAP_OK != (soap)->error) { \ soap_perror((soap), (str)); \ if (SOAP_OK == (result)) { \ (result) = (soap)->error; \ } \ goto EXIT; \ } \ } while (0) /* 视频编码器配置信息 */ struct tagVideoEncoderConfiguration { char token[ONVIF_TOKEN_SIZE]; // 唯一标识该视频编码器的令牌字符串 int Width; // 分辨率 int Height; }; /* 设备配置信息 */ struct tagProfile { char token[ONVIF_TOKEN_SIZE]; // 唯一标识设备配置文件的令牌字符串 struct tagVideoEncoderConfiguration venc; // 视频编码器配置信息 }; /* 设备能力信息 */ struct tagCapabilities { char MediaXAddr[ONVIF_ADDRESS_SIZE]; // 媒体服务地址 char EventXAddr[ONVIF_ADDRESS_SIZE]; // 事件服务地址 }; void soap_perror(struct soap* soap, const char* str) { if (nullptr == str) { SOAP_DBGERR("[soap] error: %d, %s, %s\n", soap->error, *soap_faultcode(soap), *soap_faultstring(soap)); } else { SOAP_DBGERR("[soap] %s error: %d, %s, %s\n", str, soap->error, *soap_faultcode(soap), *soap_faultstring(soap)); } } void* ONVIF_soap_malloc(struct soap* soap, unsigned int n) { void* p = nullptr; if (n > 0) { p = soap_malloc(soap, n); SOAP_ASSERT(nullptr != p); memset(p, 0x00, n); } return p; } struct soap* ONVIF_soap_new(int timeout) { struct soap* soap = nullptr; // soap环境变量 SOAP_ASSERT(nullptr != (soap = soap_new())); soap_set_namespaces(soap, namespaces); // 设置soap的namespaces soap->recv_timeout = timeout; // 设置超时(超过指定时间没有数据就退出) soap->send_timeout = timeout; soap->connect_timeout = timeout; #if defined(__linux__) || defined(__linux) // 参考https://www.genivia.com/dev.html#client-c的修改: soap->socket_flags = MSG_NOSIGNAL; // To prevent connection reset errors #endif soap_set_mode(soap, SOAP_C_UTFSTRING); // 设置为UTF-8编码,否则叠加中文OSD会乱码 return soap; } void ONVIF_soap_delete(struct soap* soap) { soap_destroy(soap); // remove deserialized class instances (C++ only) soap_end(soap); // Clean up deserialized data (except class instances) and temporary data soap_done(soap); // Reset, close communications, and remove callbacks soap_free(soap); // Reset and deallocate the context created with soap_new or soap_copy } /************************************************************************ **函数:ONVIF_init_header **功能:初始化soap描述消息头 **参数: [in] soap - soap环境变量 **返回:无 **备注: 1). 在本函数内部通过ONVIF_soap_malloc分配的内存,将在ONVIF_soap_delete中被释放 ************************************************************************/ void ONVIF_init_header(struct soap* soap) { struct SOAP_ENV__Header* header = nullptr; SOAP_ASSERT(nullptr != soap); header = (struct SOAP_ENV__Header*)ONVIF_soap_malloc(soap, sizeof(struct SOAP_ENV__Header)); soap_default_SOAP_ENV__Header(soap, header); header->wsa__MessageID = (char*)soap_wsa_rand_uuid(soap); header->wsa__To = (char*)ONVIF_soap_malloc(soap, strlen(SOAP_TO) + 1); header->wsa__Action = (char*)ONVIF_soap_malloc(soap, strlen(SOAP_ACTION) + 1); strcpy(header->wsa__To, SOAP_TO); strcpy(header->wsa__Action, SOAP_ACTION); soap->header = header; return; } /************************************************************************ **函数:ONVIF_init_ProbeType **功能:初始化探测设备的范围和类型 **参数: [in] soap - soap环境变量 [out] probe - 填充要探测的设备范围和类型 **返回: 0表明探测到,非0表明未探测到 **备注: 1). 在本函数内部通过ONVIF_soap_malloc分配的内存,将在ONVIF_soap_delete中被释放 ************************************************************************/ void ONVIF_init_ProbeType(struct soap* soap, struct wsdd__ProbeType* probe) { struct wsdd__ScopesType* scope = nullptr; // 用于描述查找哪类的Web服务 SOAP_ASSERT(nullptr != soap); SOAP_ASSERT(nullptr != probe); scope = (struct wsdd__ScopesType*)ONVIF_soap_malloc(soap, sizeof(struct wsdd__ScopesType)); soap_default_wsdd__ScopesType(soap, scope); // 设置寻找设备的范围 scope->__item = (char*)ONVIF_soap_malloc(soap, strlen(SOAP_ITEM) + 1); strcpy(scope->__item, SOAP_ITEM); memset(probe, 0x00, sizeof(struct wsdd__ProbeType)); soap_default_wsdd__ProbeType(soap, probe); probe->Scopes = scope; probe->Types = (char*)ONVIF_soap_malloc(soap, strlen(SOAP_TYPES) + 1); // 设置寻找设备的类型 strcpy(probe->Types, SOAP_TYPES); return; } void ONVIF_DetectDevice(void (*cb)(char* DeviceXAddr)) { int i; int result = 0; unsigned int count = 0; // 搜索到的设备个数 struct soap* soap = nullptr; // soap环境变量 struct wsdd__ProbeType req; // 用于发送Probe消息 struct __wsdd__ProbeMatches rep; // 用于接收Probe应答 struct wsdd__ProbeMatchType* probeMatch; SOAP_DBGLOG("Sending Probe message to multicast address...\n"); SOAP_ASSERT(nullptr != (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, nullptr, &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 { // 成功接收到设备的应答消息 if (nullptr != rep.wsdd__ProbeMatches) { count += rep.wsdd__ProbeMatches->__sizeProbeMatch; SOAP_DBGLOG("成功接收...\n"); for (i = 0; i < rep.wsdd__ProbeMatches->__sizeProbeMatch; i++) { probeMatch = rep.wsdd__ProbeMatches->ProbeMatch + i; if (nullptr != cb) { cb(probeMatch->XAddrs); // 使用设备服务地址执行函数回调 } } } } } else if (soap->error) { break; } } SOAP_DBGLOG("\ndetect end! It has detected %d devices!\n", count); if (nullptr != soap) { ONVIF_soap_delete(soap); } } /************************************************************************ **函数:ONVIF_SetAuthInfo **功能:设置认证信息 **参数: [in] soap - soap环境变量 [in] username - 用户名 [in] password - 密码 **返回: 0表明成功,非0表明失败 **备注: ************************************************************************/ static int ONVIF_SetAuthInfo(struct soap* soap, const char* username, const char* password) { int result = 0; SOAP_ASSERT(nullptr != USERNAME); SOAP_ASSERT(nullptr != PASSWORD); result = soap_wsse_add_UsernameTokenDigest(soap, nullptr, username, password); SOAP_CHECK_ERROR(result, soap, "add_UsernameTokenDigest"); EXIT: return result; } /************************************************************************ **函数:make_uri_withauth **功能:构造带有认证信息的URI地址 **参数: [in] src_uri - 未带认证信息的URI地址 [in] username - 用户名 [in] password - 密码 [out] dest_uri - 返回的带认证信息的URI地址 [in] size_dest_uri - dest_uri缓存大小 **返回: 0成功,非0失败 **备注: 1). 例子: 无认证信息的uri:rtsp://100.100.100.140:554/av0_0 带认证信息的uri:rtsp://username:password@100.100.100.140:554/av0_0 ************************************************************************/ static int make_uri_withauth(const std::string& src_uri, const std::string& username, const std::string& password, std::string* dest_uri) { int result = 0; unsigned int needBufSize = 0; SOAP_ASSERT(!src_uri.empty()); if (username.empty() && password.empty()) { // 生成新的uri地址 *dest_uri = src_uri; } else { std::string::size_type position = src_uri.find("//"); if (std::string::npos == position) { SOAP_DBGERR("can't found '//', src uri is: %s.\n", src_uri.c_str()); result = -1; return result; } position += 2; dest_uri->append(src_uri, 0, position); dest_uri->append(username + ":" + password + "@"); dest_uri->append(src_uri, position, std::string::npos); } return result; } /************************************************************************ **函数:ONVIF_GetDeviceInformation **功能:获取设备基本信息 **参数: [in] DeviceXAddr - 设备服务地址 **返回: 0表明成功,非0表明失败 **备注: ************************************************************************/ int ONVIF_GetDeviceInformation(const char* DeviceXAddr) { int result = 0; struct soap* soap = nullptr; _tds__GetDeviceInformation devinfo_req; _tds__GetDeviceInformationResponse devinfo_resp; SOAP_ASSERT(nullptr != DeviceXAddr); SOAP_ASSERT(nullptr != (soap = ONVIF_soap_new(SOAP_SOCK_TIMEOUT))); ONVIF_SetAuthInfo(soap, USERNAME, PASSWORD); result = soap_call___tds__GetDeviceInformation(soap, DeviceXAddr, nullptr, &devinfo_req, devinfo_resp); SOAP_CHECK_ERROR(result, soap, "GetDeviceInformation"); std::cout << " Manufacturer:\t" << devinfo_resp.Manufacturer << "\n"; std::cout << " Model:\t" << devinfo_resp.Model << "\n"; std::cout << " FirmwareVersion:\t" << devinfo_resp.FirmwareVersion << "\n"; std::cout << " SerialNumber:\t" << devinfo_resp.SerialNumber << "\n"; std::cout << " HardwareId:\t" << devinfo_resp.HardwareId << "\n"; EXIT: if (nullptr != soap) { ONVIF_soap_delete(soap); } return result; } /************************************************************************ **函数:ONVIF_GetCapabilities **功能:获取设备能力信息 **参数: [in] DeviceXAddr - 设备服务地址 [in] **返回: 0表明成功,非0表明失败 **备注: 1). 其中最主要的参数之一是媒体服务地址 ************************************************************************/ int ONVIF_GetCapabilities(const std::string& deviceXAddr, std::string* ptzXAddr) { int result = 0; struct soap* soap = nullptr; _tds__GetCapabilities devinfo_req; _tds__GetCapabilitiesResponse devinfo_resp; SOAP_ASSERT(!deviceXAddr.empty()); SOAP_ASSERT(nullptr != (soap = ONVIF_soap_new(SOAP_SOCK_TIMEOUT))); ONVIF_SetAuthInfo(soap, USERNAME, PASSWORD); result = soap_call___tds__GetCapabilities(soap, deviceXAddr.c_str(), nullptr, &devinfo_req, devinfo_resp); SOAP_CHECK_ERROR(result, soap, "GetCapabilities"); if (devinfo_resp.Capabilities->PTZ != nullptr) { *ptzXAddr = devinfo_resp.Capabilities->PTZ->XAddr; } EXIT: if (nullptr != soap) { ONVIF_soap_delete(soap); } return result; } int ONVIF_GetProfiles(const std::string& ptzXAddr, std::string* profilesToken) { int result = 0; struct soap* soap = nullptr; _trt__GetProfiles devinfo_req; _trt__GetProfilesResponse devinfo_resp; SOAP_ASSERT(!ptzXAddr.empty()); SOAP_ASSERT(nullptr != (soap = ONVIF_soap_new(SOAP_SOCK_TIMEOUT))); ONVIF_SetAuthInfo(soap, USERNAME, PASSWORD); result = soap_call___trt__GetProfiles(soap, ptzXAddr.c_str(), nullptr, &devinfo_req, devinfo_resp); SOAP_CHECK_ERROR(result, soap, "ONVIF_GetProfiles"); SOAP_ASSERT(!devinfo_resp.Profiles.empty()); *profilesToken = devinfo_resp.Profiles[0]->token; EXIT: if (nullptr != soap) { ONVIF_soap_delete(soap); } return result; } /************************************************************************ **函数:ONVIF_GetSnapshotUri **功能:获取设备图像抓拍地址(HTTP) **参数: [in] MediaXAddr - 媒体服务地址 [in] ProfileToken - the media profile token [out] uri - 返回的地址 [in] sizeuri - 地址缓存大小 **返回: 0表明成功,非0表明失败 **备注: 1). 并非所有的ProfileToken都支持图像抓拍地址。举例:XXX品牌的IPC有如下三个配置profile0/profile1/TestMediaProfile,其中TestMediaProfile返回的图像抓拍地址就是空指针。 ************************************************************************/ int ONVIF_GetSnapshotUri(const std::string& MediaXAddr, const std::string& ProfileToken, std::string* snapUri) { int result = 0; struct soap* soap = nullptr; _trt__GetSnapshotUri req; _trt__GetSnapshotUriResponse rep; // 检查参数合法性 if (MediaXAddr.empty() || ProfileToken.empty()) { SOAP_DBGERR("Invalid arguments\n"); return -1; } // 创建 SOAP 环境 soap = ONVIF_soap_new(SOAP_SOCK_TIMEOUT); if (!soap) { SOAP_DBGERR("Failed to create SOAP environment\n"); return -1; } // 设置认证信息 if (ONVIF_SetAuthInfo(soap, USERNAME, PASSWORD) != 0) { SOAP_DBGERR("Failed to set authentication info\n"); goto EXIT; } // 设置请求参数 memset(&req, 0, sizeof(req)); req.ProfileToken = soap_strdup(soap, ProfileToken.c_str()); // 调用服务 result = soap_call___trt__GetSnapshotUri(soap, MediaXAddr.c_str(), NULL, &req, rep); if (result != SOAP_OK || soap->error != SOAP_OK) { SOAP_DBGERR("GetSnapshotUri failed: %d, %s\n", soap->error, *soap_faultstring(soap)); result = -1; goto EXIT; } // 处理响应 - 使用正确的成员访问方式 if (rep.MediaUri) { *snapUri = rep.MediaUri->Uri; // Uri 是 std::string 类型,不需要指针检查 SOAP_DBGLOG("Snapshot URI: %s\n", snapUri->c_str()); } else { SOAP_DBGERR("MediaUri is null\n"); result = -1; } EXIT: // 清理资源 if (soap) { ONVIF_soap_delete(soap); } return result; } // 获取当前ptz的位置以及状态 int ONVIF_PTZ_GetStatus(const std::string& ptzXAddr, const std::string& ProfileToken) { int result = 0; struct soap* soap = nullptr; _tptz__GetStatus getStatus; _tptz__GetStatusResponse getStatusResponse; SOAP_ASSERT(!ptzXAddr.empty()); SOAP_ASSERT(nullptr != (soap = ONVIF_soap_new(SOAP_SOCK_TIMEOUT))); ONVIF_SetAuthInfo(soap, USERNAME, PASSWORD); getStatus.ProfileToken = const_cast<char*>(ProfileToken.c_str()); result = soap_call___tptz__GetStatus(soap, ptzXAddr.c_str(), nullptr, &getStatus, getStatusResponse); SOAP_CHECK_ERROR(result, soap, "ONVIF_PTZ_GetStatus"); if (*getStatusResponse.PTZStatus->MoveStatus->PanTilt == tt__MoveStatus__IDLE) { std::cout << " 空闲 ... " << std::endl; } else if (*getStatusResponse.PTZStatus->MoveStatus->PanTilt == tt__MoveStatus__MOVING) { std::cout << " 移动中 ... " << std::endl; } else if (*getStatusResponse.PTZStatus->MoveStatus->PanTilt == tt__MoveStatus__UNKNOWN) { std::cout << " 未知 ... " << std::endl; } std::cout << "当前p: " << getStatusResponse.PTZStatus->Position->PanTilt->x << "\n"; std::cout << "当前t: " << getStatusResponse.PTZStatus->Position->PanTilt->y << "\n"; std::cout << "当前z: " << getStatusResponse.PTZStatus->Position->Zoom->x << "\n"; EXIT: if (nullptr != soap) { ONVIF_soap_delete(soap); } return 0; } // 以指定速度移动到指定位置的ptz // p : -1 ~ 1 [] // t : -1 ~ 1 // z : 0 ~ 1 int ONVIF_PTZAbsoluteMove(const std::string& ptzXAddr, const std::string& ProfileToken) { int result = 0; struct soap* soap = nullptr; _tptz__AbsoluteMove absoluteMove; _tptz__AbsoluteMoveResponse absoluteMoveResponse; SOAP_ASSERT(!ptzXAddr.empty() && !ProfileToken.empty()); SOAP_ASSERT(nullptr != (soap = ONVIF_soap_new(SOAP_SOCK_TIMEOUT))); ONVIF_SetAuthInfo(soap, USERNAME, PASSWORD); absoluteMove.ProfileToken = const_cast<char*>(ProfileToken.c_str()); absoluteMove.Position = soap_new_tt__PTZVector(soap); absoluteMove.Position->PanTilt = soap_new_tt__Vector2D(soap); absoluteMove.Position->Zoom = soap_new_tt__Vector1D(soap); absoluteMove.Speed = soap_new_tt__PTZSpeed(soap); absoluteMove.Speed->PanTilt = soap_new_tt__Vector2D(soap); absoluteMove.Speed->Zoom = soap_new_tt__Vector1D(soap); absoluteMove.Position->PanTilt->x = 0.440833; // p absoluteMove.Position->PanTilt->y = 0.583455; // t absoluteMove.Position->Zoom->x = 0.0333333; // z // x 和y的绝对值越接近1,表示云台的速度越快 absoluteMove.Speed->PanTilt->x = 0.5; absoluteMove.Speed->PanTilt->y = 0.5; absoluteMove.Speed->Zoom->x = 0.5; result = soap_call___tptz__AbsoluteMove(soap, ptzXAddr.c_str(), nullptr, &absoluteMove, absoluteMoveResponse); SOAP_CHECK_ERROR(result, soap, "ONVIF_PTZAbsoluteMove"); EXIT: if (nullptr != soap) { ONVIF_soap_delete(soap); } return 0; } int ONVIF_PTZStopMove(const std::string& ptzXAddr, const std::string& ProfileToken) { int result = 0; struct soap* soap = nullptr; _tptz__Stop tptzStop; _tptz__StopResponse tptzStopResponse; SOAP_ASSERT(!ptzXAddr.empty() && !ProfileToken.empty()); SOAP_ASSERT(nullptr != (soap = ONVIF_soap_new(SOAP_SOCK_TIMEOUT))); ONVIF_SetAuthInfo(soap, USERNAME, PASSWORD); tptzStop.ProfileToken = const_cast<char*>(ProfileToken.c_str()); result = soap_call___tptz__Stop(soap, ptzXAddr.c_str(), nullptr, &tptzStop, tptzStopResponse); SOAP_CHECK_ERROR(result, soap, "ONVIF_PTZStopMove"); EXIT: if (nullptr != soap) { ONVIF_soap_delete(soap); } return result; } enum PTZCMD { PTZ_CMD_LEFT, PTZ_CMD_RIGHT, PTZ_CMD_UP, PTZ_CMD_DOWN, PTZ_CMD_LEFTUP, PTZ_CMD_LEFTDOWN, PTZ_CMD_RIGHTUP, PTZ_CMD_RIGHTDOWN, PTZ_CMD_ZOOM_IN, PTZ_CMD_ZOOM_OUT, }; // speed --> (0, 1] int ONVIF_PTZContinuousMove(const std::string& ptzXAddr, const std::string& ProfileToken, enum PTZCMD cmd, float speed) { int result = 0; struct soap* soap = nullptr; _tptz__ContinuousMove continuousMove; _tptz__ContinuousMoveResponse continuousMoveResponse; SOAP_ASSERT(!ptzXAddr.empty() && !ProfileToken.empty()); SOAP_ASSERT(nullptr != (soap = ONVIF_soap_new(SOAP_SOCK_TIMEOUT))); ONVIF_SetAuthInfo(soap, USERNAME, PASSWORD); continuousMove.ProfileToken = const_cast<char*>(ProfileToken.c_str()); continuousMove.Velocity = soap_new_tt__PTZSpeed(soap); continuousMove.Velocity->PanTilt = soap_new_tt__Vector2D(soap); continuousMove.Velocity->Zoom = soap_new_tt__Vector1D(soap); switch (cmd) { case PTZ_CMD_LEFT: continuousMove.Velocity->PanTilt->x = -speed; continuousMove.Velocity->PanTilt->y = 0; break; case PTZ_CMD_RIGHT: continuousMove.Velocity->PanTilt->x = speed; continuousMove.Velocity->PanTilt->y = 0; break; case PTZ_CMD_UP: continuousMove.Velocity->PanTilt->x = 0; continuousMove.Velocity->PanTilt->y = speed; break; case PTZ_CMD_DOWN: continuousMove.Velocity->PanTilt->x = 0; continuousMove.Velocity->PanTilt->y = -speed; break; case PTZ_CMD_LEFTUP: continuousMove.Velocity->PanTilt->x = -speed; continuousMove.Velocity->PanTilt->y = speed; break; case PTZ_CMD_LEFTDOWN: continuousMove.Velocity->PanTilt->x = -speed; continuousMove.Velocity->PanTilt->y = -speed; break; case PTZ_CMD_RIGHTUP: continuousMove.Velocity->PanTilt->x = speed; continuousMove.Velocity->PanTilt->y = speed; break; case PTZ_CMD_RIGHTDOWN: continuousMove.Velocity->PanTilt->x = speed; continuousMove.Velocity->PanTilt->y = -speed; break; case PTZ_CMD_ZOOM_IN: continuousMove.Velocity->PanTilt->x = 0; continuousMove.Velocity->PanTilt->y = 0; continuousMove.Velocity->Zoom->x = speed; break; case PTZ_CMD_ZOOM_OUT: continuousMove.Velocity->PanTilt->x = 0; continuousMove.Velocity->PanTilt->y = 0; continuousMove.Velocity->Zoom->x = -speed; break; default: break; } // 也可以使用soap_call___tptz__RelativeMove实现 result = soap_call___tptz__ContinuousMove(soap, ptzXAddr.c_str(), nullptr, &continuousMove, continuousMoveResponse); SOAP_CHECK_ERROR(result, soap, "ONVIF_PTZAbsoluteMove"); /* sleep(1); //如果当前soap被删除(或者发送stop指令),就会停止移动 ONVIF_PTZStopMove(ptzXAddr, ProfileToken);*/ EXIT: if (nullptr != soap) { ONVIF_soap_delete(soap); } return result; } void cb_discovery(char* deviceXAddr) { std::cout << "\n==== 发现设备: " << deviceXAddr << " ====" << std::endl; std::string ptzXAddr, profilesToken; // 获取设备能力信息 int ret = ONVIF_GetCapabilities(deviceXAddr, &ptzXAddr); if (ret != 0) { std::cerr << "错误: 获取设备能力失败 (错误码: " << ret << ")" << std::endl; return; } std::cout << " PTZ服务地址: " << ptzXAddr << std::endl; // 获取设备配置文件 ret = ONVIF_GetProfiles(ptzXAddr, &profilesToken); if (ret != 0) { std::cerr << "错误: 获取配置文件失败 (错误码: " << ret << ")" << std::endl; return; } std::cout << " Profile Token: " << profilesToken << std::endl; // 执行PTZ操作 ret = ONVIF_PTZContinuousMove(ptzXAddr, profilesToken, PTZ_CMD_LEFTUP, 0.3); if (ret != 0) { std::cerr << "错误: PTZ操作失败 (错误码: " << ret << ")" << std::endl; return; } // 停止PTZ操作 ret = ONVIF_PTZStopMove(ptzXAddr, profilesToken); if (ret != 0) { std::cerr << "错误: 停止PTZ操作失败 (错误码: " << ret << ")" << std::endl; } else { std::cout << " PTZ操作已停止" << std::endl; } } int main(int argc, char** argv) { ONVIF_DetectDevice(cb_discovery); return 0; } 获取配置文件失败
06-21
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值