From fca155b4208955075109a024c81a8037dd5a2ed6 Mon Sep 17 00:00:00 2001 From: Joe WOlfgrma Date: Sun, 7 Jul 2024 20:10:14 -0400 Subject: [PATCH 1/2] Fix for 400 error, needs additional header to work successfully --- onvif/src/soap/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 Date: Tue, 22 Oct 2024 04:27:46 -0400 Subject: [PATCH 2/2] Need uri for fn --- onvif/src/soap/client.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onvif/src/soap/client.rs b/onvif/src/soap/client.rs index 5daa919..d50d1cd 100644 --- a/onvif/src/soap/client.rs +++ b/onvif/src/soap/client.rs @@ -208,7 +208,7 @@ impl Client { debug!(?auth_type, %redirections, "About to make request."); let soap_msg = - soap::soap(message, &username_token).map_err(|e| Error::Protocol(format!("{e:?}")))?; + soap::soap(message, &username_token, &uri).map_err(|e| Error::Protocol(format!("{e:?}")))?; let mut request = self .client