472,362 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,362 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 9669
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
0
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

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.