473,493 Members | 4,355 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

sending a xml with double header

Hello, Im trying to post an XML to a UPS server and the XML has a double
header, one for the autorization section and one for the body. The following
is my code. When I run it I have the error The XML document is not well
formed. If I create this XML on a file and try to open with the XML editor I
have an error, that says I can't have to headers on the document ans it's
right because I need to have 2 headers. How can avoid this? or how can I
post 2 xmls? I need to send both sections to the UPS server. Here is my
code:

fullUrl = "https://wwwcie.ups.com/ups.app/xml/ShipConfirm"
webRequest = CType(System.Net.WebRequest.Create(fullUrl),
System.Net.HttpWebRequest)
webRequest.Method = "POST"
webRequest.ContentType = "text/xml"

Dim streamPingRequest As Stream
streamPingRequest = webRequest.GetRequestStream
Dim xmlPing2 As New XmlTextWriter(streamPingRequest,
Encoding.UTF8)

' Opens the document
xmlPing2.WriteStartDocument()
xmlPing2.Formatting = Formatting.Indented

xmlPing2.WriteStartElement("AccessRequest")
xmlPing2.WriteElementString("AccessLicenseNumber", "123456")
xmlPing2.WriteElementString("UserId", "userid")
xmlPing2.WriteElementString("Password", "password")
xmlPing2.WriteEndElement()
xmlPing2.WriteEndDocument()

xmlPing2.WriteStartDocument()
xmlPing2.WriteStartElement("ShipmentConfirmRequest ") '
xml:lang=""en-US"" > " & _
xmlPing2.WriteAttributeString("xml:lang", "en-US")
xmlPing2.WriteStartElement("Request")
xmlPing2.WriteStartElement("TransactionReference")
xmlPing2.WriteElementString("CustomerContext", "ShipConfirmUS")
xmlPing2.WriteElementString("XpciVersion", "1.0001")
xmlPing2.WriteEndElement() '"</TransactionReference>" & _
xmlPing2.WriteElementString("RequestAction", "ShipConfirm")
xmlPing2.WriteElementString("RequestOption", "nonvalidate")
xmlPing2.WriteEndElement() '"</Request>" & _
xmlPing2.WriteEndElement() '"</ShipmentConfirmRequest>"
xmlPing2.WriteEndDocument()
' close writer
xmlPing2.Close()

webRequest.AllowAutoRedirect = bAllowAutoRedirect
'webRequest.MaximumAutomaticRedirections = 50
webRequest.Timeout = iTimeout

'Send the request and wait for a response.
Try

webResponse = CType(webRequest.GetResponse(),
System.Net.HttpWebResponse)
Select Case (webResponse.StatusCode)
Case System.Net.HttpStatusCode.OK
'read the content from the response
Dim responseStream As System.IO.Stream = _
webResponse.GetResponseStream()
Dim responseEncoding As System.Text.Encoding = _
System.Text.Encoding.UTF8
' Pipes the response stream to a higher level stream
reader with the required encoding format.
Dim responseReader As New
StreamReader(responseStream, responseEncoding)
responseContent = responseReader.ReadToEnd()
Jun 22 '06 #1
0 1171

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7025
by: Paul Lamonby | last post by:
Hi, I am sending a file from the server as an email attachment. The file is being attached no problem and sending the email, but I get an error when I try to open it saying it is corrupt....
3
2585
by: RoSsIaCrIiLoIA | last post by:
I have rewrote the malloc() function of K&R2 chapter 8.7 typedef long Align; ^^^^ Here, should I write 'long', 'double' or 'long double'? I know that in my pc+compiler sizeof(long)=4,...
4
3104
by: Winston Nimchan | last post by:
Hi: I'm currently developing a socket application and would like to precede the data being sent with a 4 byte message length header (bin4). Can anyone help Regards Winston
6
2711
by: Anuradha | last post by:
Dear All How can i send mails using vb.net Thanx all
2
2128
by: daniel.czestki | last post by:
Hello, In my MS Outlook I use global address book to handling contacts. When I send email from Outlook to myself and double click on sender I get information about me from my global address...
1
4127
by: Little | last post by:
Could someone help me figure out how to put my project together. I can't get my mind wrapped around the creation of the 4 double Linked Lists. Thank your for your insight. 1. Create 4 double...
1
3279
by: Little | last post by:
Hello everyone. I am trying to do the following program and am unable to get the beginning portion to work correctly. The scanner works when I print the statements without the double linked list...
2
2123
by: kumar_subrahmanya | last post by:
Hi, I am facing problems in sending mouse clicks via SendInput API. Mouse clicks are being sent but at the X,Y co-ordinates. I am mapping my monitor to the (0,0,65535,65535) virtual monitor as...
3
2197
by: FFMG | last post by:
Hi, I want to send expiry headers along with my images. This is the code in my .htaccess file Code: -------------------- ...
0
6980
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
7157
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,...
1
6862
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...
1
4886
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...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3087
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...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1397
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
637
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.