Calling a .NET Web Service : SOAP « JDK 6 « Java






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

1.Call google web service and deal with the return with SOAPMessage
2.Create SOAP message
3.Generate DOM with SOAP message
4.Output SOAP message with XML transformer
5.Sending a SOAP Message
6.Processing a SOAP Message