473,395 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Consuming Web Service using classis ASP

Mo
Hi,

I can not find a decent example showing how to consume a asp.net 2.0
web service using classic ASP. Does any body have an example I could
use?

Thanks

Jun 4 '07 #1
8 9785
Mo wrote:
Hi,

I can not find a decent example showing how to consume a asp.net 2.0
web service using classic ASP. Does any body have an example I could
use?
It's not something a lot of us do. All I can suggest is a google search.
I seem to remember 4GuysFromRolla had a good article about it.

http://www.google.co.uk/search?q=con...005-37,GGLD:en

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jun 4 '07 #2
http://www.codeproject.com/soap/Cons...icefromASP.asp
"Mo" <le******@yahoo.comwrote in message news:11**********************@m36g2000hse.googlegr oups.com...
Hi,

I can not find a decent example showing how to consume a asp.net 2.0
web service using classic ASP. Does any body have an example I could
use?

Thanks

Jun 4 '07 #3
Mo
Thank you all for your great posts. I have created a simple helloworld
service which I am trying to call from ASP. I am using the following
code which is posted in one of the sites I found.:

html>
<head>
<title>Calling a webservice from classic ASP</title>
</head>
<body>
<%
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
Dim xmlhttp
Dim DataToSend
DataToSend="param1="&Request.Form("text1")
Dim postUrl
postUrl = " http://xxxlon.xxxmo.com/AWS.asmx/TestService HTTP/1.1"
Set xmlhttp = server.Createobject("MSXML2.XMLHTTP")
xmlhttp.Open "POST",postUrl,false
xmlhttp.setRequestHeader "Content-Type", _
"application/x-www-form- urlencoded"
xmlhttp.send DataToSend
Response.Write(xmlhttp.responseText)
End If
%>
<FORM method=POST name="form1">
Enter the two Values to be Added<BR>
<INPUT type="text" name="text1">

<BR><BR>
<INPUT type="submit" value="Add" name="submit1">
</form>
</body>
</html></PRE>

But when I access the page I am getting the following error:
Request format is unrecognized for URL unexpectedly ending in '/
TestService'.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Request format is
unrecognized for URL unexpectedly ending in '/TestService'.
If I remove the /TestService from the service url I get the following
error after I submit the form:

soap:ReceiverSystem.Web.Services.Protocols.SoapExc eption: Server was
unable to process request. ---System.Xml.XmlException: Data at the
root level is invalid. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitesp ace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent( )
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at
System.Web.Services.Protocols.SoapServerProtocol.S oapEnvelopeReader.Read()
at System.Xml.XmlReader.MoveToContent()
at
System.Web.Services.Protocols.SoapServerProtocol.S oapEnvelopeReader.MoveToContent()
at
System.Web.Services.Protocols.SoapServerProtocolHe lper.GetRequestElement()
at
System.Web.Services.Protocols.Soap12ServerProtocol Helper.RouteRequest()
at
System.Web.Services.Protocols.SoapServerProtocol.R outeRequest(SoapServerMessage
message)
at System.Web.Services.Protocols.SoapServerProtocol.I nitialize()
at System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type
type, HttpContext context, HttpRequest request, HttpResponse response,
Boolean& abortProcessing)
--- End of inner exception stack trace ---
What am I doing wrong?

Thanks

Jun 5 '07 #4
"Mo" wrote:
Set xmlhttp = server.Createobject("MSXML2.XMLHTTP")

...What am I doing wrong?
I know this does not address your initial problem, but you have created the
potential for more by using the MSXML2.XMLHTTP object when you ought to use
the server-safe MSXML2.ServerXMLHTTP.

http://msdn.microsoft.com/library/en...c0e098b8f3.asp

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.

Jun 5 '07 #5
looks like a problem with the posturl

try removing "HTTP/1.1"
"Mo" <le******@yahoo.comwrote in message news:11**********************@o5g2000hsb.googlegro ups.com...
Thank you all for your great posts. I have created a simple helloworld
service which I am trying to call from ASP. I am using the following
code which is posted in one of the sites I found.:

html>
<head>
<title>Calling a webservice from classic ASP</title>
</head>
<body>
<%
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
Dim xmlhttp
Dim DataToSend
DataToSend="param1="&Request.Form("text1")
Dim postUrl
postUrl = " http://xxxlon.xxxmo.com/AWS.asmx/TestService HTTP/1.1"
Set xmlhttp = server.Createobject("MSXML2.XMLHTTP")
xmlhttp.Open "POST",postUrl,false
xmlhttp.setRequestHeader "Content-Type", _
"application/x-www-form- urlencoded"
xmlhttp.send DataToSend
Response.Write(xmlhttp.responseText)
End If
%>
<FORM method=POST name="form1">
Enter the two Values to be Added<BR>
<INPUT type="text" name="text1">

