如何创建Axis2 Web服务? [英] How to create Axis2 web service?

查看:91
本文介绍了如何创建Axis2 Web服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试学习如何构建Web服务.我正在尝试提供最简单的直接服务,浪费了一整天的时间后,我几乎不知道该怎么办.

I am trying to learn how to build web services. I am trying to do the most simple straight forward service and after all day of wasting my time I pretty much don't know what to do any more.

我已经正确安装了带有Tomcat 6.0的Eclipse Indigo(32位).在服务器选项卡中,我可以根据需要运行/停止服务器.我还安装了Axis2 1.6.0引擎.

I Have Eclipse Indigo (32bit) with Tomcat 6.0 properly installed. In the server tab I can run/stop server as I wish. I also installed Axis2 1.6.0 engine.

这是我的步骤:

1)新的Web动态项目
2)完成后,单击项目属性>项目构面,然后检查Axis2 Web服务
3)Eclipse会将所有文件添加到我的项目中.一切似乎都很好.
4)我将简单的Convert.java文件添加到Java Resources/src(这将是我的Web服务)

1) New Web Dynamic Project
2) When done, click Project Properties > Project Facets and check Axis2 Web Services
3) Eclipse would add all bunch of files to my project. It all seems all right.
4) I would add simple Convert.java file into Java Resources/src (that would be my web service)

package wtp;
public class Convert {
      public float celsiusToFarenheit ( float celsius )
      {
        return (celsius * 9 / 5) + 32;
      }  
      public float farenheitToCelsius ( float farenheit )
      {
        return (farenheit - 32) * 5 / 9;
      }
}

5)右键单击Convert.java文件> Web服务>创建Web服务. 我会在顶部的滑块上选择启动服务",然后单击下一步"
6)Next Window将向我展示我的两种方法celsiusToFarenheit和farenheitToCelsius.他们都被检查.我将点击下一步"
7)消息将显示它正在尝试将服务发布到Tomcat并显示错误:
IWAB0489E将Web服务部署到Axis运行时时出错 axis-admin失败,出现{http://schemas.xmlsoap.org/soap/envelope/}客户端找不到端点引用(EPR)的服务

5) Right click on Convert.java file > Web Services > Create Web Service. I would pick Start Service on the slider on top and click NEXT
6) Next Window would present me with my two methods celsiusToFarenheit and farenheitToCelsius. They are both checked. I would click NEXT
7) Message will show that it's trying to publish service to Tomcat and an error would show up:
IWAB0489E Error when deploying Web service to Axis runtime axis-admin failed with {http://schemas.xmlsoap.org/soap/envelope/}Client The service cannot be found for the endpoint reference (EPR) http://localhost:8080/MyService/services/AdminService

我的问题:

1)我该如何解决?我究竟做错了什么?还是在这几个步骤中可能做错什么?试图在Axis2网站上寻求帮助,但找不到任何有用的信息.

1) How can I solve this? What am I doing wrong? Or is it possible to do anything wrong in these few steps? Tried to look for help on Axis2 website and couldn't find anything useful there.

2)当我单击创建新服务时,实际上发生了什么?

2) What is actually happening when I click to create New Service?

3)我来自.NET世界,您在其中编写方法,将其声明为Web服务,然后将文件上传到服务器上......是否可以用Java发布Web服务?我真的很讨厌在Eclipse中使用任何类型的向导,因为大多数时候它们都不起作用.总是缺少一些东西,而我最终却失去了数小时的谷歌搜索....

3) I come from .NET world where you write method, declare it as a web service, and upload file on the server..... and you are done. Is it possible to publish web service like that in Java? I really really hate using any type of wizards in Eclipse because most of the time they don't work. Always something missing and I end up loosing hours Googling....

谢谢

感谢您的帮助.

推荐答案

这是解决方案.

要解决此问题,我不得不将服务器运行时更​​改为Axis2(添加Axis2构面时Eclipse会警告您有关此信息,但事实并非如此).为此,请转到窗口"菜单,选择首选项">"Web服务">服务器和运行时".选择您的服务器(在本例中为Tomcat 5.5),然后选择Apache Axis2作为Web服务运行时.

To fix this, I had to change the server runtime to Axis2 (Eclipse should warn you about this when you add the Axis2 facet, but it doesn't). Do this by going to the Window menu, select Preferences > Web Services > Server and Runtime. Choose your server (Tomcat 5.5 in my case), then select Apache Axis2 as the web service runtime.

您可以在 http://www.psuedoguru.com/roller/page/psuedoblog中找到解决方案?entry = problems_with_wsdl_first_web

这篇关于如何创建Axis2 Web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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