Calling a .NET Web Service
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.net.URL;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.xml.sax.InputSource;
public class Main {
public static void main(String[] args) throws Exception {
URL webSvcGetURL = new URL("http://www.server.net/Webservices");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(webSvcGetURL
.openStream()));
SAXSource saxSource = new SAXSource(new InputSource(bufferedReader));
String curDir = new File(".").getCanonicalPath();
StreamSource xlstStreamSource = new StreamSource(new File(curDir + File.separator + "style.xsl"));
File resultHTMLFile = new File(curDir + File.separator + "output.html");
StreamResult streamResult = new StreamResult(resultHTMLFile);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(xlstStreamSource);
transformer.transform((Source) saxSource, streamResult);
}
}
Related examples in the same category