Hi,
I have created simple JSF page and managed bean for that page. I'm using Eclipse 3.5 SR1 ("for Java EE Developers" version) and Glassfish v2.1.
Here is my page:
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<html>
<head>
<title>Simple page</title>
</head>
<body>
<f:view>
<h:outputText value="#{messages.next}" />
</f:view>
</body>
</html>
Managed bean:
public class Messages {
public String getNext() {
return "Hello";
}
}
Next I have added reference to Web Service (New -> Web Service Client -> ...) and tried to use it in managed bean.
public class Messages {
private MessageService service;
public Messages() {
service = new MessageServiceLocator();
}
public String getNext() throws RemoteException, ServiceException {
return service.getBasicHttpBinding_IMessageService().getRandomMessage();
}
}
Abowe version works fine, but when tried use @WebServiceRef (instead of creating MessageServiceLocator instance in constructor) Web Service proxy instance is never indjected (it is always null). This version don't work because of NullPointerException exception from getNext operation.
public class Messages {
private @WebServiceRef MessageService service;
public Messages() {
// service = new MessageServiceLocator();
}
public String getNext() throws RemoteException, ServiceException {
return service.getBasicHttpBinding_IMessageService().getRandomMessage();
}
}
What I have missed? What I have to do more to use @WebServiceRef correctly?
Thanks, Rafal