mousemat24
asked on
Consume a Web service in classic ASP
Hi there
I have a web service in .NET, and I need a classic ASP file to consume it, I've got the following code:
<%
Response.Write consumeWebService("AMF")
Function consumeWebService(zip)
Dim webServiceUrl, httpReq, node, myXmlDoc
webServiceUrl = "http://test.com/eLearningService.asmx/GetSize?CC=" & zip
Set httpReq = Server.CreateObject("MSXML 2.ServerXM LHTTP")
response.write ("asd")
httpReq.Open "GET", webServiceUrl, False
response.write ("asd1")
httpReq.Send
response.write ("asd2")
Set myXmlDoc =Server.CreateObject("MSXM L.DOMDocum ent")
myXmlDoc.load(httpReq.resp onseBody)
Set httpReq = Nothing
Set node = myXmlDoc.documentElement.s electSingl eNode("//G etDownload SizeResult ")
If Not node Is Nothing Then
consumeWebService = "<b>That zipcode is within this city:</b><font color = blue>" & node.text & "</font>"
Exit Function
Else
consumeWebService = "<b>There is no location associated with that zipcode.</b>"
Exit Function
End If
End Function
%>
And I never get pass response.write ("asd1")
Any idea why I cant see response.write ("asd2")?
Thanks
I have a web service in .NET, and I need a classic ASP file to consume it, I've got the following code:
<%
Response.Write consumeWebService("AMF")
Function consumeWebService(zip)
Dim webServiceUrl, httpReq, node, myXmlDoc
webServiceUrl = "http://test.com/eLearningService.asmx/GetSize?CC=" & zip
Set httpReq = Server.CreateObject("MSXML
response.write ("asd")
httpReq.Open "GET", webServiceUrl, False
response.write ("asd1")
httpReq.Send
response.write ("asd2")
Set myXmlDoc =Server.CreateObject("MSXM
myXmlDoc.load(httpReq.resp
Set httpReq = Nothing
Set node = myXmlDoc.documentElement.s
If Not node Is Nothing Then
consumeWebService = "<b>That zipcode is within this city:</b><font color = blue>" & node.text & "</font>"
Exit Function
Else
consumeWebService = "<b>There is no location associated with that zipcode.</b>"
Exit Function
End If
End Function
%>
And I never get pass response.write ("asd1")
Any idea why I cant see response.write ("asd2")?
Thanks
Using webservices with parameters in the url is depicrated by microsoft. You can still use it, if you reconfigure the webservice to support it.
Try using
<%
Only to process a Post Request
If Request.ServerVariables("R EQUEST_MET HOD") = "POST" Then
Dim oSOAP
'Create an object of Soap Client
Set oSOAP = Server.CreateObject("MSSOA P.SoapClie nt")
oSOAP.ClientProperty("Serv erHTTPRequ est") = True
'Initaialize the Web Service
oSOAP.mssoapinit("http://localhost/Add/test.asmx?wsdl")
'Invoke the Web Service
Response.write(oSOAP.Add(R equest.For m("text1") , _
Request.Form("text2")) & "<BR>")
End If
%>
Try using
<%
Only to process a Post Request
If Request.ServerVariables("R
Dim oSOAP
'Create an object of Soap Client
Set oSOAP = Server.CreateObject("MSSOA
oSOAP.ClientProperty("Serv
'Initaialize the Web Service
oSOAP.mssoapinit("http://localhost/Add/test.asmx?wsdl")
'Invoke the Web Service
Response.write(oSOAP.Add(R
Request.Form("text2")) & "<BR>")
End If
%>
ASKER
bugs
my method name is called GetSize, and I need to pass a param to it called AMF
How can I get it to work with your example?
Do I need to place the wsdl at the end of the URL?
http://test.com/eLearningService.asmx/GetSize?CC="
Thanks
my method name is called GetSize, and I need to pass a param to it called AMF
How can I get it to work with your example?
Do I need to place the wsdl at the end of the URL?
http://test.com/eLearningService.asmx/GetSize?CC="
Thanks
oSOAP.mssoapinit("http://test.com/eLearningService.asmx/GetSize?CC=")
Sorry i made a typo. It should have been
oSOAP.mssoapinit("http://test.com/eLearningService.asmx/GetSize")
'Invoke the Web Service
Response.write(oSOAP.Add(C C))
oSOAP.mssoapinit("http://test.com/eLearningService.asmx/GetSize")
'Invoke the Web Service
Response.write(oSOAP.Add(C
Here I will type the complete example
<html>
<head>
<title>CONSUME WEBSERVICE</title>
</head>
<body>
<%
Only to process a Post Request
If Request.ServerVariables("R EQUEST_MET HOD") = "POST" Then
Dim oSOAP
'Create an object of Soap Client
Set oSOAP = Server.CreateObject("MSSOA P.SoapClie nt")
oSOAP.ClientProperty("Serv erHTTPRequ est") = True
'Initaialize the Web Service
oSOAP.mssoapinit("http://test.com/eLearningService.asmx/GetSize")
'Invoke the Web Service
Response.write(oSOAP.Add(R equest.For m("CC"))
End If
%>
<FORM method=POST name="form1">
.<BR>
<INPUT type="text" name="CC">
<BR><BR>
<INPUT type="submit" value="Add" name="submit1">
</form>
</body>
</html>
<html>
<head>
<title>CONSUME WEBSERVICE</title>
</head>
<body>
<%
Only to process a Post Request
If Request.ServerVariables("R
Dim oSOAP
'Create an object of Soap Client
Set oSOAP = Server.CreateObject("MSSOA
oSOAP.ClientProperty("Serv
'Initaialize the Web Service
oSOAP.mssoapinit("http://test.com/eLearningService.asmx/GetSize")
'Invoke the Web Service
Response.write(oSOAP.Add(R
End If
%>
<FORM method=POST name="form1">
.<BR>
<INPUT type="text" name="CC">
<BR><BR>
<INPUT type="submit" value="Add" name="submit1">
</form>
</body>
</html>
ASKER
bugs
How do I pass a para to the WS, I'm really sorry about the 101 questions, but I've spent all day on this, and havent done anything
Thanks
How do I pass a para to the WS, I'm really sorry about the 101 questions, but I've spent all day on this, and havent done anything
Thanks
I see you are passing AMF as the ZIP to your webservice.
In my example there is a textbox which sends the parameter.
For you, all you have do is
'Initaialize the Web Service
oSOAP.mssoapinit("http://test.com/eLearningService.asmx/GetSize")
'Invoke the Web Service
Response.write(oSOAP.Add(' AMF') 'Try either single or double quote
In my example there is a textbox which sends the parameter.
For you, all you have do is
'Initaialize the Web Service
oSOAP.mssoapinit("http://test.com/eLearningService.asmx/GetSize")
'Invoke the Web Service
Response.write(oSOAP.Add('
One more thing does your NODE in the webservice has /GetDownloadSizeResult
CAN YOU please paste the WEBSERVICE for us
ASKER
bugs
When I click on the Submit button, it dosnt go to any page, I get
The page cannot be displayed
HTTP 500 - Internal server error
Internet Explorer
When I click on the Submit button, it dosnt go to any page, I get
The page cannot be displayed
HTTP 500 - Internal server error
Internet Explorer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@mousemat24
If you still could not get me then maybe I am not explaining right. But still would try. Try checking the below link and it will help you
http://www.w3schools.com/webservices/ws_use.asp
If you still could not get me then maybe I am not explaining right. But still would try. Try checking the below link and it will help you
http://www.w3schools.com/webservices/ws_use.asp
It would be great if you paste your Webservice for me to understand.
Please check the NODES. ??? If the node is GetDownloadSizeResult
Please check the NODES. ??? If the node is GetDownloadSizeResult
ASKER
thanks for all your help bugs, its very kind of you!
This is my code
<html>
<head>
<title>CONSUME WEBSERVICE</title>
</head>
<body>
<script>
Function consumeWebService()
Dim soapClient
Set soapClient = Server.CreateObject("MSSOA P.SoapClie nt")
soapClient.ClientProperty( "ServerHTT PRequest") = True
soapClient.mssoapinit "http://edeploy-ws.pwcinternal.com/eLearningService.asmx?wsdl"
consumeWebService = soapClient.GetDownloadSize ("AMF")
alert(consumeWebService)
End Function
</script>
<FORM method=POST name="form1">
<BR>
<INPUT type="text" name="CC">
<BR><BR>
<INPUT type="button" onclick="consumeWebService ()" value="Add" name="asdasd">
</form>
</body>
</html>
This is my code
<html>
<head>
<title>CONSUME WEBSERVICE</title>
</head>
<body>
<script>
Function consumeWebService()
Dim soapClient
Set soapClient = Server.CreateObject("MSSOA
soapClient.ClientProperty(
soapClient.mssoapinit "http://edeploy-ws.pwcinternal.com/eLearningService.asmx?wsdl"
consumeWebService = soapClient.GetDownloadSize
alert(consumeWebService)
End Function
</script>
<FORM method=POST name="form1">
<BR>
<INPUT type="text" name="CC">
<BR><BR>
<INPUT type="button" onclick="consumeWebService
</form>
</body>
</html>
Hi,
By looking at www.xmethods.net, you can get a list of all the webservices that are registered.
For using webservices in ASP.NET , you can see this URL :
http://www.aspng.com/quickstart/aspplus/doc/servicesanddata.aspx
Hope that helps.
The simplest method that I have found to cunsume Webservice from ASP is by using Microsoft's WebService Behavior.
You can download it and find description from
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/webservice/overview.asp.
This is description from MS:
The WebService behavior enables client-side script to invoke remote methods exposed by Web Services, or other Web servers, that support the SOAP and Web Services Description Language (WSDL) 1.1. This behavior provides developers the opportunity to use and leverage SOAP, without requiring expert knowledge of its implementation. The WebService behavior supports the use of a wide variety of data types, including intrinsic SOAP data types, arrays, objects, and Extensible Markup Language (XML) data. The WebService behavior is implemented with an HTML Component (HTC) file as an attached behavior, so it can be used in Microsoft® Internet Explorer 5 and later versions.
By looking at www.xmethods.net, you can get a list of all the webservices that are registered.
For using webservices in ASP.NET , you can see this URL :
http://www.aspng.com/quickstart/aspplus/doc/servicesanddata.aspx
Hope that helps.
The simplest method that I have found to cunsume Webservice from ASP is by using Microsoft's WebService Behavior.
You can download it and find description from
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/webservice/overview.asp.
This is description from MS:
The WebService behavior enables client-side script to invoke remote methods exposed by Web Services, or other Web servers, that support the SOAP and Web Services Description Language (WSDL) 1.1. This behavior provides developers the opportunity to use and leverage SOAP, without requiring expert knowledge of its implementation. The WebService behavior supports the use of a wide variety of data types, including intrinsic SOAP data types, arrays, objects, and Extensible Markup Language (XML) data. The WebService behavior is implemented with an HTML Component (HTC) file as an attached behavior, so it can be used in Microsoft® Internet Explorer 5 and later versions.
ASKER
but it dosnt display the int that GetDownloadSize should display
ASKER
here is my WS code
public int GetDownloadSize(string CourseCode)
{
Course objCourse = Builder.GetCourse(CourseCo de, true);
return Builder.GetDownloadSize(Co urseCode, objCourse.DownloadBuildNum ber);
}
public int GetDownloadSize(string CourseCode)
{
Course objCourse = Builder.GetCourse(CourseCo
return Builder.GetDownloadSize(Co
}
Till then Try going through the links i have sent you last...
ASKER
with your example
Response.Write consumeWebService()
Function consumeWebService()
Dim soapClient
Set soapClient = Server.CreateObject("MSSOA P.SoapClie nt")
soapClient.ClientProperty( "ServerHTT PRequest") = True
soapClient.mssoapinit "http://test.com/eLearningService.asmx?wsdl"
consumeWebService = soapClient.GetSize("BUGS")
End Function
I get an error
Object required: Server
I beleive its on this line
Set soapClient = Server.CreateObject("MSSOA P.SoapClie nt")
Thanks
Response.Write consumeWebService()
Function consumeWebService()
Dim soapClient
Set soapClient = Server.CreateObject("MSSOA
soapClient.ClientProperty(
soapClient.mssoapinit "http://test.com/eLearningService.asmx?wsdl"
consumeWebService = soapClient.GetSize("BUGS")
End Function
I get an error
Object required: Server
I beleive its on this line
Set soapClient = Server.CreateObject("MSSOA
Thanks
ASKER
thanks for all your help, that worked :-)
Also, check on what are the types of characters that ur webservice will accept? I feel that you are not getting authenticated, hence, not being able to go pass response.write("asd1")