Re: Consume web service using HTTP



{\rtf1\ansi\ansicpg936\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fnil\fprq2\fcharset0 MS Sans Serif;}}
\viewkind4\uc1\pard\lang2052\f0\fs20 Hi David,
\par
\par Welcome to MSDN newsgroup.
\par As for the calling webservice in JSP application, I think you'd consider the following options:
\par
\par 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 .....
\par
\par 2. If you're calling the webservice through webpage's clientside script code, using the XML HTTP component as you mentioned should be ok.
\par
\par Based on the code you provided, you directly send the following XML as SOAP messageto target .net webservcie:
\par
\par "<OrderDetails
\par xmlns='http://www.domain.com'><orderno>123456</orderno></OrderDetails>"
\par
\par 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:
\par
\par #SOAP Toolkit 3.0
\par http://www.microsoft.com/downloads/details.aspx?FamilyId=C943C0DD-CEEC-4088-9753-86F052EC8450&displaylang=en
\par
\par 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....
\par
\par Hope helps. Thanks,
\par
\par Steven Cheng
\par Microsoft Online Support
\par
\par Get Secure! www.microsoft.com/security
\par (This posting is provided "AS IS", with no warranties, and confers no rights.)
\par
\par
\par
\par
\par
\par \pard\li720 --------------------
\par From: "David Lozzi" <DavidLozzi@xxxxxxxxxxxxx>
\par References: <uLLaJJuGGHA.1032@xxxxxxxxxxxxxxxxxxxx>
\par Subject: Re: Consume web service using HTTP
\par Date: Mon, 16 Jan 2006 17:03:47 -0500
\par Lines: 75
\par X-Priority: 3
\par X-MSMail-Priority: Normal
\par X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
\par X-RFC2646: Format=Flowed; Response
\par X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
\par Message-ID: <#JoMEjuGGHA.1628@xxxxxxxxxxxxxxxxxxxx>
\par Newsgroups: microsoft.public.dotnet.framework.webservices
\par NNTP-Posting-Host: c-24-63-42-200.hsd1.ma.comcast.net 24.63.42.200
\par Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
\par Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.framework.webservices:13373
\par X-Tomcat-NG: microsoft.public.dotnet.framework.webservices
\par
\par This is what I have so far in my classic asp page
\par
\par Dim objSrvHTTP
\par Dim objXMLSend
\par Dim objXMLReceive
\par set objSrvHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
\par set objXMLSend = Server.CreateObject("MSXML2.DOMDocument")
\par set objXMLReceive = Server.CreateObject("MSXML2.DOMDocument")
\par
\par objXMLSend.async = false
\par objXMLSend.loadXML "<OrderDetails
\par xmlns='http://www.domain.com'><orderno>123456</orderno></OrderDetails>"
\par
\par objSrvHTTP.open
\par "POST","http://localhost/prgnrt/orderstatus.asmx/OrderDetails",false
\par objSrvHTTP.send objXMLSend
\par objXMLReceive = objSrvHTTP.responseText
\par Response.ContentType = "text/xml"
\par Response.Write(objSrvHTTP.responseText)
\par
\par
\par and I get this error:
\par
\par Request format is invalid: text/xml.
\par
\par
\par The web service details are:
\par
\par HTTP POST
\par The following is a sample HTTP POST request and response. The placeholders
\par shown need to be replaced with actual values.
\par
\par POST /prgnrt/orderstatus.asmx/OrderDetails HTTP/1.1
\par Host: localhost
\par Content-Type: application/x-www-form-urlencoded
\par Content-Length: length
\par
\par orderno=stringHTTP/1.1 200 OK
\par Content-Type: text/xml; charset=utf-8
\par Content-Length: length
\par
\par <?xml version="1.0"?>
\par xmlThanks!!
\par
\par --
\par David Lozzi
\par Web Applications Developer
\par dlozzi@(remove-this)delphi-ts.com
\par
\par
\par
\par "David Lozzi" <DavidLozzi@xxxxxxxxxxxxx> wrote in message
\par news:uLLaJJuGGHA.1032@xxxxxxxxxxxxxxxxxxxxxxx
\par > Howdy,
\par >
\par > I wrote a web service in .Net for my customer. My customer has another
\par > vendor who now has to consume it but they are not using Visual Studio.
\par > Most of their pages are jsp, and they said they need to consume this web
\par > service using HTTP. The developer's IDE is Notepad. Yeah, weird I know.
\par >
\par > How is this done? I guess if I can get it to run ASP, IDE independant,
\par > that should make them happy. Any references you can point me to?
\par >
\par > Thanks!!
\par >
\par > --
\par > David Lozzi
\par > Web Applications Developer
\par > dlozzi@(remove-this)delphi-ts.com
\par >
\par >
\par >
\par >
\par
\par
\par \pard
\par
\par }