首页 > 解决方案 > JAX-WS:找不到类

问题描述

我不精通Java。这是网络服务,我正在尝试实现 - 一个基本示例,我面临编译错误。我不确定我在这里错过了什么。

在此处输入图像描述

这是代码。

package com.joshis1.jaxws;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;

@WebService
@SOAPBinding(style = Style.DOCUMENT)
public interface IwebServiceInterface {
@WebMethod String sayHello(String name);
}

接下来,实现接口

package com.joshis1.jaxws;

import javax.jws.WebService;

@WebService(endpointInterface = "com.joshis1.jaxws")
public class webServiceImpl implements IwebServiceInterface {
    @Override
     public  String sayHello(String name)
     {
        return "Hello Shreyas " +  name;
     }
}

接下来,发布端点的主类

package com.joshis1.publisher;
import javax.xml.ws.Endpoint;

import com.joshis1.jaxws.*;

public class WebServicePublisher {

    public static void main(String[] args) {
        Endpoint.publish("http://localhost:8888/webservice/helloworld", new webServiceImpl());

    }

}

接下来,一个非常基本的问题——我需要在这里安装一个网络服务器吗?

标签: javajax-ws

解决方案


你指向你endpointInterface的包裹:

@WebService(endpointInterface = "com.joshis1.jaxws")

它需要引用您的界面:

@WebService(endpointInterface = "com.joshis1.jaxws.IwebServiceInterface")

查看错误在说什么非常重要

类:com.joshis1.jaxws找不到


推荐阅读