Project Name: JavaFXWebClient
Finish
2. Right click JavaFXWebClient in Projects window and select New -> Web Service Client
(You need to have Java EE plugin installed. This is available in Tools -> Plugins.)
WSDL URL: http://www.webservicex.net/stockquote.asmx?WSDL
3. Right click in source editor window -> Insert Code -> Call Web Service Operation
This automatically adds method definitions corresponding to Web service calls, for example the following piece of code:
private static String getQuote(java.lang.String symbol) {
net.webservicex.StockQuote service = new net.webservicex.StockQuote();
net.webservicex.StockQuoteSoap port = service.getStockQuoteSoap();
return port.getQuote(symbol);
}
4. Write your JavaFX Web service client using the methods defined in the previous step.
public class JavaFXWebClient extends Application {
Label quoteLbl = new Label();
TextField textFld = new TextField();
Button btn = new Button();
@Override
public void start(Stage primaryStage) {
btn.setText("Get IBM Quote");
btn.setOnAction(new EventHandler
@Override
public void handle(ActionEvent event) {
quoteLbl.setText(getQuote("IBM"));
textFld.setText(getQuote("IBM"));
}
});
Group root = new Group();
root.getChildren().add(0,btn);
root.getChildren().add(1,quoteLbl);
root.getChildren().add(2,textFld);
root.getChildren().get(0).setLayoutX(50);
root.getChildren().get(0).setLayoutY(70);
root.getChildren().get(1).setLayoutX(50);
root.getChildren().get(1).setLayoutY(10);
root.getChildren().get(2).setLayoutX(50);
root.getChildren().get(2).setLayoutY(40);
Scene scene = new Scene(root, 700, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
References
http://lehelsipos.blogspot.ro/2012/09/javafx-22-webservice-example.html
http://www.actionscript.org/forums/showthread.php3?t=70742
https://netbeans.org/kb/docs/websvc/jax-ws.html
https://netbeans.org/kb/docs/websvc/intro-ws.html
No comments:
Post a Comment