Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Translating JAVA code to VB.net?

Status
Not open for further replies.

Bilberry

Programmer
Dec 17, 2007
111
NL
Dear Friends,
I have really tried everything but i cannot translate the JAVA code into VB.net. Could anybody translate this? A big golden star for the final solution:

Code:
import java.io.File;

import javax.ws.rs.core.MediaType;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.URI;
import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.httpclient.methods.multipart.FilePart;
import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.methods.multipart.StringPart;

public class MultipartRecord
{
    public static void main(String[] args)
    {
        try
        {
            File f = new File("c:\\csvs\\image1.jpg");
            
            HttpClient client = new HttpClient();

                PostMethod postMethod = new 
                PostMethod("[URL unfurl="true"]http://localhost/networking/rest/record/HOMEPAGE/");[/URL]
            
                postMethod.setRequestHeader("Cookie", "JSESSIONID=A741270662A86F796DA16646F0708C43");

            FilePart filePart = new FilePart("image_field", f);
            filePart.setContentType(MediaType.APPLICATION_OCTET_STREAM);

            StringPart sp = new StringPart("__xml_data__",
              "<platform><record><field1>Some text field</field1>"
            + "<image_field>image1.jpg</image_field></record></platform>");

            sp.setContentType(MediaType.APPLICATION_XML);
            
            final Part[] parts = { sp, filePart };

            postMethod.setRequestEntity(new MultipartRequestEntity(parts, postMethod.getParams()));

            int executeMethod = client.executeMethod(postMethod);
        }
        catch(Exception e)
        {
            System.out.println("Exception");
        }
    }
}
 
Suggestion
1) Describe what this program does/should do
2) Post you best version of the translation and explain what is happening and why it is not doing what you want



Lion Crest Software Services
Anthony L. Testi
President
 
Sorry i have put more information on the VB6 part. It should be translated into VB6 in stead of .NET.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top