@WebServices as @Stateless bean session in ejb jar

Scenario: After creating several web services as @Stateless bean, pack it as an ejb jar. Result - access to the wsdl file cannot be.

Purpose: I want to use @WebServices as an @Stateless session, using jj jar packaging with the available wsdl file form.

Web service:

@Stateless @WebService(serviceName = "ws.isp.SecurityService", wsdlLocation = "META-INF/wsdl/SecurityService.wsdl") public class SecurityService{ @EJB private Kerberos factory; @EJB private UsersServiceBean uService; public SecurityService() { } @WebMethod @WebResult(name = "SimpleResponse") public SimpleResponse LogOut( @WebParam(name = "sessionUUID", targetNamespace = "https://secure.co.ua/ws/") String sessionUUID ) { SimpleResponse resp = new SimpleResponse(); try{ factory.removeSession(sessionUUID); resp.setError(WSErrorCodes.SUCCESS); }catch (Exception e){ e.printStackTrace(); resp.setError(WSErrorCodes.UNRELOSVED_ERROR); } return resp; } @WebMethod public MySession logIn( @WebParam(name = "username", targetNamespace = "https://secure.co.ua/ws/") String username, @WebParam(name = "password", targetNamespace = "https://secure.co.ua/ws/") String password){ MySession result = new MySession(); try { UserSession us = factory.creatSession(uService.getUser(username, password).getId()); result.setSessionID(us.getSessionUUID().toString()); result.setError(WSErrorCodes.SUCCESS); } catch (NullPointerException e){ e.printStackTrace(); result.setError(WSErrorCodes.UNRELOSVED_USER); } catch (Exception e){ e.printStackTrace(); result.setError(WSErrorCodes.UNRELOSVED_ERROR); } return result; } } 

In this case, I get

Invalid wsdl request http://192.168.44.48:8181/ws.isp.SecurityService/SecurityService

when I try to access wsdl and if not use the wsdlLocation description, I get a blank page.

Web service as it works well.

Q1: what is the rule for describing the location of the wsdl file for web services as a stateless person in an ejb bank.

Q2: Is it possible to generate a wsdl file during maven packaging?

Q3: how to generate a wsdl file for a web service where we have an annotation like @Stateless and @EJB (currently I can only generate it by commenting on these annotations)

environment: mave 2, ejb 3.1, glassfish v3, jax-ws 2.x

Thanks!

+4
source share
2 answers

the problem was in the broken page inspector .. so when I go to http://192.168.44.48:8181/ws.isp.SecurityService/SecurityService?wsdl I have a blank page in the web inspector.

sorry for the fake.

0
source

Q1. which is the rule for describing the location of the wsdl file for web services as stateless in jj jjj.

If provided through the wsdllocation attribute, Metro seems to read the WSDL using the class loader, which makes the META-INF/wsdl JJB JAR a good choice for hosting WSDL. I tested on my side with the following EJB:

 @Stateless @WebService(wsdlLocation = "META-INF/wsdl/HelloService.wsdl") public class HelloService { public String hello(String name) { return "Hello, " + name + "!"; } } 

WSDL is located in src/main/resources/META-INF/wsdl/ in my EJB maven project.

And access to http: // localhost: 8080 / HelloServiceService / HelloService? Wsdl shows my WSDL (and not dynamically generated).

So the question is: have you tried http://192.168.44.48:8181/ws.isp.SecurityService/SecurityService?wsdl ?

Q2. Is it possible to generate a wsdl file during maven packaging?

jaxws-maven-plugin:wsgen can do this (see genWsdl ), but I have to admit that I'm completely lost.

When using the Java-based approach, you either allow the JAX-WS runtime to generate WSDL dynamically during deployment ~ or ~ you provide a static version and use wsdlLocation . However, generating WSDL and using wsdlLocation does not have much IMO value. What is the point? The wsgen documentation somehow confirms this:

By default, wsgen does not create a WSDL file. This flag is optional and will cause wsgen to generate a WSDL file and is usually used only so that the developer can view the WSDL before deploying the endpoint.

Q3. how to generate a wsdl file for a web service where we have an annotation such as @Stateless and @EJB (currently I can only generate it by commenting on these annotations)

I do not understand this question, and I do not understand why you want to generate WDSL (see above).

+2
source

Source: https://habr.com/ru/post/1309642/


All Articles