From b8e0e31ab0e122231e2560c0bc87ca891d2d3405 Mon Sep 17 00:00:00 2001 From: Joe WOlfgrma Date: Sun, 7 Jul 2024 20:10:14 -0400 Subject: [PATCH] Fix for 400 error, needs additional header to work successfully --- onvif/src/soap/client.rs | 2 +- onvif/src/soap/mod.rs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/onvif/src/soap/client.rs b/onvif/src/soap/client.rs index f8d2dc7..62ae1e1 100644 --- a/onvif/src/soap/client.rs +++ b/onvif/src/soap/client.rs @@ -214,7 +214,7 @@ impl Client { "About to make request. auth_type={:?}, redirections={}", auth_type, redirections ); - let soap_msg = soap::soap(message, &username_token) + let soap_msg = soap::soap(message, &username_token, &uri) .map_err(|e| Error::Protocol(format!("{:?}", e)))?; let mut request = self diff --git a/onvif/src/soap/mod.rs b/onvif/src/soap/mod.rs index 4a0c6ab..b86ceba 100644 --- a/onvif/src/soap/mod.rs +++ b/onvif/src/soap/mod.rs @@ -6,6 +6,7 @@ mod tests; use auth::username_token::UsernameToken; use schema::soap_envelope; use xmltree::{Element, Namespace, XMLNode}; +use url::Url; const SOAP_URI: &str = "http://www.w3.org/2003/05/soap-envelope"; @@ -24,11 +25,12 @@ pub struct Response { pub response: Option, } -pub fn soap(xml: &str, username_token: &Option) -> Result { +pub fn soap(xml: &str, username_token: &Option, uri: &Url) -> Result { let app_data = parse(xml)?; let mut namespaces = app_data.namespaces.clone().unwrap_or_else(Namespace::empty); namespaces.put("s", SOAP_URI); + namespaces.put("a", "http://www.w3.org/2005/08/addressing"); let mut body = Element::new("Body"); body.prefix = Some("s".to_string()); @@ -44,6 +46,10 @@ pub fn soap(xml: &str, username_token: &Option) -> Result