Rust
Rust
HTTP SOAP 1.2 Request and Response using POST
See more HTTP Examples
Demonstrates a working SOAP 1.2 request and response using POST with a live server. You may try running this example with the URLs and data provided. See http://wsf.cdyne.com/WeatherWS/Weather.asmx?op=GetCityWeatherByZIP for details.Note: This example is correct in theory, but no longer works for live testing because the SOAP service provider (cdyne.com) has made changes or discontinued the free service.
Chilkat Rust Downloads
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// --------------------------------------------------------------------------------
// Also see Chilkat's Online WSDL Code Generator
// to generate code and SOAP Request and Response XML for each operation in a WSDL.
// --------------------------------------------------------------------------------
let http = chilkat::Http::new();
let soap_xml = chilkat::Xml::new();
soap_xml.set_tag("soap12:Envelope");
let _ = soap_xml.add_attribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").is_ok();
let _ = soap_xml.add_attribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema").is_ok();
let _ = soap_xml.add_attribute("xmlns:soap12", "http://www.w3.org/2003/05/soap-envelope").is_ok();
soap_xml.new_child2("soap12:Body", "");
let _ = soap_xml.get_child2(0).is_ok();
soap_xml.new_child2("GetCityWeatherByZIP", "");
let _ = soap_xml.get_child2(0).is_ok();
let _ = soap_xml.add_attribute("xmlns", "http://ws.cdyne.com/WeatherWS/").is_ok();
soap_xml.new_child2("ZIP", "60187");
soap_xml.get_root2();
println!("{}", soap_xml.get_xml().unwrap_or_default());
let req = chilkat::HttpRequest::new();
req.set_http_verb("POST");
req.set_send_charset(false);
req.add_header("Content-Type", "application/soap+xml; charset=utf-8");
req.add_header("SOAPAction", "http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP");
req.set_path("/WeatherWS/Weather.asmx");
let _ = req.load_body_from_string(&soap_xml.get_xml().unwrap_or_default(), "utf-8").is_ok();
http.set_follow_redirects(true);
let resp = chilkat::HttpResponse::new();
if http.http_s_req("wsf.cdyne.com", 80, false, &req, &resp).is_err() {
println!("{}", http.last_error_text());
return;
}
let xml_response = chilkat::Xml::new();
let _ = xml_response.load_xml(&resp.body_str()).is_ok();
println!("{}", xml_response.get_xml().unwrap_or_default());