The SQLData News service returns news from various sources, including Yahoo!
<?xml version='1.0' encoding='UTF-8' ?> <definitions name ='SQLDataSoap' targetNamespace = 'http://www.SoapClient.com/xml/SQLDataSoap.wsdl' xmlns:tns='http://www.SoapClient.com/xml/SQLDataSoap.wsdl' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns='http://schemas.xmlsoap.org/wsdl/'> <types> <schema targetNamespace='http://www.SoapClient.com/xml/SQLDataSoap.xsd' xmlns='http://www.w3.org/2001/XMLSchema'> </schema> </types> <message name='ProcessSRL'> <part name='SRLFile' type='xsd:string'/> <part name='RequestName' type='xsd:string'/> <part name='key' type='xsd:string'/> </message> <message name='ProcessSRL2'> <part name='SRLFile' type='xsd:string'/> <part name='RequestName' type='xsd:string'/> <part name='key1' type='xsd:string'/> <part name='key2' type='xsd:string'/> </message> <message name='ProcessSRLResponse'> <part name='return' type='xsd:string'/> </message> <message name='ProcessSQL'> <part name='DataSource' type='xsd:string'/> <part name='SQLStatement' type='xsd:string'/> <part name='UserName' type='xsd:string'/> <part name='Password' type='xsd:string'/> </message> <message name='ProcessSQLResponse'> <part name='return' type='xsd:string'/> </message> <portType name='SQLDataSoapPortType'> <operation name='ProcessSRL' parameterOrder='SRLFile RequestName key'> <input message='tns:ProcessSRL' /> <output message='tns:ProcessSRLResponse' /> </operation> <operation name='ProcessSRL2' parameterOrder='SRLFile RequestName key1 key2'> <input message='tns:ProcessSRL2' /> <output message='tns:ProcessSRLResponse' /> </operation> <operation name='ProcessSQL' parameterOrder='DataSource SQLStatement UserName Password'> <input message='tns:ProcessSQL' /> <output message='tns:ProcessSQLResponse' /> </operation> </portType> <binding name='SQLDataSoapBinding' type='tns:SQLDataSoapPortType' > <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http' /> <operation name='ProcessSRL' > <soap:operation soapAction='http://soapclient.com/SQLDataSRL' /> <input> <soap:body use='encoded' namespace='http://www.SoapClient.com/xml/SQLDataSoap.xsd' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' /> </input> <output> <soap:body use='encoded' namespace='http://www.SoapClient.com/xml/SQLDataSoap.xsd' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' /> </output> </operation> <operation name='ProcessSRL2' > <soap:operation soapAction='http://soapclient.com/SQLDataSRL' /> <input> <soap:body use='encoded' namespace='http://www.SoapClient.com/xml/SQLDataSoap.xsd' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' /> </input> <output> <soap:body use='encoded' namespace='http://www.SoapClient.com/xml/SQLDataSoap.xsd' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' /> </output> </operation> <operation name='ProcessSQL' > <soap:operation soapAction='http://www.SoapClient.com/SQLDataSQL' /> <input> <soap:body use='encoded' namespace='http://www.SoapClient.com/xml/SQLDataSoap.xsd' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' /> </input> <output> <soap:body use='encoded' namespace='http://www.SoapClient.com/xml/SQLDataSoap.xsd' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' /> </output> </operation> </binding> <service name='SQLDataSoap' > <port name='SQLDataSoapPortType' binding='tns:SQLDataSoapBinding' > <soap:address location='http://soapclient.com/xml/SQLDataSoap.wsdl' /> </port> </service> </definitions>
If you invoke wsdl2java on the above WSDL document, you can run this client to interact with the service. The client will pop up an HTML panel and display the returned news document. Note that the client may print various Swing related stack traces, which can be safely ignored.
package news; import javax.naming.InitialContext; import java.awt.Dimension; import java.awt.event.WindowEvent; import java.awt.event.WindowAdapter; import java.io.IOException; import javax.swing.JFrame; import javax.swing.JEditorPane; import javax.swing.JScrollPane; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; public class Client extends JFrame implements HyperlinkListener { public static void main(String[] args) throws Exception { | InitialContext ctx = new InitialContext(); | SQLDataSoap service = (SQLDataSoap) ctx.lookup("xmlrpc:soap:news.SQLDataSoap"); | SQLDataSoapPortType news = service.getSQLDataSoapPortType(); | Client cl = new Client(news.processSRL("NEWS.SRI","yahoo","")); } public Client(String text) { | super("SQLDataSoap News"); | pane = new JEditorPane("text/html", text); | JScrollPane scroll = new JScrollPane(pane); | pane.addHyperlinkListener(this); | pane.setText(text); | pane.setEditable(false); | getContentPane().add(scroll); | setSize(new Dimension(600, 400)); | addWindowListener(new WindowAdapter() { | | public void windowClosing(WindowEvent e) { | | | System.exit(0); | | } | }); | setVisible(true); } public void hyperlinkUpdate(HyperlinkEvent e) { | if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { | | try { | | | pane.setPage(e.getURL()); | | } catch (IOException ex) { | | | ex.printStackTrace(); | | } | } } private final JEditorPane pane; }
Please refer to the README file for details on how to build and run the example.
Copyright © 2003, 2004 Novell, Inc. All rights reserved. Copyright © 2001, 2002, 2003 SilverStream Software, LLC. All rights reserved.