Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 17th, 2005, 10:53 AM
Registered User
 
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Java to Asp .Net

Dear Friends

Any body can help in converting this piece of code from Java to Asp. Net.

public createURL(... {
    . . .
    this.metodo = "http";
    this.host = "<application>.<customer>.azormarket.com";
    this.puerto = 8086;
    this.trx = "/xml/FullAvail1_0.do";

    try{
        this.url = new URL(metodo, host, Integer.parseInt(puerto), trx);
    }
    catch (MalformedURLException e)
    { . . . }
    }
    public String sendAndReceive(String xmlReq) throws . . .
    { HttpURLConnection uc=null;

    // Codificación en Base64
    String userPwd = "<user>" + ":" + "<password>";
    String userPassword = Base64Converter.encode(userPwd.getBytes());

    // Parametro HTTP llamado xml
    xmlReq = "xml=" + xmlReq;
    try {
    uc = (HttpURLConnection) url.openConnection();
    Permission per = uc.getPermission();

    uc.setRequestProperty("Authorization", "Basic " + userPassword);
    uc.setRequestMethod("POST");
    uc.setRequestProperty("Content-length",
    String.valueOf(xmlReq.getBytes().length));
    uc.setDoInput(true);
    uc.setDoOutput(true);

    //Write POST
    OutputStream out = uc.getOutputStream();
    out.write(xmlReq.getBytes());
    out.flush();

    //Read Response
    String line;
    StringBuffer xmlResponse = new StringBuffer();
    InputStream content = (InputStream) uc.getInputStream();
    BufferedReader in;
    in = new BufferedReader(new InputStreamReader(content));
    while((line = in.readLine()) != null) {
    xmlResponse.append(line); }
    } finally {
        try { in.close(); } catch(Exception e){};
        try { out.close(); } catch(Exception e){};
        try { uc.disconnect(); }
    catch(Exception e){}; }
    catch (FileNotFoundException fnfe) { . . . } catch (Exception e){ . . .
    } return xmlResponse.toString();
}</html>

 
Old February 1st, 2011, 04:36 PM
Registered User
 
Join Date: Feb 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

¿Vives en Puerto Rico?





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.Net Table and Java Script ramuis78 ASP.NET 2.0 Basics 3 February 27th, 2007 02:12 AM
ASP.NET 2.0 + Java-Script DuhMaster ASP.NET 2.0 Basics 0 January 9th, 2007 06:16 AM
Java Or ASP.Net fongklem Assembly Language 0 June 5th, 2006 10:20 AM
java script in ASP.Net buddy_gg VS.NET 2002/2003 1 July 11th, 2003 03:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.