简体   繁体   English

在Java中部署Web服务

[英]Deploying web services in java

I have a java web service. 我有一个Java Web服务。 The actual operations of it are not important. 它的实际操作并不重要。 But what is important is the return value. 但是重要的是返回值。 It is returning a class I created called GetReturnCapsule . 它正在返回我创建的名为GetReturnCapsule的类。


    /**
     * Web service operation
     */
    @WebMethod(operationName = "get")
    public GetReturnCapsule get(@WebParam(name = "company")
    final String company, @WebParam(name = "timeStamp")
    final long timeStamp, @WebParam(name = "hash")
    final int hash)
    {
       ...stuff
    }

Here is the return capsule code. 这是返回胶囊代码。 Its pretty much just a wrapper for some data. 它几乎只是一些数据的包装。


public class GetReturnCapsule
{
    long timeStamp;
    List ips;
    int hash;

    public GetReturnCapsule(long timeStamp,Listips,int hash)
    {
        this.timeStamp = timeStamp;
        this.ips = ips;
        this.hash = hash;
    }

    public long getTimeStamp()
    {
        return timeStamp;
    }

    public int getHash()
    {
        return hash;
    }

    public List getIPs()
    {
        return ips;
    }

}

The webservice compiles correctly. Web服务正确编译。 However, when I try to deploy it, it get the following error from Glashfish. 但是,当我尝试部署它时,它从Glashfish收到以下错误。


SEVERE: Class [ com/compunetix/vsd/stix/server/webservices/GetReturnCapsule ] not found. Error while loading [ class com.compunetix.vsd.stix.server.webservices.GetIp ]
SEVERE: Class [ com/compunetix/vsd/stix/server/webservices/GetReturnCapsule ] not found. Error while loading [ class com.compunetix.vsd.stix.server.webservices.GetIp ]
SEVERE: Exception while invoking class org.glassfish.ejb.startup.EjbDeployer prepare method
SEVERE: Exception while preparing the app
SEVERE: Exception while preparing the app : Unable to load EJB module.  DeploymentContext does not contain any EJB  Check archive to ensure correct packaging for C:\Documents and Settings\dvargo\My Documents\STix1030Netbeans\STixWebService\build\web
SEVERE: Class [ com/compunetix/vsd/stix/server/webservices/GetReturnCapsule ] not found. Error while loading [ class com.compunetix.vsd.stix.server.webservices.GetIp ]
SEVERE: Class [ com/compunetix/vsd/stix/server/webservices/GetReturnCapsule ] not found. Error while loading [ class com.compunetix.vsd.stix.server.webservices.GetIp ]
SEVERE: Exception while invoking class org.glassfish.ejb.startup.EjbDeployer prepare method
SEVERE: Exception while preparing the app
SEVERE: Exception while preparing the app : Unable to load EJB module.  DeploymentContext does not contain any EJB  Check archive to ensure correct packaging for C:\Documents and Settings\dvargo\My Documents\STix1030Netbeans\STixWebService\build\web

My main question is, can is it possible to actually return a custom class using java web services. 我的主要问题是,是否可以使用Java Web服务实际返回自定义类。 My second question is, any idea on how I can fix this based off of these error messages? 我的第二个问题是,关于如何根据这些错误消息解决此问题的任何想法吗?

Yes you can return custom classes with java web services. 是的,您可以使用Java Web服务返回自定义类。 As for your second question, it looks like you are missing a dependency in your ear. 至于第二个问题,似乎您的耳朵里缺少依赖性。 Check out this post . 看看这个帖子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM