myGoogleResults

Sunday, February 1, 2009

Call a WCF Service from Classic ASP

Dim wsdl, moniker, obj

wsdl = GetWsdlFromUrl("http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary1/Service1/?wsdl")

moniker = "service:wsdl=" & wsdl & ", "
moniker = moniker + "address=http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary1/Service1/,"
moniker = moniker + "contract=IService1, "
moniker = moniker + "contractNamespace=http://tempuri.org/, "
moniker = moniker + "binding=WSHttpBinding_IService1, "
moniker = moniker + "bindingNamespace=http://tempuri.org/"


Set objProxy = GetObject(moniker)

Dim str
str = objProxy.GetData("2")
Response.Write(str)




Function GetWsdlFromUrl(strUrl)

Dim winHttpReq, resp

Set winHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
resp = winHttpReq.Open("GET", strUrl, False)
winHttpReq.Send

GetWsdlFromUrl = winHttpReq.ResponseText

End Function

1 comment:

Anonymous said...

Hi,

The above code is giving an error at the line "str = objProxy.GetData("2")".
Do you have any suggestion on this?