472,359 Members | 1,631 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,359 software developers and data experts.

NEWBEE wishes to send xml data via the SOAP method

plumpnation
Hello one and all.

I have recently been working outside of my field of expertise alot, and it is greatly distressing me. I have learned a small amount of php and actionscript, but now need to move into the realm of asp.

I have been supplied this script in asp classic by the web service administrator as an example, but i have no idea how to use it in conjunction with a html POST form.

1. Should the form be put within the same page?

2. How do i replace the values in the strAppData portion of the script with the POST ones entered into the fields of the form?

The asp is working as expected, it's just that it's not dynamic.

<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>11111111</BrokerID>" & vbcrlf
strAppData = strAppData & " <BrokerName>Tester Broker</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>Mr</Title>" & vbcrlf
strAppData = strAppData & " <FirstName>James</FirstName>" & vbcrlf
strAppData = strAppData & " <Surname>Bond</Surname>" & vbcrlf
strAppData = strAppData & " <Email>james@uni-exports.co.uk</Email>" & vbcrlf
strAppData = strAppData & " <Marital>S</Marital>" & vbcrlf
strAppData = strAppData & " <HomePhone>01923280000</HomePhone>" & vbcrlf
strAppData = strAppData & " <MobilePhone>07779876554</MobilePhone>" & vbcrlf
strAppData = strAppData & " <Address>" & vbcrlf
strAppData = strAppData & " <YearsAtAddress>0</YearsAtAddress>" & vbcrlf
strAppData = strAppData & " <MonthsAtAddress>0</MonthsAtAddress>" & vbcrlf
strAppData = strAppData & " <HouseNameNo>38</HouseNameNo>" & vbcrlf
strAppData = strAppData & " <Street>West Close</Street>" & vbcrlf
strAppData = strAppData & " <Locality />" & vbcrlf
strAppData = strAppData & " <Town>London</Town>" & vbcrlf
strAppData = strAppData & " <County>Greater London</County>" & vbcrlf
strAppData = strAppData & " <Postcode>HA3 5LR</Postcode>" & vbcrlf
strAppData = strAppData & " </Address>" & vbcrlf
strAppData = strAppData & " </MainApp>" & vbcrlf
strAppData = strAppData & " <Details>" & vbcrlf
strAppData = strAppData & " <LoanAmount>25000</LoanAmount>" & vbcrlf
strAppData = strAppData & " <LoanTerm>120</LoanTerm>" & vbcrlf
strAppData = strAppData & " <LoanPurpose>CA</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.centraltrust.co.uk/AWDWebService/awdservice.asmx"
Set objHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP")
With objHTTP
.Open "POST", strUrl, false
.SetRequestHeader "Host", "testserver.centraltrust.co.uk"
.SetRequestHeader "Content-Type", "text/xml; charset=utf-8"
.SetRequestHeader "SOAPAction", "http://www.centraltrust.co.uk/SendApplication"
.send strSOAP
Response.Write(.responseText)
End With
%>
<br>
<%
End If
%>
<form id="frmTest" name="frmTest"method="post">
<input type="submit" value="Test" name="cmdSubmit">
</form>
</body>
</html>

If anybody can spare any time at all, i'd really appreciate it.

Thanks again.
Sep 7 '06 #1
4 4243
Just in case no one uses classic asp anymore, could i ask that someone help me with this asp.net version that i'm writing/compiling.

At present, this script writes an xml file elsewhere in the parent folder of my localhost. Obviously this is little help, as i need to send it to a web service using the SOAP method.

Does anyone know how I can change this script in order to do that?




<%@ Page language="vb"%>
<%@ Import Namespace="System.XML" %>
<html><head>

<script language="VB" runat="server" ID=Script1>




Sub btnWriteXML_OnClick(sender As Object, e As EventArgs)
Try


Dim enc as Encoding
'Create file, overwrite if exists
'enc is encoding object required by constructor
'It is null, so default encoding is used
Dim objXMLTW as new XMLTextWriter(Server.MapPath("loanPerson.xml"), enc)
objXMLTW.WriteStartDocument
'Top level (Parent element)
objXMLTW.WriteStartElement("CentralTrust")
objXMLTW.WriteStartElement("Ident")

objXMLTW.WriteStartElement("BrokerID")
objXMLTW.WriteString("11702258")
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("BrokerName")
objXMLTW.WriteString("Irelish Limited")
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("AppNo")
objXMLTW.WriteString("1234-TST")
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("Trans")
objXMLTW.WriteString("SHORTAPPSUBMIT")
objXMLTW.WriteEndElement

'end ident
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("Application")

objXMLTW.WriteStartElement("MainApp")

'Child elements, from request form
objXMLTW.WriteStartElement("FirstName")
objXMLTW.WriteString(Request("firstname"))
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("Surname")
objXMLTW.WriteString(Request("surname"))
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("Email")
objXMLTW.WriteString(Request("email"))
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("Address")
objXMLTW.WriteString(Request("address"))
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("Marital")
objXMLTW.WriteString(Request("marital"))
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("HomePhone")
objXMLTW.WriteString(Request("homephone"))
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("MobilePhone")
objXMLTW.WriteString(Request("mobilephone"))
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("Address")

objXMLTW.WriteStartElement("YearsAtAddress")
objXMLTW.WriteString(Request("yearsataddress"))
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("MonthsAtAddress")
objXMLTW.WriteString(Request("monthsataddress"))
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("HouseNameNo")
objXMLTW.WriteString(Request("housenameno"))
objXMLTW.WriteEndElement


