Created
March 22, 2015 20:32
-
-
Save minostro/fd138eec3c356cfdcb7e to your computer and use it in GitHub Desktop.
SOAP with Erlang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
application:start(inets). | |
SoapBody = "<soap:Body><GetWeather xmlns=\"http://www.webserviceX.NET\"><CityName>Chicago</CityName><CountryName>United States</CountryName></GetWeather></soap:Body>". | |
SoapEnvelope = lists:append([ | |
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">", | |
SoapBody, | |
"</soap:Envelope>"] | |
). | |
{ok, {{_, _, _}, _, ResponseBody}} = httpc:request(post, {"http://www.webservicex.net/globalweather.asmx", [], "text/xml", SoapEnvelope}, [], []). | |
{Xml, _} = xmerl_scan:string(ResponseBody). | |
{_, _, [{_, _, [{_, _, [{_, [], Data}]}]}]} = xmerl_lib:simplify_element(Xml). | |
{XmlData, _} = xmerl_scan:string(lists:append(Data), [{encoding, latin1}]). | |
xmerl_lib:simplify_element(XmlData). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment