Help with small dotnet project

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need some help on a project that connects to a secure web server using
basic authentication and a Base64 encoded userid and password, and posts a
urlencoded xml file.
 
Hi Walter,

|| I need some help on a project that connects to a secure web
|| server using basic authentication and a Base64 encoded userid
|| and password, and posts a urlencoded xml file.

The more specific your questions, the better the chance of something
useful coming back.

How's about breaking that lot down and spreading them out over a period as
you develop your project. You may find it more effective to put some of your
questions to us here,
some in
news://msnews.microsoft.com/microsoft.public.dotnet.xml
and some in
news://msnews.microsoft.com/microsoft.public.dotnet.framework.aspnet.

Welcome to the groups, and see you later. ;-)

Regards,
Fergus
 
Hto base64 encode in vb.net, how to authenticate to a web server using basic
authentication in vb.net
Thanks.
 
Or, how to write these java functions in dotnet:

private String getAuthorization() {
String uidpwd = userID + ":" + password;

// Encode the user ID and password
byte[] inputBytes = uidpwd.getBytes();
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(inputBytes);
}

private void sendRequest(HttpURLConnection httpConnection
, String authorization
, String request) throws IOException {
httpConnection.setRequestProperty("Authorization","BASIC " +
authorization);
httpConnection.setUseCaches(false);
PrintWriter writer = new
PrintWriter(httpConnection.getOutputStream());
writer.println(request);
writer.close();
}

String strAuth = getAuthorization();
StringBuffer sbufPost = new StringBuffer();
String fileContent = URLEncoder.encode(readXML(requestFile));
sbufPost.append("&Param1=" + fileContent);

// Create the Http connection
HttpURLConnection httpConnection = createConnection();

// Send the XML request
try {
sendRequest(httpConnection, strAuth, sbufPost.toString());
 
Thanks, that helps a lot. I have a C## snippet to do the basic
authentication. Now, my question is, how to send just a string, not a byte
array, is there something else beside httpwebrequest to use? Thanks.

I will post complete code if I get it up and running, this is to connect to
a Weblogic server.

HttpWebRequest req =
(HttpWebRequest)WebRequest.Create("https://secure.test.com");
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.Headers.Add("Authorization: Basic base64encodeduid:pwd");
 
* said:
Thanks, that helps a lot. I have a C## snippet to do the basic
authentication. Now, my question is, how to send just a string, not a byte
array, is there something else beside httpwebrequest to use? Thanks.

I will post complete code if I get it up and running, this is to connect to
a Weblogic server.

HttpWebRequest req =
(HttpWebRequest)WebRequest.Create("https://secure.test.com");
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.Headers.Add("Authorization: Basic base64encodeduid:pwd");

You can convert a string to a byte array using
'System.Text.Encoding.<...>.GetBytes'.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Improve your quoting style:
<http://learn.to/quote>
<http://www.plig.net/nnq/nquote.html>
 
Back
Top