未生成 WebService。/已生成

WebService not being produced./Generated

我正在尝试在我的本地主机上部署网络服务,但它似乎没有生成 "Endpoint"。

我不知道我是怎么搞砸的:(

我正在使用 apache cxf 2.7.1 和 glassfish 3.1。我什至尝试添加 ear 库。

这是我的构建路径:

我的项目浏览器看起来像这样:

我的webservice和webservice接口都有注释,如下图:

Code for webservice interface (I removed the other some parts to make the code shorter)

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

import no.solarsoft.venus2.webservice.exception.WebServiceException;
import no.solarsoft.venus2.webservice.queryoptions.ParticipantQuery; 
import no.solarsoft.venus2.webservice.queryoptions.ParticipantQueryParameterKey;
import no.solarsoft.venus2.webservice.queryoptions.QueryParameter;

@WebService()
public interface WebServiceVenus2Interface {

    /**
     * FETCHING DATA FROM DATABASE
     *
     */
    @WebMethod
    public void Foo(ParticipantQueryParameterKey pqpk);

    @WebMethod
    public String test();

    @WebMethod
    public String sayHello(String string) throws WebServiceException;

The code for my web service:

import javax.annotation.Resource;
import javax.jws.WebParam;
import javax.servlet.http.HttpServletRequest;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;

import no.solarsoft.venus2.datamanager.CRUDOperation;
import no.solarsoft.venus2.datamanager.DataManager;
import no.solarsoft.venus2.entities.GradeScale;
import no.solarsoft.venus2.enums.ImageType;
import no.solarsoft.venus2.exception.DataAccessException;
import no.solarsoft.venus2.exception.InstanceNotFoundException;
import no.solarsoft.venus2.service.EmailService;
import no.solarsoft.venus2.webservice.exception.ParameterValidationException;
import no.solarsoft.venus2.webservice.exception.WebServiceException;
import no.solarsoft.venus2.webservice.exception.WebServiceFaultBean;
import no.solarsoft.venus2.webservice.queryoptions.ParticipantQuery;
import no.solarsoft.venus2.webservice.queryoptions.ParticipantQueryParameterKey;
import no.solarsoft.venus2.webservice.queryoptions.QueryParameter;


// @Stateless()
@javax.jws.WebService(endpointInterface = "no.solarsoft.venus2.webservice.WebServiceVenus2Interface", serviceName = "WebServiceVenus2Service")
public class WebServiceVenus2 implements WebServiceVenus2Interface {

    private DataManager dataManager = DataManager.getInstance();
    private static final Logger log = Logger.getAnonymousLogger();
    @Resource
    WebServiceContext wsContext;

    @Override
    public void Foo(ParticipantQueryParameterKey pqpk) {}

    private void logEntered(String login) {
        log.info(MessageFormat.format("{0}: ''{1}'' entered web service method ''{2}()''",
                WebServiceVenus2.class.getSimpleName(), login, getMethodName()));
    }

    private String getClientIp() {
        MessageContext mc = wsContext.getMessageContext();
        HttpServletRequest req = (HttpServletRequest) mc.get(MessageContext.SERVLET_REQUEST);
        return req.getRemoteAddr();
    }

    /**
     * Get the method name for a depth in call stack. <br />
     * Utility function
     * 
     * @param depth
     *            depth in the call stack (0 means current method, 1 means call method, ...)
     * @return method name
     */
    public static String getMethodName() {

        final StackTraceElement[] ste = Thread.currentThread().getStackTrace();
        return ste[3].getMethodName(); // Thank you Tom Tresansky
    }

    /**
     * FETCHING DATA FROM DATABASE
     */
    @Override
    public String test() {
        String ip = getClientIp();
        logEntered(ip);
        return "WebService test succeded! Client IP: " + ip;
    }

    @Override
    public String sayHello(String string) throws WebServiceException {
        logEntered(null);
        if (string == null || string.isEmpty()) {
            log.severe("Throwing excetion...");
            throw new WebServiceException("String can not be empty or NULL!", new WebServiceFaultBean());
        }
        log.exiting(WebServiceVenus2.class.getName(), WebServiceVenus2.getMethodName());
        return "Hello " + string + "!";
    }

这是我的 web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
</web-app>

我希望有人能帮助我。谢谢

我几乎逐字地将此代码加载到 Eclipse 中的动态 Web 模块并部署到 Glassfish4。部署后(使用 eclipse "add to server"),WSDL 在 http://localhost:8181/Venus2WebService/WebServiceVenus2Service?wsdl 可用 Web 服务端点是 http://localhost:8181/Venus2WebService/WebServiceVenus2Service

我从 CXF 中包含的唯一 jar(未在您的 post 中显示)来自阅读 CXF 二进制分发库目录中的 WHICH_JARS 自述文件:

  • asm-3.3.1.jar
  • commons-logging-1.1.1.jar
  • cxf-2.7.17.jar
  • geronimo-javamail_1.4_spec-1.7.1.jar
  • geronimo-jaxws_2.2_spec-1.1.jar
  • jaxb-api-2.2.6.jar
  • jaxb-impl-2.2.6.jar
  • neethi-3.0.3.jar
  • stax2-api-3.1.4.jar
  • wsdl4j-1.6.3.jar
  • xmlschema-core-2.1.0.jar

我通过查看服务器的 eclipse 控制台获得了端点 URL:

2015-09-09T21:45:40.683-0400|Info: Webservice Endpoint deployed WebServiceVenus2
 listening at address at http://oc-mbp01.local:8181/Venus2WebService/WebServiceVenus2Service.

类路径(对我来说都在 WEB-INF/lib 中):