paip.myeclipse7 java webservice 最佳实践o228

paip.myeclipse7  java webservice 最佳实践o228

 

java的ws实现方案:jax-ws>>xfire

ws的测试工具  webservice测试调用工具WebserviceStudio20

 

作者Attilax  艾龙,  EMAIL:[email protected]
来源:attilax的专栏
地址:http://blog.csdn.net/attilax

 

 /////////////////

1. 创建一个 webService 工程。

2. 创建一个普通 Java 类(做为bean class)

3. 创建 webService 服务端,选择才讲的bean来创建ws,生成代理类

package com.hmw.jaxws;

 

@javax.jws.WebService(targetNamespace ="http://jaxws.hmw.com/", serviceName = "HelloJaxwsService",portName = "HelloJaxwsPort", wsdlLocation ="WEB-INF/wsdl/HelloJaxwsService.wsdl")

public class HelloJaxwsDelegate {

 

         com.hmw.jaxws.HelloJaxwshelloJaxws = new com.hmw.jaxws.HelloJaxws();

 

         publicString sayHello(String userName) {

                   returnhelloJaxws.sayHello(userName);

         }

 

         publicint add(int i, int j) {

                   returnhelloJaxws.add(i, j);

         }

 

}

 

 

/imServer/WebRoot/WEB-INF/sun-jaxws.xml

<?xmlversion = "1.0"?>

<endpointsversion="2.0"

    xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime">

    <endpointname="HelloJaxwsPort"

       implementation="com.hmw.jaxws.HelloJaxwsDelegate"

       url-pattern="/HelloJaxwsPort">

    </endpoint></endpoints>

 

 

 

4. 导入相关的 jar 包(jax-ws)

add lib >> my eclipse lib>>jax-ws  lib

 

5.访问url

http://localhost:8080/imServer/HelloJaxwsPort

显示

Web Services

Endpoint

Information

Service Name:

{http://jaxws.hmw.com/}HelloJaxwsService

Port Name:

{http://jaxws.hmw.com/}HelloJaxwsPort

Address:

http://localhost:8080/imServer/HelloJaxwsPort

WSDL:

http://localhost:8080/imServer/HelloJaxwsPort?wsdl

Implementation class:

com.hmw.jaxws.HelloJaxwsDelegate

 

 

6.access wdsl    http://localhost:8080/imServer/HelloJaxwsPort?wsdl

7. 测试使用工具

参考:

MyEclipse 8.6 创建 jax-ws 的详细步骤(有截图) - 旺仔专栏 - 博客频道 -CSDN.NET.htm

Web Service测试工具小汇 - oscarxie - 博客园

paip.myeclipse7 java webservice 最佳实践o228,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。