objXMLTW.WriteStartElement("Street")
objXMLTW.WriteString(Request("street"))
objXMLTW.WriteEndElement


objXMLTW.WriteStartElement("Locality")
objXMLTW.WriteString(Request("locality"))
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("Town")
objXMLTW.WriteString(Request("town"))
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("County")
objXMLTW.WriteString(Request("county"))
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("Postcode")
objXMLTW.WriteString(Request("postcode"))
objXMLTW.WriteEndElement

'end Address
objXMLTW.WriteEndElement

'end MainApp
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("Details")

objXMLTW.WriteStartElement("LoanAmount")
objXMLTW.WriteString(Request("loanamount"))
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("LoanTerm")
objXMLTW.WriteString(Request("loanterm"))
objXMLTW.WriteEndElement

objXMLTW.WriteStartElement("LoanPurpose")
objXMLTW.WriteString(Request("loanpurpose"))
objXMLTW.WriteEndElement

'end Details
objXMLTW.WriteEndElement

'end Application
objXMLTW.WriteEndElement

'end Central Trust
objXMLTW.WriteEndElement

objXMLTW.WriteEndDocument 'End Document
objXMLTW.Flush 'Write to file
objXMLTW.Close



Catch Ex as Exception

End Try
End Sub


</script>
</head>

<body>

<center><b>XML Text Reader/Text Writer Demo</b></center>

<form method="post" action="XML_DEMO.aspx" runat="server" ID=Form1>



<TD width="50%" valign = top>
Complete the fields below to create and display the XML file "loanPerson.xml&quot;
<p><strong>Applicant</strong>

<table><tr><td>

FirstName:</td>

<td><asp:Textbox id=firstname runat="server" width="200"
visible="True"></asp:Textbox></td></tr>
<tr>
<td>Surname: </td>
<td>

<asp:Textbox id="surname" runat="server" visible="True" width="200"/></td></tr>
<tr><td>
City: </td>
<td>
<asp:Textbox id=city runat="server" width="200"
visible="True"></asp:Textbox></td></tr>
<tr>
<td>
Homephone: </td>
<td>
<asp:Textbox id=homephone runat="server" width="200" visible="True"
MaxLength="20"></asp:Textbox></td></tr>
<tr><td>
Postcode: </td>
<td>
<asp:Textbox id=postcode runat="server" width="200"
visible="True" maxlength="8"></asp:Textbox></td></tr>


</table></p>
</TD>
</tr>
</table>
<p>&nbsp;</p>
<asp:Button id="btnWriteXML" text="Submit" OnClick="btnWriteXML_onClick" runat="server" />

</form>



</body></html>




Thankyou for reading, even if you can't help.
Sep 7 '06 #2
I've got an answer to my own question. I'll post it in case anyone fancies knowing

in the classic asp script to add a variable from the form, which is in this case in the same page as the asp, you can probably have the asp as an form action page as well ) you add

& Request.Form(“yourFieldname”) &

so that a line of your code looks like

strAppData = strAppData & "<Title>” & Request.Form(“App1Title”) & “</Title>" & vbcrlf

similar to adding variable values in php ("stuff".$variable."stuff")

I don't think anyone would use this script these days, but you never know.

Good luck to all of you.
Sep 7 '06 #3
teju
34
Check out w3schools.com XML and SOAP section .There are lot of examples
Hope this helps u
Sep 8 '06 #4
Check out w3schools.com XML and SOAP section .There are lot of examples
Hope this helps u

thankyou very much :)
Sep 8 '06 #5

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

Similar topics

5
by: mark kurten | last post by:
i have a requirement to send a soap message to a web service. i'm familiar with the soap toolkit using vb. i need to generate a xml document which i think i can do, but i don't know how to...
7
by: Mullin Yu | last post by:
I want to submit a utf-8 xml request to a servlet by the following coding. it seesm that the servlet can't recognize it correctly. can i just using string postData = "..... utf-8 data" and then...
4
by: ad | last post by:
I want to send a DataSet to WebService, but the DataSet if too huge(there about 50000 records, and 50 fields every record). My solution is 1.save the DataSet as XML file, 2.zip the XML file. 3....
2
by: Swapnil2006 | last post by:
I am using the SOAP 1.1 request and response to create a corresponding web method for it. SOAP 1.1 response looks like as follows : <?xml version="1.0" encoding="utf-8"?> <soap:Envelope...
31
by: Bryan Dickerson | last post by:
Ok, simple question: from a VB.Net web service (as I've said before, I'm a newbie to SOAP), how would I get the SOAP body into a string? My boss and I concur that it, at least from our...
0
by: Jigar.Patel | last post by:
I have simple remoting server exposing following simple method. When I try to add webreference to this server in another project, it gives me following error: Custom tool error: Unable to import...
5
by: Trapulo | last post by:
Hello, I need to send to a webservice a parameter that is a string containing an XML doc. In this xml, a node value came from a byte array (it's an RSA signature). What is the best way to convert...
4
by: Joseph Geretz | last post by:
We use a Soap Header to pass a token class (m_Token) back and forth with authenticated session information. Given the following implementation for our Logout method, I vastly prefer to simply code...
1
by: =?Utf-8?B?UnVp?= | last post by:
Can I override the send and receive methods on a web service proxy? I want to use the default proxy classes generated when I add a reference to a web service to create and read the SOAP messages...
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: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
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...

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.