Results 1 to 2 of 2
- 12-21-2011, 09:01 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 1
- Rep Power
- 0
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:-
if you have any idea then please guide here to do this.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"); } }
Thanks
-SwLast edited by pbrockway2; 12-21-2011 at 09:11 AM. Reason: code tags added/password removed
- 12-21-2011, 01:59 PM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
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
-
Need help with first Java programme.. Very new!
By xxdave in forum New To JavaReplies: 3Last Post: 11-22-2011, 04:46 PM -
Help with BinarytoDecimal programme
By Thompson in forum New To JavaReplies: 3Last Post: 02-23-2011, 10:43 PM -
cannot compile the programme
By Roshini in forum New To JavaReplies: 3Last Post: 09-06-2010, 11:02 AM -
How to create pass by reference??
By --> xeiyne! in forum CLDC and MIDPReplies: 4Last Post: 04-08-2010, 06:43 PM -
Using JET to create external Python/Jython files??
By mjwoodford in forum New To JavaReplies: 0Last Post: 09-17-2009, 05:33 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks