Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / January 2006

Tip: Looking for answers? Try searching our database.

Consume web service using HTTP

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Lozzi - 16 Jan 2006 21:17 GMT
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 they need to consume this web service
using HTTP. The developer's IDE is Notepad. Yeah, weird I know.

How is this done? I guess if I can get it to run ASP, IDE independant, that
should make them happy. Any references you can point me to?

Thanks!!

Signature

David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com

Dave - 16 Jan 2006 21:57 GMT
this can be done... it took me a while to figure it out but its not all that
bad.
first, in the web.config you need a section:
<webServices>
 <protocols>
  <add name="HttpGet"/>
  <add name="HttpPost"/>
 </protocols>
</webServices>
which enables http get and post operations to the service.  then you can use
an http form like:
 <form target="zero" action='servicename.asmx/servicefunction'
method="post">
with a normal 'submit' button to send the data to the service.  the one ugly
part i had to work around was the returned xml, i ended up sending it to a
hidden frame just because i didn't want it anyway.  there are probably
better ways to use the returned data if you call it with javascript or
vbscript.

> Howdy,
>
[quoted text clipped - 7 lines]
>
> Thanks!!
David Lozzi - 16 Jan 2006 22:03 GMT
This is what I have so far in my classic asp page

Dim objSrvHTTP
Dim objXMLSend
Dim objXMLReceive
set objSrvHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
set objXMLSend = Server.CreateObject("MSXML2.DOMDocument")
set objXMLReceive = Server.CreateObject("MSXML2.DOMDocument")

objXMLSend.async = false
objXMLSend.loadXML "<OrderDetails
xmlns='http://www.domain.com'><orderno>123456</orderno></OrderDetails>"

objSrvHTTP.open
"POST","http://localhost/prgnrt/orderstatus.asmx/OrderDetails",false
objSrvHTTP.send objXMLSend
objXMLReceive = objSrvHTTP.responseText
Response.ContentType = "text/xml"
Response.Write(objSrvHTTP.responseText)

and I get this error:

Request format is invalid: text/xml.

The web service details are:

HTTP POST
The following is a sample HTTP POST request and response. The placeholders
shown need to be replaced with actual values.

POST /prgnrt/orderstatus.asmx/OrderDetails HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: length

orderno=stringHTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0"?>
xmlThanks!!

Signature

David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com

> Howdy,
>
[quoted text clipped - 7 lines]
>
> Thanks!!
Steven Cheng[MSFT] - 17 Jan 2006 07:08 GMT
Hi David,

Welcome to MSDN newsgroup.
As for the calling webservice in JSP application, I think you'd consider
the following options:

1. If you're calling the webservice through JSP's serverside code(java
code), I think you have to lookup some JAVA specific webservice sdk which
can help create webservice proxy classes which simplified webservice
consuming... Elsewise, you have to use the java specific http request
component to manually send SOAP XML http request to the .net webservice
....

2. If you're calling the webservice through webpage's clientside script
code, using the XML HTTP component as you mentioned should be ok.

Based on the code you provided, you directly send the following XML as SOAP
messageto target .net webservcie:

"<OrderDetails
xmlns='http://www.domain.com'><orderno>123456</orderno></OrderDetails>"

This is not correct since SOAP webservcie message should include the
complete SOAP envelope which contains soap headers(optional) and soap boday
(required)....     To determine the correct XML soap message you should
send, I suggest you use some TCP or HTTP trace tools to trace the soap
message ( you can consuming the webservcie through .net client app first  
to capture such SOAP message).   And the Trace Utility in SOAP toolkit 3.0
is a good http trace tools:

#SOAP Toolkit 3.0
http://www.microsoft.com/downloads/details.aspx?FamilyId=C943C0DD-CEEC-4088-
9753-86F052EC8450&displaylang=en

When you has captured the soap message , you can define a XML template file
or string that you can use to easily build a SOAP request message....

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
From: "David Lozzi" <DavidLozzi@nospam.nospam>
References: <uLLaJJuGGHA.1032@TK2MSFTNGP11.phx.gbl>
Subject: Re: Consume web service using HTTP
Date: Mon, 16 Jan 2006 17:03:47 -0500
Lines: 75
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
Message-ID: <#JoMEjuGGHA.1628@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: c-24-63-42-200.hsd1.ma.comcast.net 24.63.42.200
Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.webservices:13373
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

This is what I have so far in my classic asp page

Dim objSrvHTTP
Dim objXMLSend
Dim objXMLReceive
set objSrvHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
set objXMLSend = Server.CreateObject("MSXML2.DOMDocument")
set objXMLReceive = Server.CreateObject("MSXML2.DOMDocument")

