473,880 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

NEWBEE wishes to send xml data via the SOAP method

plumpnation
16 New Member
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>Callin g a webservice from classic ASP</title>
</head>
<body>
<%

If Not IsEmpty(Request .Form("cmdSubmi t")) Then
strAppData = ""
strAppData = strAppData & "<CentralTrust> "
strAppData = strAppData & " <Ident>" & vbcrlf
strAppData = strAppData & " <BrokerID>11111 111</BrokerID>" & vbcrlf
strAppData = strAppData & " <BrokerName>Tes ter Broker</BrokerName>" & vbcrlf
strAppData = strAppData & " <AppNo>1234-TST</AppNo>" & vbcrlf
strAppData = strAppData & " <Trans>SHORTAPP SUBMIT</Trans>" & vbcrlf
strAppData = strAppData & " </Ident>" & vbcrlf
strAppData = strAppData & " <Application> " & vbcrlf
strAppData = strAppData & " <MainApp>" & vbcrlf
strAppData = strAppData & " <Title>Mr</Title>" & vbcrlf
strAppData = strAppData & " <FirstName>Jame s</FirstName>" & vbcrlf
strAppData = strAppData & " <Surname>Bond </Surname>" & vbcrlf
strAppData = strAppData & " <Email>james@un i-exports.co.uk</Email>" & vbcrlf
strAppData = strAppData & " <Marital>S</Marital>" & vbcrlf
strAppData = strAppData & " <HomePhone>0192 3280000</HomePhone>" & vbcrlf
strAppData = strAppData & " <MobilePhone>07 779876554</MobilePhone>" & vbcrlf
strAppData = strAppData & " <Address>" & vbcrlf
strAppData = strAppData & " <YearsAtAddress >0</YearsAtAddress> " & vbcrlf
strAppData = strAppData & " <MonthsAtAddres s>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>Great er 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>250 00</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:Enve lope xmlns:soap=""ht tp://schemas.xmlsoap .org/soap/envelope/"" xmlns:xsi=""htt p://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""htt p://www.w3.org/2001/XMLSchema"">" & vbcrlf
strSOAP = strSOAP & " <soap:Body>" & vbcrlf
strSOAP = strSOAP & " <SendApplicatio n xmlns=""http://www.centraltrus t.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.cent raltrust.co.uk/AWDWebService/awdservice.asmx "
Set objHTTP = Server.CreateOb ject("Msxml2.Se rverXMLHTTP")
With objHTTP
.Open "POST", strUrl, false
.SetRequestHead er "Host", "testserver.cen traltrust.co.uk "
.SetRequestHead er "Content-Type", "text/xml; charset=utf-8"
.SetRequestHead er "SOAPAction ", "http://www.centraltrus t.co.uk/SendApplication "
.send strSOAP
Response.Write( .responseText)
End With
%>
<br>
<%
End If
%>
<form id="frmTest" name="frmTest"m ethod="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 4357
plumpnation
16 New Member
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="Syst em.XML" %>
<html><head>

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




