473,395 Members | 1,702 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.

continuing the classic asp to web service saga: parse the response

plumpnation
I have now got this bulky piece of script working, it reads the form correctly, which sends the request to the web service using SOAP. It conforms to their DTD and the web service then responds and sends an xml document back to the page.

I would very much like the contents of the form to be entered into an sql database as it is sent to the web service, as their reply does not contain the full details filled into the form.

Aside from the response xml looking ugly written at the top of the html page, can anyone help me in my quest to open a success or failure page based upon the response xml recieved in the browser. i.e. can i parse it, picking out the SUCCESS or FAILURE text and use this info to forward to a new page?

<html>
<head>
<title>Calling a webservice from classic ASP</title>
</head>
<body>
<%

If Not IsEmpty(Request.Form("cmdSubmit")) Then
strAppData = ""
strAppData = strAppData & "<CentralTrust>"
strAppData = strAppData & " <Ident>" & vbcrlf
strAppData = strAppData & " <BrokerID>XXXXXXXX</BrokerID>" & vbcrlf
strAppData = strAppData & " <BrokerName>XXXXXXXXX</BrokerName>" & vbcrlf
strAppData = strAppData & " <AppNo>1234-TST</AppNo>" & vbcrlf
strAppData = strAppData & " <Trans>SHORTAPPSUBMIT</Trans>" & vbcrlf
strAppData = strAppData & " </Ident>" & vbcrlf
strAppData = strAppData & " <Application>" & vbcrlf
strAppData = strAppData & " <MainApp>" & vbcrlf
strAppData = strAppData & " <Title>" & Request.Form("title") & "</Title>" & vbcrlf
strAppData = strAppData & " <FirstName>" & Request.Form("firstname") & "</FirstName>" & vbcrlf
strAppData = strAppData & " <Surname>" & Request.Form("surname") & "</Surname>" & vbcrlf
strAppData = strAppData & " <Email>" & Request.Form("email") & "</Email>" & vbcrlf
strAppData = strAppData & " <Marital>" & Request.Form("marital") & "</Marital>" & vbcrlf
strAppData = strAppData & " <HomePhone>" & Request.Form("homephone") & "</HomePhone>" & vbcrlf
strAppData = strAppData & " <MobilePhone>" & Request.Form("mobilephone") & "</MobilePhone>" & vbcrlf
strAppData = strAppData & " <Address>" & vbcrlf
strAppData = strAppData & " <YearsAtAddress>" & Request.Form("yearsataddress") & "</YearsAtAddress>" & vbcrlf
strAppData = strAppData & " <MonthsAtAddress>" & Request.Form("monthsataddress") & "</MonthsAtAddress>" & vbcrlf
strAppData = strAppData & " <HouseNameNo>" & Request.Form("housenameno") & "</HouseNameNo>" & vbcrlf
strAppData = strAppData & " <Street>" & Request.Form("street") & "</Street>" & vbcrlf
strAppData = strAppData & " <Locality />" & vbcrlf
strAppData = strAppData & " <Town>" & Request.Form("town") & "</Town>" & vbcrlf
strAppData = strAppData & " <County>" & Request.Form("county") & "</County>" & vbcrlf
strAppData = strAppData & " <Postcode>" & Request.Form("postcode") & "</Postcode>" & vbcrlf
strAppData = strAppData & " </Address>" & vbcrlf
strAppData = strAppData & " </MainApp>" & vbcrlf
strAppData = strAppData & " <Details>" & vbcrlf
strAppData = strAppData & " <LoanAmount>" & Request.Form("loanamount") & "</LoanAmount>" & vbcrlf
strAppData = strAppData & " <LoanTerm>" & Request.Form("loanterm") & "</LoanTerm>" & vbcrlf
strAppData = strAppData & " <LoanPurpose>" & Request.Form("loanpurpose") & "</LoanPurpose>" & vbcrlf
strAppData = strAppData & " </Details>" & vbcrlf
strAppData = strAppData & " </Application>" & vbcrlf
strAppData = strAppData & "</CentralTrust>" & vbcrlf

strSOAP = "<?xml version=""1.0"" encoding=""utf-8""?>" & vbcrlf
strSOAP = strSOAP & "<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">" & vbcrlf
strSOAP = strSOAP & " <soap:Body>" & vbcrlf
strSOAP = strSOAP & " <SendApplication xmlns=""http://www.centraltrust.co.uk"">" & vbcrlf
strSOAP = strSOAP & " <appString>" & Replace(Replace(strAppData, "<", "&lt;"), ">", "&gt;") & "</appString>" & vbcrlf
strSOAP = strSOAP & " </SendApplication>" & vbcrlf
strSOAP = strSOAP & " </soap:Body>" & vbcrlf
strSOAP = strSOAP & "</soap:Envelope>" & vbcrlf

strURL = "http://testserver.mywebservice.co.uk/WebService/awservice.asmx"
Set objHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP")
With objHTTP
.Open "POST", strUrl, false
.SetRequestHeader "Host", "testserver.mywebservice.co.uk"
.SetRequestHeader "Content-Type", "text/xml; charset=utf-8"
.SetRequestHeader "SOAPAction", "http://www.centraltrust.co.uk/SendApplication"
.send strSOAP
Response.Write(.responseText)'this is the responded xml that I wish to use for redirection
End With
%>
<br>
<%
End If
%>

