This discussion is archived
0 Replies Latest reply: May 1, 2013 4:56 PM by 966626 RSS

WebService not initialized

966626 Newbie
Currently Being Moderated
I am experimenting with WebServices, when i used form a JSP/Servlet client the webservice is working fine:
package org.me.calculator.client;

import com.delunasaenz.scoreboard.Game;
import com.delunasaenz.scoreboard.ScoreboardWS;
import com.delunasaenz.scoreboard.ScoreboardWSService;
import java.io.*;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.WebServiceRef;
import javax.xml.ws.soap.SOAPFaultException;

/**
 *
 * @author mg116726
 */
@WebServlet(name="ClientServlet", urlPatterns={"/ClientServlet"})
public class ClientServlet extends HttpServlet {
    @WebServiceRef(wsdlLocation = "http://localhost:8080/ScoreboardApp/ScoreboardWSService?wsdl")
    public ScoreboardWSService service;
    
    @Resource
    protected WebServiceContext context;
    
    /** 
    * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            out.println("<h2>Servlet ClientServlet at " + request.getContextPath () + "</h2>");
                
                ScoreboardWS port = service.getScoreboardWSPort();
But using that in a JavaFX code service is null:
import com.delunasaenz.scoreboardWS.Game;
import com.delunasaenz.scoreboardWS.ScoreboardWS;
import com.delunasaenz.scoreboardWS.ScoreboardWSService;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javax.annotation.Resource;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.WebServiceRef;

/**
 *
 * @author charly
 */
public class ScoreBoardController implements Initializable {
    @WebServiceRef(wsdlLocation = "http://localhost:8080/ScoreboardApp/ScoreboardWSService?wsdl")
    public ScoreboardWSService service;
    
    @Resource
    protected WebServiceContext context;
    
    @FXML
    private ChoiceBox leagueSelection;
    
    
    @FXML
    private void handleButtonAction(ActionEvent event) {
        
    }
    
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        leagueSelection.getSelectionModel().select(0);
        leagueSelection.getSelectionModel().selectedIndexProperty()
                .addListener(new ChangeListener<Number>() {
            @Override
            public void changed(ObservableValue<? extends Number> ov,
                                                Number t, Number t1) {
                
                ScoreboardWS port = service.getScoreboardWSPort();
Am I doing something wrong?
Greetings and thanks in advance.
NetBeans 7.3 , Java 7, GlasFish 3

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points