Sub btnWriteXML_OnC lick(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(S erver.MapPath(" loanPerson.xml" ), enc)
objXMLTW.WriteS tartDocument
'Top level (Parent element)
objXMLTW.WriteS tartElement("Ce ntralTrust")
objXMLTW.WriteS tartElement("Id ent")

objXMLTW.WriteS tartElement("Br okerID")
objXMLTW.WriteS tring("11702258 ")
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("Br okerName")
objXMLTW.WriteS tring("Irelish Limited")
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("Ap pNo")
objXMLTW.WriteS tring("1234-TST")
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("Tr ans")
objXMLTW.WriteS tring("SHORTAPP SUBMIT")
objXMLTW.WriteE ndElement

'end ident
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("Ap plication")

objXMLTW.WriteS tartElement("Ma inApp")

'Child elements, from request form
objXMLTW.WriteS tartElement("Fi rstName")
objXMLTW.WriteS tring(Request(" firstname"))
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("Su rname")
objXMLTW.WriteS tring(Request(" surname"))
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("Em ail")
objXMLTW.WriteS tring(Request(" email"))
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("Ad dress")
objXMLTW.WriteS tring(Request(" address"))
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("Ma rital")
objXMLTW.WriteS tring(Request(" marital"))
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("Ho mePhone")
objXMLTW.WriteS tring(Request(" homephone"))
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("Mo bilePhone")
objXMLTW.WriteS tring(Request(" mobilephone"))
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("Ad dress")

objXMLTW.WriteS tartElement("Ye arsAtAddress")
objXMLTW.WriteS tring(Request(" yearsataddress" ))
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("Mo nthsAtAddress")
objXMLTW.WriteS tring(Request(" monthsataddress "))
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("Ho useNameNo")
objXMLTW.WriteS tring(Request(" housenameno"))
objXMLTW.WriteE ndElement


objXMLTW.WriteS tartElement("St reet")
objXMLTW.WriteS tring(Request(" street"))
objXMLTW.WriteE ndElement


objXMLTW.WriteS tartElement("Lo cality")
objXMLTW.WriteS tring(Request(" locality"))
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("To wn")
objXMLTW.WriteS tring(Request(" town"))
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("Co unty")
objXMLTW.WriteS tring(Request(" county"))
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("Po stcode")
objXMLTW.WriteS tring(Request(" postcode"))
objXMLTW.WriteE ndElement

'end Address
objXMLTW.WriteE ndElement

'end MainApp
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("De tails")

objXMLTW.WriteS tartElement("Lo anAmount")
objXMLTW.WriteS tring(Request(" loanamount"))
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("Lo anTerm")
objXMLTW.WriteS tring(Request(" loanterm"))
objXMLTW.WriteE ndElement

objXMLTW.WriteS tartElement("Lo anPurpose")
objXMLTW.WriteS tring(Request(" loanpurpose"))
objXMLTW.WriteE ndElement

'end Details
objXMLTW.WriteE ndElement

'end Application
objXMLTW.WriteE ndElement

'end Central Trust
objXMLTW.WriteE ndElement

objXMLTW.WriteE ndDocument 'End Document
objXMLTW.Flush 'Write to file
objXMLTW.Close



Catch Ex as Exception

End Try
End Sub


</script>
</head>

<body>

<center><b>XM L Text Reader/Text Writer Demo</b></center>

<form method="post" action="XML_DEM O.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>Appl icant</strong>

<table><tr><t d>

FirstName:</td>

<td><asp:Textbo x 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="btnWri teXML_onClick" runat="server" />

</form>



</body></html>




Thankyou for reading, even if you can't help.
Sep 7 '06 #2
plumpnation
16 New Member
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(“y ourFieldname”) &

so that a line of your code looks like

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

similar to adding variable values in php ("stuff".$varia ble."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 New Member
Check out w3schools.com XML and SOAP section .There are lot of examples
Hope this helps u
Sep 8 '06 #4
plumpnation
16 New Member
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
6862
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 send it to this service. i've accessed other web services in .net and usually there are functions i can reference which do the processing and then return some result.
7
12009
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 save the files at utf-8 encoded at the vs.net ide? or if i use string, vs.net ide will conside it to be utf-16??? UTF8Encoding encoding = new UTF8Encoding();
4
18552
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. send the zip file to WebService. 4. Unzip the zip file to XML. 5. Load XML file into DataSet. 6.Bulk copy the XML file to DataBase.
2
1179
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 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> <GetPostsResponse xmlns="http://tempuri.org/">
31
2864
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 perspective, should be as simple as defining an object and viewing a parameter on that object. My boss has worked with it and I'm still tryin'... TIA! -- TFWBWY...A
0
4855
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 WebService/Schema. Unable to import binding 'MyRemoteObjectBinding' from namespace 'http://schemas.microsoft.com/clr/nsassem/RemoteServer/RemoteServer%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull'. Unable to import...
5
5887
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 the original byte () value to the xml and viceversa? I've tried a lof of way, as encoding.utf8, encoding.unicode, bitconverter, etc, but the only working solution I found is Convert.XXbase64String: writer.WriteElementString("ContentSignature",
4
2491
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 m_Token = null in order to destroy the session token when the user logs out. However, I'm finding that setting class instance to null results in no header being sent back to the client, with the result that the client actually remains with an...
1
1890
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 when I call a method… but, I would like to replace the send and receive with my own code so I could send the Soap message to an EMS queue and get the response SOAP from another queue instead of calling the web service.
0
9926
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11093
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10811
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10396
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9550
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7951
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5778
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5973
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4192
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.