• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using javax.xml.transform. Transformer class ???

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have a webservice for encrypting a password such as that provided by the method doProcess() in MyClient class below. Currently this method processes a soap message(not shown in the code snippet) containing the plain text password and prints out the encrypted password to the console using "System.out" as shown by method process() in class EncryptionHandler below.

Now, what I want to do is instead of printing the encrypted password to the console, I want to print it out to a file. As you can see method doProcess() takes an "OutputStream" as one of its arguments. Can anyone tell me how to use one of the sub-classes of OutputStream to print out the encrypted password to a file? I am not that familiar with webservices, so I don't know how the class javax.xml.transform.Transformer works in transforming an input into an output. I hope to receive a quick reply from you experts of Java Web Services.

Thank you.

regards,
sbk


import java.io.InputStream;
import javax.xml.transform.Source;
import javax.xml.transform.Result;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerException;

import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
public class MyClient
{

public void doProcess(boolean logoff, OutputStream out)
throws ServiceException, SOAPException, IOException, MalformedURLException, TransformerException
{
...
...
...
...
// Here "is" is an InputStream object which is basically a styleSheet
TransformerFactory transFactory = TransformerFactory.newInstance();
Transformer transformer = transFactory.newTransformer(new StreamSource(is));

transformer.transform(new StreamSource(in), new StreamResult(out));
}
}

public class EncryptionHandler
{
public void process()
{
MyClient eclient = new MyClient();
eClient.doProcess(true, System.out);
}
}
 
rubbery bacon. rubbery tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic