Klasik Asp İle Web Servis Kullanım Örneği
-
http://www.w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit adresindekiverileri kullanarak xml sayfasına giden verileri asp ile göstermek istiyorum. Açıkçası xml ile daha önce hiç uğraşmadım ama basit bir örnek olursa oradan yürürüm sanırım.
-
http://holidaywebservice.com/ExampleCode_ASP.aspx
----------------------
<html><head><title></title></head><body><%Dim objHTTP, strEnvelope Set objHTTP =Server.CreateObject("Microsoft.XMLHTTP") strEnvelope ="<?xml version='1.0' encoding='utf-8'?>" strEnvelope = strEnvelope &"<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" strEnvelope = strEnvelope &"<soap:Body>" strEnvelope = strEnvelope &"<GetInfoFromWhitesPagesResponse xmlns='http://[0.0.0.0]/Contale'>" strEnvelope = strEnvelope &"<phone>4504656253</phone>" strEnvelope = strEnvelope &"</GetInfoFromWhitesPagesResponse>" strEnvelope = strEnvelope &"</soap:Body></soap:Envelope>"Dim url url ="http://[0.0.0.0]/contale/customer.asmx"With objHTTP .Open"post", url,False.setRequestHeader "Content-Type","text/xml; charset=utf-8".setRequestHeader "SOAPAction","http://[0.0.0.0]/contale/GetInfoFromWhitesPagesResponse".send strEnvelope EndWithDim strResponse strResponse = objHTTP.responseXML.TextIf(strResponse ="")ThenResponse.Write("Invalid user")ElseResponse.Write(strResponse)EndIf%></body></html> -
edit : saçmalaya başladım yatıyorum ben :D
interfector tarafından 20/Mar/14 04:22 tarihinde düzenlenmiştir -
Amaç SOAP isteği yapmak değil de bu hizmeti kullanmaksa HTTP Post örneği ASP içinde en kolay kullanılabilecek olanı, onu kullanmanı tavsiye ederim. 50°C 'yi karşılığı F'a çeviren bir örnek.
Function CelsiusToFahrenheit(celcius) With Server.CreateObject("MSXML2.ServerXMLHTTP") .open "POST", "http://www.w3schools.com//webservices/tempconvert.asmx/CelsiusToFahrenheit", False .setRequestHeader "Content-Type", "application/x-www-form-urlencoded" On Error Resume Next .send "Celsius=" & celcius CelsiusToFahrenheit = .responseXML.selectSingleNode("string").Text End With End Function Response.Write CelsiusToFahrenheit(50)
Toplam Hit: 842 Toplam Mesaj: 4
