Page 1 of 1

About Question enthuware.ocejws.v6.2.69 :

Posted: Sat Apr 12, 2014 8:02 pm
by himaiMinh
Technically, I think 4 options compiles and works.
I tried something like this example:

Code: Select all

 @WebServiceRef(value=LogWebService.class, type=LogLog.class)
It is not necessary to put values for the "value" and "type" attributes in this annotation.
But with these two attributes, the service can still be injected.

Re: About Question enthuware.ocejws.v6.2.69 :

Posted: Sun Apr 13, 2014 2:51 am
by fjwalraven
No, when you apply the @WebServiceRef on the Service class (i.e. LogWebService) these options will fail at runtime:

Code: Select all

@WebServiceRef(value=LogWebService.class, type=LogLog.class)
LogWebService o;                            
and

Code: Select all

@WebServiceRef(value=LogWebService.class)
LogWebService o;                            
Because a the server expects a @WebService annotation on the LogWebService class (which is not the generated SEI):
javax.servlet.ServletException: PWC1392: Error instantiating servlet class nl.notes.servlet.LogServlet
root cause

com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class nl.notes.servlet.LogServlet
root cause

com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Env-Prop: nl.notes.servlet.LogServlet/o@Field-Injectable Resource. Class name = nl.notes.servlet.LogServlet Field name=o@javax.jws.WebServiceRef@@@ into class nl.notes.servlet.LogServlet: Lookup failed for 'java:comp/env/nl.notes.servlet.LogServlet/o' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
root cause

javax.naming.NamingException: Lookup failed for 'java:comp/env/nl.notes.servlet.LogServlet/o' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException [Root exception is com.sun.xml.ws.model.RuntimeModelerException: A WebService annotation is not present on class: client.LogWebService]]
root cause

javax.naming.NamingException [Root exception is com.sun.xml.ws.model.RuntimeModelerException: A WebService annotation is not present on class: client.LogWebService]
root cause

com.sun.xml.ws.model.RuntimeModelerException: A WebService annotation is not present on class: client.LogWebService

Re: About Question enthuware.ocejws.v6.2.69 :

Posted: Wed Sep 24, 2014 12:30 am
by koitoer
I believe the snippet of the code should be .

public class LogServiceImpl implements LogLog

Because in any place of the question refers to this interface and that need to be used in order to set the type value in WebServiceRef annotation, please let me know if that is right? or if I have a misunderstand about it.

Re: About Question enthuware.ocejws.v6.2.69 :

Posted: Wed Sep 24, 2014 2:37 pm
by fjwalraven
Not necessarily, let me try to explain.

Just create a dynamic web project in an Eclipse project with a Glassfish server installed. Mine is called "WebServiceReferenceSIB".

When you deploy the following class:

Code: Select all

@WebService(serviceName="LogWebService", name="LogLog")
public class LogServiceImpl {
	@Oneway
	public void log(String msg) {
		System.out.println(msg);
	}
}
It will publish the WSDL on this address:
From the WSDL you can already see that the Generated SEI will have the name "LogLog":

Code: Select all


<definitions ...>
...
<portType name="LogLog">
<operation name="log">
<input wsam:Action="http://ws.notes.nl/LogLog/log" message="tns:log"/>
</operation>
</portType>
<binding name="LogLogPortBinding" type="tns:LogLog">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="log">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
</operation>
</binding>
<service name="LogWebService">
<port name="LogLogPort" binding="tns:LogLogPortBinding">
<soap:address location="http://localhost:8080/WebServiceReference/LogWebService"/>
</port>
</service>
</definitions>
from your src-folder generate the client artifacts:
You can see that the SEI is called LogLog:

Code: Select all

@WebService(name = "LogLog", targetNamespace = "http://ws.notes.nl/")
@XmlSeeAlso({
    ObjectFactory.class
})
public interface LogLog {
    @WebMethod
    @Oneway
    @RequestWrapper(localName = "log", targetNamespace = "http://ws.notes.nl/", className = "client.Log")
    @Action(input = "http://ws.notes.nl/LogLog/log")
    public void log(
        @WebParam(name = "arg0", targetNamespace = "")
        String arg0);

}
The code with the client artifacts should now be part of your project. Just create the Servlet from the question, add the Web project to your server, and hit the URL:
http://localhost:8080/WebServiceReference/log?log=yes

It should now work and show you an html page with "yes" in it.

Re: About Question enthuware.ocejws.v6.2.69 :

Posted: Thu Feb 19, 2015 12:51 am
by mujahed
Hi,

I am trying to understand how below option is correct.

@WebServiceRef(type=LogLog.class)"

In the explanation given, it suggests that "
When the @WebServiceRef is defined on a (field) property and refers to a generated SEI type (e.g. LogLog) - the value element must be present - the type element may be present
There is no "value" here. Is it the case that this is not referring to SEI but is referring to generated service type than this makes sense. But how did you arrive at the conclusion that this is referring to generated service?

Please help me understand the problem.

Thanks.

Re: About Question enthuware.ocejws.v6.2.69 :

Posted: Thu Feb 19, 2015 6:57 am
by fjwalraven
Hi,

In this question the @WebServiceRef annotation refers to the generated Service (i.e. LogWebService) like this:

Code: Select all

@WebServiceRef
LogWebService o; 
and not to the generated SEI (i.e. LogLog), like this:

Code: Select all

@WebServiceRef
LogLog o;  
Does it make sense now?