THIS IS THE FORM THAT NEEDS NOT ONLY TO GO TO THE ABOVE ASP TO BE INSERTED INTO THE XML FOR THE WEB SERVICE SOAP REQUEST, BUT ALSO NEEDS TO BE INPUTTED INTO A SQL DATABASE

<form id="frmTest" name="frmTest"method="post">
<p>
<label></label>
</p>
<table width="171" border="1">
<tr>
<td width="161" align="right"><p>title:
<label>
<select name="title" id="title">
<option value="Mr" selected>mr</option>
<option value="Mrs">mrs</option>
<option value="Miss">miss</option>
<option value="Ms">ms</option>
<option value="Dr">dr</option>
</select>
</label>
</p>
<p>firstname:
<input name="firstname" type="text" id="firstname" maxlength="50">

surname:
<input name="surname" type="text" id="surname" maxlength="50">
email:
<input name="email" type="text" id="email">
marital status:
<label>
<select name="marital" id="marital">
<option value="S" selected>single</option>
<option value="M">married</option>
<option value="D">divorced</option>
<option value="C">co-habiting</option>
<option value="W">widow</option>
<option value="I">widower</option>
</select>
</label>
<label> </label>
hometelno:
<input name="homephone" type="text" id="homephone">
mobile tel. no:
<input name="mobilephone" type="text" id="mobilephone">
years at address:
<input name="yearsataddress" type="text" id="yearsataddress">
</p>
<p>months at address: </p>
<p>
<input name="monthsataddress" type="text" id="monthsataddress">
</p>
<p>
house name or no:
<input name="housenameno" type="text" id="housenameno">
street:
<input name="street" type="text" id="street">
town:
<input name="town" type="text" id="town">
county:
<input name="county" type="text" id="county">
postcode:
<input name="postcode" type="text" id="postcode">
loan amount applying for:
<input name="loanamount" type="text" id="loanamount">
loanterm:
<input name="loanterm" type="text" id="loanterm">
purpose for loan:
<label>
<select name="loanpurpose" id="loanpurpose">
<option value="CA" selected>Car</option>
<option value="DC">Debt Consolidation</option>
<option value="CD">Consumer Durables</option>
<option value="HO">Holiday</option>
<option value="HI">Home Improvements</option>
<option value="OT">Other</option>
</select>
</label>
</p></td>
</tr>
</table>
<p>
<label></label>
<input type="submit" value="Submit Application" name="cmdSubmit">
</p>
</form>
</body>
</html>



Any help would be sorely appreciated. I will keep on it, and if I find an answer, will post it up.
Sep 8 '06 #1
2 3388
this is the returned xml from the web service. I need to write a portion of asp within the above script to do something IF the ResponseType is SUCCESS or FAILURE.

<document>
<Ident>
<BrokerID>14562132</BrokerID>
<AppNo>1234-TST </AppNo>
<Trans>RESPONSE</Trans>
</Ident>
<Application>
<Details>
<ResponseType>SUCCESS</ResponseType>
<OurID>08/09/2006 04:22:47</OurID>
</Details>
</Application>
</document>

Thankyou for your time. Remember I am writing in classic asp.

Nice one guys :)
Sep 8 '06 #2
found out.

use the (inStr) command to find out where it lies and then perhaps the (Mid) command to write the if function.

Technical jargon is not my speciality so forgive me if i've used the wrong terminology.

You could either say

if the reply from the inStr is more than 0, then you could assume that the reply is saying SUCCESS. (Look at the returned XML above.)

Response.Write InStr(yourSoapReplyString,"SUCCESS")

Or you could include the inStr value in the mid command to make sure the script starts reading the returned xml in the correct format.

If Mid(sQuerystring, InStr(sQueryString,"SUCCESS"), 7) = "SUCCESS" Then

This will reply a value. You could use the response value to determine what happens next.
Sep 18 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: Adam Short | last post by:
I am trying to write a routine that will connect a .NET server with a classic ASP server. I know the following code doesn't work! The data is being returned as a dataset, however ASP does not...
6
by: ASPfool | last post by:
Hello everyone, Please help me before I throw my computer out of the window: I'm working on a web application in classic ASP (vbscript), which is making calls to some webservices. The calls...
8
by: FS Liu | last post by:
Hi, I am writing ATL Service application (XML Web service) in VS.NET C++. Are there any sample programs that accept XML as input and XML as output in the web service? Thank you very much.
4
by: Julian Hershel | last post by:
Hi. I have a very simple web service that I am trying to call from a classic ASP page. The web service project and the ASP page are both on my development machine. That's the code of my web...
1
by: Chumley Walrus | last post by:
I'm changing an old classic asp script over to asp.net; it displays links corresponding to each day of the week <script runat="server"> Sub Page_Load(s As Object, e As EventArgs) ...
3
by: ryan.mclean | last post by:
Hi everyone! I'm hoping that someone can help me out. I have a webservice written in vb.net. This service uses the SoapHeader to secure the webservice to users that give a username and password....
5
by: Mark | last post by:
Hi all, I have a .NET webservice which I would like to consume from a classic ASP page. Furthermore, I would like to populate a recordset (if possible) with the data from the returned webservice...
2
by: shadow.demon | last post by:
So ajax is the new black, i've had a couple ideas about how to implement it. I've alook at ajax.net and few other implementations but to me they're a bit complex. Maybe it's the way to go to have...
1
by: lambelly | last post by:
I can connect to a web service via asp.net, but my client is using asp classic. In asp.net I do something very simple along the lines of: CmsApi cmsService = new CmsApi(); Authenticate auth = new...
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.