@@ -6,6 +6,7 @@ mod tests;
66use auth:: username_token:: UsernameToken ;
77use schema:: soap_envelope;
88use xmltree:: { Element , Namespace , XMLNode } ;
9+ use url:: Url ;
910
1011const 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