<BR><BR>
<INPUT type="submit" value="Add" name="submit1">
</form>
</body>
</html></PRE>

But when I access the page I am getting the following error:
Request format is unrecognized for URL unexpectedly ending in '/
TestService'.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Request format is
unrecognized for URL unexpectedly ending in '/TestService'.
If I remove the /TestService from the service url I get the following
error after I submit the form:

soap:ReceiverSystem.Web.Services.Protocols.SoapExc eption: Server was
unable to process request. ---System.Xml.XmlException: Data at the
root level is invalid. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitesp ace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent( )
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at
System.Web.Services.Protocols.SoapServerProtocol.S oapEnvelopeReader.Read()
at System.Xml.XmlReader.MoveToContent()
at
System.Web.Services.Protocols.SoapServerProtocol.S oapEnvelopeReader.MoveToContent()
at
System.Web.Services.Protocols.SoapServerProtocolHe lper.GetRequestElement()
at
System.Web.Services.Protocols.Soap12ServerProtocol Helper.RouteRequest()
at
System.Web.Services.Protocols.SoapServerProtocol.R outeRequest(SoapServerMessage
message)
at System.Web.Services.Protocols.SoapServerProtocol.I nitialize()
at System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type
type, HttpContext context, HttpRequest request, HttpResponse response,
Boolean& abortProcessing)
--- End of inner exception stack trace ---
What am I doing wrong?

Thanks

Jun 5 '07 #6
Mo
Thank you for all your great posts. I am still haven't been able to
get it to work. After I change the object to MSXML2.ServerXMLHTTP I
am getting 500 error on the browser after the button click. I also
tried removeing http/1.1 from the desciprion of the service and I get
the error saying that unexpected ending in /TestService.

Any other recommendations? There must be a working code somewhere. I
do not believe I am the first guy looking for this.

Thanks

Jun 5 '07 #7
I am getting the same problem. A web service can be accessed if both web service and ASP page are on the same server, but if we change it to different servers then it's not returning any response XML. What problem could have been in this I am using MSXML2.ServerXMLHTTP to retrieve XML.

Thanks
Sep 29 '08 #8
"Adeel Taseer" wrote:
I am getting the same problem.
Same problem as what?

A web service can be accessed if both web service and ASP page are
on the same server, but if we change it to different servers then
it's not returning any response XML.
Are there any IP restrictions on the service you are attempting to consume?
What kind of response do you get if you consume the service directly with a
web browser (while logged onto the server that consumes the service) ?

Is the service on the remote server an ASP.NET Web Service? If so, have you
tried toggling this?
http://msdn.microsoft.com/en-us/libr...attribute.aspx

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.

Sep 29 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: raghavendra | last post by:
Hi, How to run automatically windows service by using setup deployment insatllation script using visual studio 2003.? What i did is :-- 1. created a windows service & tested the same. 2....
1
by: John Lee | last post by:
Hi, I have two web services and they are setup as "Integrated Windows Authentication" only and they are both assigned to application pool with Domain Account. I can use ws.Credentials =...
3
by: Jim Lewis | last post by:
I have read several things that state accessing a Web Service through a Query String should work. However, when I try to execute http://localhost/webservice1/service1.asmx/HelloWorld I get the...
5
by: David Lozzi | last post by:
Howdy, I wrote a web service in .Net for my customer. My customer has another vendor who now has to consume it but they are not using Visual Studio. Most of their pages are jsp, and they said...
0
by: JDF | last post by:
I am trying to create a Windows service using SimpleXMLRPCServer and win32serviceutil. The service itself seems to be working properly (starts, stops, etc) and I can connect using an XMLRPC client...
6
by: Ravi Shankar | last post by:
Hello, I have written a service using VB.Net which is basically a asynch socket listener. I have been able to install it successfully. Using the Service Control Manager I am able to start & stop...
3
by: Brad | last post by:
I'm setting up my new pc with all my VS.net projects and I'm missing something.....something I've done many times before without problem. I have several asp.net apps accessing secure .net web...
3
by: =?Utf-8?B?RGFuZGFuIFpoYW5n?= | last post by:
Now I have a web application, a web service and a SQL Server database. The Web application will invoke the web service, the web service invokes the SQL Server stored procedure. I let the web...
1
by: riaz1983 | last post by:
Hi, I am trying to access a .net web service using php.A member function in the web service has an object as a parameter. I was not able to access that member function. Here is the web service...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.