4

シナリオ: Web サービスを @Stateless Bean として作成し、ejb jar としてパッケージ化します。結果 - wsdl ファイルにアクセスできません。

目標: Web からアクセス可能な wsdl ファイルを含む ejb jar パッケージを使用して、@WebServices を @Stateless セッションとして使用したいと考えています。

ウェブサービス:

@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;
    }

}

この場合、私は得る

無効な wsdl リクエスト http://192.168.44.48:8181/ws.isp.SecurityService/SecurityService

wsdl にアクセスしようとすると、wsdlLocation の説明を使用しないと、空白のページが表示されます。

それ自体がうまく機能するWebサービス。

Q1: Web サービスの wsdl ファイルの場所を ejb jar でステートレスとして記述する規則は何ですか?

Q2: Maven のパッケージング中に wsdl ファイルを生成することは可能ですか?

Q3: @Stateless や @EJB などのアノテーションを持つ Web サービスの wsdl ファイルを生成する方法 (現在、これらのアノテーションをコメントすることによってのみ生成できます)

環境: mave 2、ejb 3.1、glassfish v3、jax-ws 2.x

ありがとうございました!

4

2 に答える 2

2

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).

于 2010-05-13T21:04:48.690 に答える
0

問題は壊れたページインスペクターにありました.. http://192.168.44.48:8181/ws.isp.SecurityService/SecurityService?wsdlに行くと 、ウェブインスペクターに空白のページが表示されました。

偽物でごめんなさい。

于 2010-05-23T10:18:01.797 に答える