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

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


    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 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;
    public class MYCliass
    private static String url= "https://";
    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();
        MultipartPostMethod mPost = new MultipartPostMethod(url);
        mPost.setRequestHeader ("Authorization", "Basic " + encoding);
        mPost.addPart(new FilePart("ctr", file1, "application/xml","ISO-8859-1"));
        client.executeMethod( mPost );
    if you have any idea then please guide here to do this.

    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
    Colombo, Sri Lanka
    Blog Entries
    Rep Power

    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://";

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