Consuming Web Service using classis ASP

Consuming Web Service using classis ASP

am 04.06.2007 21:42:42 von Mo hariri

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

Re: Consuming Web Service using classis ASP

am 04.06.2007 21:58:30 von reb01501

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=consume+web+service+with+cl assic+asp&hl=en&sourceid=gd&rls=GGLD,GGLD:2005-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.

Re: Consuming Web Service using classis ASP

am 05.06.2007 00:05:42 von Jon Paal

http://www.codeproject.com/soap/ConsumWebServicefromASP.asp


"Mo" wrote in message news:1180986162.292609.197400@m36g2000hse.googlegroups.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
>

Re: Consuming Web Service using classis ASP

am 05.06.2007 03:55:37 von Mo hariri

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>

Calling a webservice from classic ASP


<%
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
%>


Enter the two Values to be Added











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.SoapException: 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.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at
System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelop eReader.Read()
at System.Xml.XmlReader.MoveToContent()
at
System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelop eReader.MoveToContent()
at
System.Web.Services.Protocols.SoapServerProtocolHelper.GetRe questElement()
at
System.Web.Services.Protocols.Soap12ServerProtocolHelper.Rou teRequest()
at
System.Web.Services.Protocols.SoapServerProtocol.RouteReques t(SoapServerMessage
message)
at System.Web.Services.Protocols.SoapServerProtocol.Initialize( )
at System.Web.Services.Protocols.ServerProtocolFactory.Create(T ype
type, HttpContext context, HttpRequest request, HttpResponse response,
Boolean& abortProcessing)
--- End of inner exception stack trace ---


What am I doing wrong?

Thanks

Re: Consuming Web Service using classis ASP

am 05.06.2007 13:53:15 von Dave Anderson

"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-us/xmlsdk/html/97884cf6 -5fdf-4b1f-8273-73c0e098b8f3.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.

Re: Consuming Web Service using classis ASP

am 05.06.2007 16:01:48 von Jon Paal

looks like a problem with the posturl

try removing "HTTP/1.1"


"Mo" wrote in message news:1181008537.890174.228220@o5g2000hsb.googlegroups.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>
>
> Calling a webservice from classic ASP
>
>
> <%
> 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
> %>
>


> Enter the two Values to be Added

>
>
>


>
>

>
>
>
> 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.SoapException: 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.ParseRootLevelWhitespace()
> at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
> at System.Xml.XmlTextReaderImpl.Read()
> at System.Xml.XmlTextReader.Read()
> at
> System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelop eReader.Read()
> at System.Xml.XmlReader.MoveToContent()
> at
> System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelop eReader.MoveToContent()
> at
> System.Web.Services.Protocols.SoapServerProtocolHelper.GetRe questElement()
> at
> System.Web.Services.Protocols.Soap12ServerProtocolHelper.Rou teRequest()
> at
> System.Web.Services.Protocols.SoapServerProtocol.RouteReques t(SoapServerMessage
> message)
> at System.Web.Services.Protocols.SoapServerProtocol.Initialize( )
> at System.Web.Services.Protocols.ServerProtocolFactory.Create(T ype
> type, HttpContext context, HttpRequest request, HttpResponse response,
> Boolean& abortProcessing)
> --- End of inner exception stack trace ---
>
>
> What am I doing wrong?
>
> Thanks
>

Re: Consuming Web Service using classis ASP

am 05.06.2007 17:30:39 von Mo hariri

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