objXMLSend.async = false
objXMLSend.loadXML "<OrderDetails
xmlns='http://www.domain.com'><orderno>123456</orderno></OrderDetails>"

objSrvHTTP.open
"POST","http://localhost/prgnrt/orderstatus.asmx/OrderDetails",false
objSrvHTTP.send objXMLSend
objXMLReceive = objSrvHTTP.responseText
Response.ContentType = "text/xml"
Response.Write(objSrvHTTP.responseText)

and I get this error:

Request format is invalid: text/xml.

The web service details are:

HTTP POST
The following is a sample HTTP POST request and response. The placeholders
shown need to be replaced with actual values.

POST /prgnrt/orderstatus.asmx/OrderDetails HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: length

orderno=stringHTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0"?>
xmlThanks!!

Signature

David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com

"David Lozzi" <DavidLozzi@nospam.nospam> wrote in message
news:uLLaJJuGGHA.1032@TK2MSFTNGP11.phx.gbl...

> Howdy,
>
[quoted text clipped - 7 lines]
>
> Thanks!!
David Lozzi - 18 Jan 2006 20:54 GMT
I updated as suggested but I still get the same error.

Dim objSrvHTTP
Dim objXMLSend
Dim objXMLReceive
set objSrvHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
set objXMLSend = Server.CreateObject("MSXML2.DOMDocument")
set objXMLReceive = Server.CreateObject("MSXML2.DOMDocument")

objXMLSend.async = false
objXMLSend.loadXML "<soap:Envelope
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">" & _
"<soap:Body><OrderDetails xmlns=""http://www.domain.com"">" & _
   "<orderno>123456</orderno>" & _
   "</OrderDetails></soap:Body></soap:Envelope>"

objSrvHTTP.open
"POST","http://localhost/prgnrt/orderstatus.asmx/OrderDetails",false
objSrvHTTP.send objXMLSend
objXMLReceive = objSrvHTTP.responseText
Response.ContentType = "text/xml"
Response.Write(objSrvHTTP.responseText)

Signature

David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com

> Hi David,
>
[quoted text clipped - 117 lines]
>>
>> Thanks!!
Steven Cheng[MSFT] - 19 Jan 2006 05:59 GMT
Thanks for your response.

So have you tried using some trace tools to capture a example SOAP request
message(sent by .net webservice proxy)? Also, for testing, you can use the
.net's HttpWebRequest component to post raw XML soap message to the service
to see whether this works, if still not work , there may exists some
problem with our XML SOAP message, elsewise, the problem should reside in
the msxml code....

Thanks,

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
From: "David Lozzi" <DavidLozzi@nospam.nospam>
References: <uLLaJJuGGHA.1032@TK2MSFTNGP11.phx.gbl>
<#JoMEjuGGHA.1628@TK2MSFTNGP12.phx.gbl>
<7CypSTzGGHA.3764@TK2MSFTNGXA02.phx.gbl>
Subject: Re: Consume web service using HTTP
Date: Wed, 18 Jan 2006 15:54:26 -0500
Lines: 184
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
X-RFC2646: Format=Flowed; Original
Message-ID: <eq2HeFHHGHA.376@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: c-24-63-42-200.hsd1.ma.comcast.net 24.63.42.200
Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.webservices:13401
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

I updated as suggested but I still get the same error.

Dim objSrvHTTP
Dim objXMLSend
Dim objXMLReceive
set objSrvHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
set objXMLSend = Server.CreateObject("MSXML2.DOMDocument")
set objXMLReceive = Server.CreateObject("MSXML2.DOMDocument")

objXMLSend.async = false
objXMLSend.loadXML "<soap:Envelope
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">" & _
"<soap:Body><OrderDetails xmlns=""http://www.domain.com"">" & _
   "<orderno>123456</orderno>" & _
   "</OrderDetails></soap:Body></soap:Envelope>"

objSrvHTTP.open
"POST","http://localhost/prgnrt/orderstatus.asmx/OrderDetails",false
objSrvHTTP.send objXMLSend
objXMLReceive = objSrvHTTP.responseText
Response.ContentType = "text/xml"
Response.Write(objSrvHTTP.responseText)

Signature

David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com

> Hi David,
>
[quoted text clipped - 29 lines]
>
> #SOAP Toolkit 3.0

http://www.microsoft.com/downloads/details.aspx?FamilyId=C943C0DD-CEEC-4088-
> 9753-86F052EC8450&displaylang=en
>
[quoted text clipped - 83 lines]
>>
>> Thanks!!

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.