Skip to content

Commit 467087d

Browse files
Joe WOlfgrmaJoe WOlfgrma
Joe WOlfgrma
authored and
Joe WOlfgrma
committed
Fix for 400 error, needs additional header to work successfully
1 parent 1b1e6fd commit 467087d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

onvif/src/soap/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ impl Client {
214214
"About to make request. auth_type={:?}, redirections={}", auth_type, redirections
215215
);
216216

217-
let soap_msg = soap::soap(message, &username_token)
217+
let soap_msg = soap::soap(message, &username_token, &uri)
218218
.map_err(|e| Error::Protocol(format!("{:?}", e)))?;
219219

220220
let mut request = self

onvif/src/soap/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mod tests;
66
use auth::username_token::UsernameToken;
77
use schema::soap_envelope;
88
use xmltree::{Element, Namespace, XMLNode};
9+
use url::Url;
910

1011
const SOAP_URI: &str = "http://www.w3.org/2003/05/soap-envelope";
1112

@@ -24,11 +25,12 @@ pub struct Response {
2425
pub response: Option<String>,
2526
}
2627

27-
pub fn soap(xml: &str, username_token: &Option<UsernameToken>) -> Result<String, Error> {
28+
pub fn soap(xml: &str, username_token: &Option<UsernameToken>, uri: &Url) -> Result<String, Error> {
2829
let app_data = parse(xml)?;
2930

3031
let mut namespaces = app_data.namespaces.clone().unwrap_or_else(Namespace::empty);
3132
namespaces.put("s", SOAP_URI);
33+
namespaces.put("a", "http://www.w3.org/2005/08/addressing");
3234

3335
let mut body = Element::new("Body");
3436
body.prefix = Some("s".to_string());
@@ -44,6 +46,10 @@ pub fn soap(xml: &str, username_token: &Option<UsernameToken>) -> Result<String,
4446
header
4547
.children
4648
.push(XMLNode::Element(parse(&username_token.to_xml())?));
49+
let mut to_el = Element::new("To");
50+
to_el.prefix = Some("a".to_string());
51+
to_el.children.push(XMLNode::Text(uri.as_str().to_owned()));
52+
header.children.push(XMLNode::Element(to_el));
4753
envelope.children.push(XMLNode::Element(header));
4854
}
4955

0 commit comments

Comments
 (0)