zoukankan      html  css  js  c++  java
  • webservice初学习

    1.使用Eclipse建立Web Service服务端和客户端

    (1)服务器端

    首先,在eclipse中像建立一个web项目一样,new->Dynamic Web Project,项目名为helloService

    接着,建一个需要暴露给外部的方法,

    package service;

    public class HelloService {

           public String say(String name) throws InterruptedException{

                  return "hello "+name;

           }

    }

    然后呢,右击这个项目,new -> other->web services->webservice,选择需要暴露的实现,service.HelloService,然后选择发布

    通过tomcat发布的,直接start即可。常用的框架有,cxf、 axis、 axis2等,这里选择了axis,发布之后,我们打开网页输入地址即可打开它的wsdl:http://localhost:8280/helloService/services/HelloService?wsdl。

    (2)客户端

    需要使用client去连这个Webservice服务了,新建一个java工程(都可以),然后新建一个Webservice client就可以,输入wsdl地址,finish即可,然后可以看到目录下的Webservice java类,新建一个test,去测试

    package test;

    import java.rmi.RemoteException;

    import service.HelloService;

    import service.HelloServiceProxy;

    public class Test {

           public static void main(String[] args) throws RemoteException {

                  HelloServiceProxy helloPxy = new HelloServiceProxy();

                  HelloService service = helloPxy.getHelloService();

                  String res = service.say("yyf");

                  System.out.println(res);

           }

    }

     

     

     

     

  • 相关阅读:
    scala之伴生对象的继承
    scala之伴生对象说明
    “Failed to install the following Android SDK packages as some licences have not been accepted” 错误
    PATH 环境变量重复问题解决
    Ubuntu 18.04 配置java环境
    JDBC的基本使用2
    DCL的基本语法(授权)
    ZJNU 1374
    ZJNU 2184
    ZJNU 1334
  • 原文地址:https://www.cnblogs.com/w669399221/p/14204193.html
Copyright © 2011-2022 走看看