views:

424

answers:

2

Hi!

Scenario: Creating some web service as @Stateless bean, package it as ejb jar. Result - can`t access to wsdl file.

Goal: I want to use @WebServices as @Stateless session using ejb jar packaging with accessible wsdl file form web.

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 getting

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

when I try to access to wsdl and if do not use description of wsdlLocation I getting blank page.

Web service as it self working good.

Q1: what is the rule of describing wsdl file location for web services as stateless in ejb jar.

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

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

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

Thank you!

A: 

Q1. what is the rule of describing wsdl file location for web services as stateless in ejb jar.

If provided via the wsdllocation attribute, it seems that Metro reads WSDLs using the classloader which makes META-INF/wsdl of the EJB JAR a decent choice to place WSDLs. 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 + "!";
    }
}

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

And accessing http://localhost:8080/HelloServiceService/HelloService?wsdl shows my WSDL (and not a dynamically generated one).

So the question is, did you try http://192.168.44.48:8181/ws.isp.SecurityService/SecurityService?wsdl?

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

The jaxws-maven-plugin:wsgen goal can do that (see the genWsdl parameter) but I must admit that I'm completely lost now.

When using a Java-first approach, you either let the JAX-WS runtime generate the WSDL dynamically at deploy time ~or~ you provide a static version and use wsdlLocation. However, generating the WSDL and using the wsdlLocation doesn't make much sense IMO. What's the point? The documentation of wsgen somehow confirms this:

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

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

I don't understand the question and I don't understand why you want to generate the WDSL (see above).

Pascal Thivent
>Q1 . yes, i try to http://localhost:8080/HelloServiceService/HelloService?wsdl , but instead of wsdl I get> Invalid wsdl request http://192.168.44.48:8181/ws.isp.SecurityService/SecurityService>Q2 Thank you, It should help>Q3 - the problem is in wsgen - it can`t generate wsdl from java file if annotation like @Stateless and @EJB used there.
kislo_metal
A: 

problem was in broken page inspector.. so whene I go to http://192.168.44.48:8181/ws.isp.SecurityService/SecurityService?wsdl I got blank page in web inspector.

sorry for fake.

kislo_metal