Results 1 to 2 of 2
  1. #1
    swasti092 is offline Member
    Join Date
    Dec 2011
    Posts
    1
    Rep Power
    0

    Default try to create a xml from a external url and will pass that xml to another programme.

    Hi

    I am trying to create a .xml file from a java code and i culd not able to do this.
    please find the code below:-
    Java Code:
    import java.io.File;
    
    import javax.xml.soap.MessageFactory;
    import javax.xml.soap.Name;
    import javax.xml.soap.SOAPBody;
    import javax.xml.soap.SOAPConnection;
    import javax.xml.soap.SOAPConnectionFactory;
    import javax.xml.soap.SOAPFactory;
    import javax.xml.soap.SOAPHeader;
    import javax.xml.soap.SOAPMessage;
    
    import org.apache.commons.httpclient.HttpClient;
    import org.apache.commons.httpclient.methods.MultipartPostMethod;
    import org.apache.commons.httpclient.methods.multipart.FilePart;
    import org.apache.commons.httpclient.protocol.Protocol;
    
    import com.sun.org.apache.bcel.internal.generic.GETFIELD;
    
    
    public class MYCliass
    {
    private static String url= "https://http://www.java-forums.org/newthread.php?do=newthread&f=33";
    public static void main(String[] args) throws Exception 
    {
    	Protocol easyhttps = new Protocol("https", new MySSLFactory(), 443);
    	Protocol.registerProtocol("https", easyhttps);
    	HttpClient client = new HttpClient();
    	File file1 = new File("C:/Swasti/CUMI/CUMI/sender.xml");
    	String userPassword = "what:ever";
    	String encoding = new sun.misc.BASE64Encoder().encode (userPassword.getBytes());
    	SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
        SOAPConnection connection = soapConnectionFactory.createConnection();
        SOAPFactory soapFactory = SOAPFactory.newInstance();
        MessageFactory factory = MessageFactory.newInstance();
        SOAPMessage message = factory.createMessage();
        SOAPHeader header = message.getSOAPHeader();
        SOAPBody body = message.getSOAPBody();
        header.detachNode();
        System.out.println("..................");
        MultipartPostMethod mPost = new MultipartPostMethod(url);
        mPost.setRequestHeader ("Authorization", "Basic " + encoding);
        System.out.println("..................");
        mPost.setRequestHeader("Content-Type","multipart/form-data");
        mPost.addPart(new FilePart("ctr", file1, "application/xml","ISO-8859-1"));
        client.executeMethod( mPost );
        
        System.out.println("Done");
    }   
    }
    if you have any idea then please guide here to do this.

    Thanks
    -Sw
    Last edited by pbrockway2; 12-21-2011 at 10:11 AM. Reason: code tags added/password removed

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default Re: try to create a xml from a external url and will pass that xml to another program

    The URL you used is not a valid one.

    Java Code:
    private  static String url= "https://http://www.java-forums.org/newthread.php?do=newthread&f=33";

Similar Threads

  1. Need help with first Java programme.. Very new!
    By xxdave in forum New To Java
    Replies: 3
    Last Post: 11-22-2011, 05:46 PM
  2. Help with BinarytoDecimal programme
    By Thompson in forum New To Java
    Replies: 3
    Last Post: 02-23-2011, 11:43 PM
  3. cannot compile the programme
    By Roshini in forum New To Java
    Replies: 3
    Last Post: 09-06-2010, 12:02 PM
  4. How to create pass by reference??
    By --> xeiyne! in forum CLDC and MIDP
    Replies: 4
    Last Post: 04-08-2010, 07:43 PM
  5. Using JET to create external Python/Jython files??
    By mjwoodford in forum New To Java
    Replies: 0
    Last Post: 09-17-2009, 06:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •