473,883 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to post an XML file to HTTPS using vb.net 2005

JD
I am currently trying to send an XML document to an HTTPS address. The
address is something like https://blah.com:5558/test/http.

I am trying to use httpWebRequest but am not sure if this is the correct
way. My code looks like the following:

Private Sub Upload(ByVal fileName As String, ByVal uploadUrl As String)
Dim requestStream As Stream = Nothing
Dim fileStream As FileStream = Nothing
Dim uploadResponse As HttpWebResponse = Nothing
Try
Dim uploadRequest As HttpWebRequest = WebRequest.Crea te(uploadUrl)
uploadRequest.M ethod = WebRequestMetho ds.Http.Post

' UploadFile is not supported through an Http proxy
' so we disable the proxy for this request.
uploadRequest.P roxy = Nothing

requestStream = uploadRequest.G etRequestStream ()
fileStream = File.Open(fileN ame, FileMode.Open)

Dim buffer(1024) As Byte
Dim bytesRead As Integer
While True
bytesRead = fileStream.Read (buffer, 0, buffer.Length)
If bytesRead = 0 Then
Exit While
End If
requestStream.W rite(buffer, 0, bytesRead)
End While

' The request stream must be closed before getting the response.
requestStream.C lose()

uploadResponse = uploadRequest.G etResponse()
Console.WriteLi ne("Upload complete.")
Catch ex As UriFormatExcept ion
Console.WriteLi ne(ex.Message)
Catch ex As IOException
Console.WriteLi ne(ex.Message)
Catch ex As WebException
Console.WriteLi ne(ex.Message)

Finally
If uploadResponse IsNot Nothing Then
uploadResponse. Close()
End If
If fileStream IsNot Nothing Then
fileStream.Clos e()
End If
If requestStream IsNot Nothing Then
requestStream.C lose()
End If
End Try

When this code is executed, the following exception occurs:

The remote server returned an error: (401) Unauthorized.

Another method I tried also returns an error :
The remote server returned an error:(501) Not
Implemented.sys tem.net.webexce ption

Any help / advise would be greatly appreciated.
Cheers
JD
Mar 23 '06 #1
2 11256

Hi JD

Did you manage to get your code working. I'm trying to do a similar
thing and having difficulties, the same 401 exception.

It would be a great help if anybody could shed some light on the
situation

Thanks in advance

g

--
the_g_man
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message2225194.html

Jun 29 '06 #2

Hi,

I have done something like this in C# (below) im posting it for you. might
be helpfull :)...

Cheers

private String SendDa(string url, string keyword)
{
String result="";
String strPost="your xml string from a file";
StreamWriter myWriter=null;
HttpWebRequest objRequest=(Htt pWebRequest)Web Request.Create( "YourURL
Here");
objRequest.Meth od="POST";
objRequest.Cont entLength=strPo st.Length;
objRequest.Cont entType="applic ation/x-www-form-urlencoded";

try
{
myWriter=new StreamWriter(ob jRequest.GetReq uestStream());
myWriter.Write( strPost);
}
catch(Exception ex)
{
return ex.Message;
}
finally
{
yWriter.Close() ;
}

HttpWebResponse objResponse=(Ht tpWebResponse)o bjRequest.GetRe sponse();
using (StreamReader sr=new StreamReader(ob jResponse.GetRe sponseStream()) )
{
result=sr.ReadT oEnd();
sr.Close();
}
return result;
}
}
--
Waqas Ahmed
Project Manager/Lead Developer
Softflux Pakistan
"the_g_man" wrote:

Hi JD

Did you manage to get your code working. I'm trying to do a similar
thing and having difficulties, the same 401 exception.

It would be a great help if anybody could shed some light on the
situation

Thanks in advance

g

--
the_g_man
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message2225194.html

Jul 1 '06 #3

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

Similar topics

2
5326
by: Angie | last post by:
Hello everybody, I have an osCommerce shopping cart on my site, which is an open-source product that uses php. I'm very new to php. I also have an online scheduling application that I outsourced to a third party, which resides on a different server. I asked my scheduling provider if there was anyway I could use my osCommerce php registration for thier registration so I could avoid having visitors to the site register and sign-in twice,...
6
5561
by: DavidT | last post by:
I need to build a valid XML file using ASP form elements, pass that "file" to a https url and then retrieve the ID that is returned. I can build the XML into a string no problem but how then heck do I go about posting/retrieving? I've come across something like this in my search: Dim oXML, sURL Dim sContents sURL = "https://domain/page.asp"
4
3719
by: michaelparkin | last post by:
Hi, Sorry to post what might seem like a trivial problem here, but its driving me mad! I have a simple https client that uses httplib to post data to a web server. When I post over http & https using curl the data is recieved by the web server with no problems.
0
1360
by: Amoril | last post by:
I am currently developing an app that will post an XML file ­(1 to 100MB+ in size) to an outside vendor application via HTTPS P­ost (doing this in a vb.net windows app). The vendor will then at some ­later date post an updated return XML file to my webserver (asp.net). T­he primary problem I'm having is getting the posted stream to load in a­n XMLDocument object. When trying to read the posted stream in­to the XMLDocument the following...
2
6954
by: Amoril | last post by:
I am currently developing an app that will post an XML file (1 to 100MB+ in size) to an outside vendor application via HTTPS Post (doing this in a vb.net windows app). The vendor will then at some later date post an updated return XML file to my webserver (asp.net). The primary problem I'm having is getting the posted stream to load in an XMLDocument object. When trying to read the posted stream into the XMLDocument the following error is...
7
4272
by: | last post by:
Hello, I would like to do the following from a asp.net button click: <form method="POST" action="https://www.1234.com/trans_center/gateway/direct.cgi"> <input type="hidden" name="Merchant" value="Merchant Name"> <input type="hidden" name="OrderID" value="Unique OrderID value"> <input type="hidden" name="email" value="Customers email address (OPTIONAL)">
0
10721
by: mahesh anasuri | last post by:
Hi all, I am new to this mailing list. Thankful if any one is using curl/linux version to and worked on Https. I have created certificates (PEM format) for client and server using openSSL. I am using Apache server/Linux platform and started server with "server certificate". I configured server to listen HTTPS service at port 443. I downloaded download.txt correctly from server using command as $curl --cacert cacert.pem ...
3
8043
by: Yourself | last post by:
Hi, I'm trying to post data to PayPal for a shopping cart, basically I want to replicate a form like the following, but create the variables dynamically from code behind: <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="seller@designerfotos.com"> <input type="hidden" name="item_name"
0
4130
by: shlim | last post by:
Currently I'm using VB.Net to perform a http/https multipart form post to a servlet. I'm able to perform the post using HttpWebrequest via GetRequestStream(). However, the servlet returned me with "The remote server returned an error: (500) Internal Server Error". Obviously, this means that I have not posted all the parameters as the servlet requested. But I just can't seem to find out what went wrong with my code. Hope someone can enlighten me,...
0
9933
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
9781
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11123
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
10836
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
9567
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
7960
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
7114
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5794
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...
3
3230
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.