eclipse怎么c 创建webservicee

我的eclipse怎么不能自动生成webService客户端代码_百度知道
我的eclipse怎么不能自动生成webService客户端代码
baidu?&nbsp://d;service&nbsp.baidu,我看到别人的eclipse里只要右键新建.jpg" esrc="client就可以自动产生客户端代码.com/zhidao/wh%3D450%2C600/sign=cf431adbc874b3d7eec8acb6e02ea0ec08fa503dc693!该怎么办./zhidao/wh%3D600%2C800/sign=2a96e67ca144ad342eea8f81e09220cc/a8ec8acb6e02ea0ec08fa503dc693,而我的根本没有那一项.com/zhidao/pic/item/a8ec8acb6e02ea0ec08fa503dc693.hiphotos://d.hiphotos://d.jpg" target="_blank" title="点击查看大图" class="ikqb_img_alink"><img class="ikqb_img" src="http,找到web&nbsp我想在eclipse里新建一个webservice客户端
我有更好的答案
你下载的eclipse版本不是j2ee的版本,要下载j2ee版本才有
哦 谢谢你的回答,除了换个版本的还有什么解决办法吗?
下载eclipse的ee插件
其他类似问题
为您推荐:
webservice的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁二次元同好交流新大陆
扫码下载App
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
爱自由,反独裁,反专制,倡导言论自由.新闻自由.拒绝洗脑.独立思想者,坚信思想是个好东西,它会要了独裁的命...........
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
2.2.开发前准备:安装Eclipse-jee;下载最新版本的Axis2,网址&,选择Standard Binary Distribution的zip包,解压缩得到的目录名axis2-1.4.1,目录内的文件结构如下:2.3.开发前配置:在Eclipse的菜单栏中,Window --& Preferences --& Web Service --& Axis2&Perferences,在Axis2 runtime location中选择Axis2解压缩包的位置,设置好后,点"OK"即行。(如图)2.4.开发Web Service:(1)新建一个Java Project,命名为"WebServiceTest1"(2)新建一个class,命名为"CalculateService",完整代码如下:(3)在"WebServiceTest1"项目上new --& other,找到"Web Services"下面的"Web Service";(4)下一步(next),在出现的Web Services对象框,在Service implementation中点击"Browse",进入Browse Classes对象框,查找到我们刚才写的写的CalculateService类。(如下图)。点击"ok",则回到Web Service话框。(5)在Web Service对话框中,将Web Service type中的滑块,调到"start service“的位置,将Client&type中的滑块调到"Test client"的位置。(6)在Web Service type滑块图的右边有个"Configuration",点击它下面的选项,进入Service Deployment Configuration对象框,在这里选择相应的Server(我这里用Tomcat6.0)和Web Service runtime(选择Apache Axis2),如下图:(7)点OK后,则返回到Web Service对话框,同理,Client type中的滑块右边也有"Configuration",也要进行相应的置,步骤同上。完成后,Next --& next即行。进入到Axis2 Web Service Java Bean Configuration,我们选择Generate a default services.xml,如下图所示:(可能报错:The Apache Axis2 Web service runtime in Tomcat v7.0 Server does not support the service project &,就是只能使用Servlet3.0以下的规范)(创建项目时需要选择3.0以下版本,比如2.5)(8)到了Server startup对话框,有个按键"start server"(如下图),点击它,则可启动Tomcat服务器了。(9)等启完后,点击"next -- & next"(其中一步可以选择浏览器打开如下页面,端口号并不一定是19189),&一切默认即行,最后,点击完成。最后,出现如下界面:(Web&Service Explorer),我们在这里便可测试我们的Web服务。(使用浏览器打开的话使用如下地址:)。如下图所示:注:在浏览器中打开Web Service Explorer(有时候在eclipse中关闭了webservice explorer,可以用这种方法打开)首先登录地址:。然后在网页左上角选择标签。然后输入WSDL地址:http://localhost:8080/WebServiceTest1/services/CalculateService?wsdl 。这个wsdl地址就是我们刚才发布服务的那个wsdl。点击go,如下图所示:然后就可以看到如下界面了:(10)测试比较简单,例如,我们选择一个"plus"的Operation(必须是CalculateServiceSoap11Binding),出现下图,在x的输入框中输入1,在y的输入框中输入2,点击"go",便会在status栏中显示结果3.0。其他方法的测试也类似。结果如上图所示。2.5.CalculateService客户端调用程序前面我们已经定义好了加减乘除的方法并将这些方法发布为服务,那么现在要做的就是调用这些服务即可。客户端调用程序如下代码所示:CalculateServiceTest.java运行结果:3.实例2.HelloService(1)首先定义服务方法,代码如下所示:(2)参考实例1将这个方法发布为服务。(3)编写客户端代码调用WebService(主要参考[5])本文例子与其他例子最大的不同就在这里,其他例子一般需要根据刚才的服务wsdl生成客户端stub,然后通过stub来调用服务,这种方式显得比较单一,客户端必须需要stub存根才能够访问服务,很不方面。本例子的客户端不采用stub方式,而是一种实现通用的调用方式,不需要任何客户端存根即可访问服务。只需要指定对于的web servce地址、操作名、参数和函数返回类型即可。代码如下所示:HelloServiceTest2.java运行该程序,点击Run As-&Java application,可以看到控制台端口的输出是:Hello, My Friends,表明客户端调用成功。该例子最大的不同和优势表现在客户端的调用方式,或者说是发起服务调用的方式,虽然比起客户端stub存根的方式,代码稍多,但是这种方式统一,不需要生产stub存根代码,解决了客户端有很多类的问题。如果读者对这些代码进一步封装,我想调用方式很简单,只需要传递相关参数,这更好地说明了服务调用的优势。而且这种方式更加简单明了,一看便知具体含义。而不需要弄得stub类的一些机制。(4)改写客户端调用服务的代码(3)中提到的客户端应用代码写的略微有些繁杂,下面将上面的客户端调用service程序进行改写,简洁了许多。代码如下:HelloServiceTest.java转自:/xwdreamer/archive//2296914.html
阅读(1327)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
在LOFTER的更多文章
loftPermalink:'',
id:'fks_',
blogTitle:'eclipse+webservice开发实例',
blogAbstract:'1.参考文献:1.利用Java编写简单的WebService实例 &'
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}Eclipse发布WebService和调用WebService接口 - 开源中国社区
当前访客身份:游客 [
当前位置:
一、发布WebService服务
1、整个服务端架构如下:
2、创建过程
& & 1)web.xml
2)wsdd.xml
3)HelloWorldService.jws
public&class&HelloWorldService&{
&&&&private&final&static&String&sGreeting&=&&Hello&World!&;
&&&&public&String&getMessage(){
&&&&&&&&return&(sGreeting);
4) SayHello.java
public&class&SayHello&{
&&&&public&String&getName(String&name)&{&&
&&&&&&&&return&&hello====&&&+&&&
5) 用到的jar包 lib
二、Client调用服务端接口&
1、 项目架构如下:
2、调用过程:
1)右键点击项目名称——&“NEW”——&“Other”——&输入WEB service client 如下
2)完成出现客户端配置窗口,如下
3)在“service definition”中输入webservice开放的服务地址,
注意地址末尾必须加上“?WSDL”
还需注意的是,创建的web service client 必须是3.0以下版本。
4)这个项目中除了 TestClient.java类是自己创建的,其他都是自动生成的。
5)TestClient.java类
public&static&void&main(String[]&args)&{
&&&&&&&&try&{
&&&&&&&&&&&&
HelloWorldServiceServiceLocator&service&=&new&HelloWorldServiceServiceLocator();
&&&&&&&&&&&&java.net.URL&url&=&new&java.net.URL(&
http://localhost:8080/mywebservices/services/HelloWorldService.jws?WSDL&);
&&&&&&&&&&&&
HelloWorldServiceSoapBindingStub&stub&=&new&HelloWorldServiceSoapBindingStub(url,&service);
&&&&&&&&&&&&String&x2&=&stub.getMessage();
&&&&&&&&&&&&System.out.println(x2);
&&&&&&&&&&&&
&&&&&&&&}&catch&(RemoteException&e)&{
&&&&&&&&&&&&//&TODO&Auto-generated&catch&block20
&&&&&&&&&&&&e.printStackTrace();
&&&&&&&&}&catch&(MalformedURLException&e)&{
&&&&&&&&&&&&//&TODO&Auto-generated&catch&block23
&&&&&&&&&&&&e.printStackTrace();
这里主要用到的是***Locator 和***Stub这两个类。
共有0个评论
更多开发者职位上
有什么技术问题吗?
X红薯的其它问题
类似的话题winters1224 的BLOG
用户名:winters1224
文章数:199
评论数:14
访问量:73945
注册日期:
阅读量:5863
阅读量:12276
阅读量:314889
阅读量:1028571
[匿名]51cto游客:
51CTO推荐博文
1、&客户端访问
客户端接口:
&*&@author:&FL
&*&@date:&2013-2-4-下午1:09:12
package&wsC
&*&@author&FL
&*&@since&2013-2-4
public&interface&ClientInt&{
public&String&ask(String&question);
客户端实现:
&*&@author:&FL
&*&@date:&2013-2-4-下午1:10:20
package&wsC
import&org.apache.cxf.binding.soap.saaj.SAAJOutI
import&org.apache.cxf.endpoint.C
import&org.apache.cxf.frontend.ClientP
import&org.apache.cxf.interceptor.LoggingOutI
import&org.apache.cxf.jaxws.JaxWsProxyFactoryB
import&org.apache.cxf.transport.C
import&org.apache.cxf.transport.http.HTTPC
import&org.apache.cxf.transports.http.configuration.HTTPClientP
import&ws.WsI
&*&@author&FL
&*&@since&2013-2-4
public&class&ClientImpl&implements&ClientInt&{
private&WsInt&ws;
private&String&address;
public&ClientImpl()&{
this.address&=&&http://localhost:7001/TestWS/service/qa&;
JaxWsProxyFactoryBean&factory&=&new&JaxWsProxyFactoryBean();
factory.setServiceClass(WsInt.class);
factory.setAddress(address);
factory.getOutInterceptors().add(new&LoggingOutInterceptor());
factory.getOutInterceptors().add(new&SAAJOutInterceptor());
ws&=&(WsInt)&factory.create();
Client&clientl&=&ClientProxy.getClient(ws);
Conduit&conduit&=&clientl.getConduit();
HTTPConduit&hc&=&(HTTPConduit)&
HTTPClientPolicy&httpClient&=&new&HTTPClientPolicy();
hc.setClient(httpClient);
&*&@author&FL
&*&@since&2013-2-4
&*&@param&question
&*&@return
&*&@see&wsClient.ClientInt#ask(java.lang.String)
public&String&ask(String&question)&{
String&result&=&null;
result&=&ws.qa(question);
客户端测试:
&*&@author:&FL
&*&@date:&2013-2-4-下午1:15:37
import&org.junit.T
import&wsClient.ClientI
import&wsClient.ClientI
&*&@author&FL
&*&@since&2013-2-4
public&class&TestClient&{
public&void&test()&{
ClientInt&client&=&new&ClientImpl();
String&result&=&client.ask(&ni&shi&shei&);
System.out.println(result);
运行junit测试用例,应输出:
信息:&Outbound&Message
---------------------------
Address:&http://localhost:7001/TestWS/service/qa
Encoding:&UTF-8
Content-Type:&text/xml
Headers:&{SOAPAction=[&&],&Accept=[*/*]}
Payload:&&soap:Envelope&xmlns:soap=&http://schemas.xmlsoap.org/soap/envelope/&&&soap:Body&&ns2:qa&xmlns:ns2=&http://ws/&&&arg0&ni&shi&shei&/arg0&&/ns2:qa&&/soap:Body&&/soap:Envelope&
--------------------------------------
this&is&my&life
2、&这是用Eclipse创建cxf&webservice的简易方法。没有涉及到wsdl、cxf的用户安全验证等细节。这些东西请自己补充。
本文出自 “” 博客,请务必保留此出处
了这篇文章
类别:┆阅读(0)┆评论(0)

我要回帖

更多关于 vs2010创建webservice 的文章

 

随机推荐