在Eclipse中创建简单的JAX-WS WebService [英] Creating a Simple JAX-WS WebService in Eclipse

查看:118
本文介绍了在Eclipse中创建简单的JAX-WS WebService的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在eclipse中创建一个简单的Web服务。首先,我创建了一个空的java项目,并在src文件夹中添加了以下三个文件。

I'm trying to create a simple web service in eclipse. First i created an empty java project and added the three following files in the src folder


  1. Greeting.java



package com.alfaisaliah;

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

@WebService
public interface Greeting {
    @WebMethod
    String sayHello(String name);
}




  1. GreetingImp.java



package com.alfaisaliah;

import javax.jws.WebService;

@WebService(endpointInterface="com.alfaisaliah.Greeting")
public class GreetingImp implements Greeting {

    @Override
    public String sayHello(String name) {
        return "Hello " + name;
    }
}




  1. WSPublisher



package com.alfaisaliah;

import javax.xml.ws.Endpoint;

public class WSPublisher {
    public static void main(String[] args){
        Endpoint.publish("http://localhost:8081/WS/Greeting", new GreetingImp());
    }
}

我正在关注的教程没有指定任何服务器运行Web服务!我想知道是否需要指定任何服务器。我已经有Tomcat v5.5,但是在这个例子中我没有使用它。每当我将该项目作为java项目运行时,我会遇到某种错误。任何人都可以帮助我确定我的问题在哪里尝试运行Web服务。这是eclipse控制台的输出

The tutorial I'm following doesn't specify any server to run the web service on! I'm wondering if I need to specify any server. I already have Tomcat v5.5 but am not using it in this example. Whenever I run this project as a java project I get some kind of error. Can anyone please help me identify where my problem is trying to run the web service. Here is the output of the eclipse console

Feb 26, 2012 12:01:00 PM com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass
INFO: Dynamically creating request wrapper Class com.alfaisaliah.jaxws.SayHello

Feb 26, 2012 12:01:00 PM com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass
INFO: Dynamically creating response wrapper bean Class com.alfaisaliah.jaxws.SayHelloResponse

另外当我再次运行该项目时,该地址已被使用

Also when I run the project again it says that the address is already in use

Feb 26, 2012 12:01:00 PM com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass
INFO: Dynamically creating request wrapper Class com.alfaisaliah.jaxws.SayHello

Feb 26, 2012 12:01:00 PM com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass
INFO: Dynamically creating response wrapper bean Class com.alfaisaliah.jaxws.SayHelloResponse
Exception in thread "main" com.sun.xml.internal.ws.server.ServerRtException: Server Runtime Error: java.net.BindException: Address already in use

我很感激你的帮助家伙:)

I would appreciate your help guys :)

推荐答案

检查此链接,

http://www.myeclipseide.com/文档/ quickstarts / webservices_jaxws /

上面的链接提供了生成Web服务服务器和客户端的分步细节。

Above link gives step-by-step details for generating both web-service server and client.

从POJO开始,不需要注释,JAX-WS运行时在Tomcat服务器上部署后会小心。

You start with POJO, no annotation needed, JAX-WS runtime will take care after deployment on Tomcat server.

这篇关于在Eclipse中创建简单的JAX-WS WebService的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