This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have a requirement to use EJB 3.1 where only some of its methods will be exposed as webservices and will be consumed by our external client applications where as other components of our application(Servlet etc) should have access to all of its method. At this point,Im not even sure if it is possible with single EJB to achieve both.
E.g. If EJB has 3 method,the external client will be exposed to 1 or 2 method where as the other component of the application should have access to all of the EJB methods.
On the Java class that implements your Web service, specify the @WebMethod annotation on each method that you want to customize for the service. You can use this annotation to exclude a method from your service. By default, all public methods are exposed in a service, including inherited methods that are below the Object class.
Sure you can. You expose your EJB using a Web Service endpoint interface and a Remote business interface. You specify the methods you need for each view in the interface (as long as it's not Stateful, of course). You can even use the same interface for the Remote client view and the Web Service endpoint, though that's not necessarily a good idea.
Be advised though, that your parameters and return value have to fulfill all the requirements for both SOAP and EJB.
Then you declare the methods you want to expose in their relevant interfaces. If you want to expose a WebService superset in the remote EJB, you can have the Remote interface extend the Endpoint interface and declare the additional methods... For configuration of the two, check the spec. But they are easy to combine since EJB 3.
You can easily inject the remote view into a Servlet as @EJB, and use the WebService at the same time. It should be possible to reuse the Remote interface as a web service endpoint interface and use @WebMethod annotations to expose the methods you need in the web service as opposed to the remote ejb, but I've never done it as it would look kind of dirty, and it may cause problems later on when changes are required. Better to use two different interfaces.
I hope that answers your question. Otherwise I misunderstood again. :/