-
Using javax.xml.transform.Transformer ???
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);
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks