MyEclipse 搭建webservice (axis1.4)

时间:2022-06-03 22:59:04

0 引言 

以前都是做javaweb的 最近因工作需要 接触了webservice

关于什么事webservice,与web的区别,soap,跟http的区别,asix1和asix2的区别,为什么不用json 等等等等 这里就不细谈了。等以后有机会会好好探讨下 要不会在心里留下阴影。

这里主要讲的是如何用myeclipse搭建axis1.4版本的webservice  并进行测试 。

网上看了很多 但版本过多没找到合适的 所以在这里把自己弄得小demo拿了出来

好 闲话不说了 上代码

1 搭建项目

在MyEclipse中 新建 Web项目 项目名 wbsDemo

1.0 最终结构

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAAGECAIAAAAUchpoAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAgAElEQVR4nO2df5Qb1X32n7GBGJy8QI3BEEoWM9q4mwWc0BSQoPFbAljaJijkRJgGWJyXjhIDkV6HTZuwcfixcVI2TaUS3EqltRdzAsinoJJXmoVDywZYgV8wJc52Iaup2Tjm9WJDvBhM1rvS3PePGc2MpBlJ+0Ozs+Pv5+j46N65986dPXp879yZ73M5xhgIgrCLRfPdAYI4tiDJEYStkOQIwlZIcgRhK8fNpvLo6MC2gdEBtKzB6M1rWlpa1sxRrwjCtcx8lBsdHbh5FKMtLXefy53LHX/zAEZHB+auYwThTqYxyu1+/Lva9wuu3bxtFC2jWNMyyj4x+gnW0jKAu7aNbrur8fakuM8z3M0S/sarEMSCp1HJ/fJfv3vhlzcbkt8ZeP/qu8/lGBsYGBgFMApg9OY57x8ARZzRnJYUsqRTYsFSR3Jb7rkPAMD+8uueqQNbCx9OfHj4yO/HD594wtE1GH32zRagBQOjoy0tGG1Z0zLavI7qOhPDHMeR7IgFSh3JfTB5XOF033dvnlSSxy/BiX+gHrr5d8WbBwCsQcsARtcAuPnmlmZ104g/wfJtPk9YJNERC5A6yyff7tn47ujLmHyv+tPy0Q+2rcGa0VGM3vU/z/3NtrtMVizFMOeLS6WvXFiszFXHLI7jtKOAFP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PsGx71FNalkB22iv/xjY7ETK5zeI7QsipDkp8Rwi5kqxN/xRZIWnSmlU+YYkLo8J/8o87vvLlLwJgAMcBjIEDYxw4BsY9/kQ6Klw33320HWVNh57YOQA3jnJskfJcTmZMlpnMUJQ5mTFZBmPM9N0UNyLFfYb1/UDSO82ZKdEkXPhcWJYXPZISlSGOARzAlK8MABZzx4jk+Ehfm6/kB+iN0QjnFFw4sSQIJ3OM/JdPEE6BJEcQtkKSIwhbIckRhK2Q5AjCVlz4kIC8Twgn40LJFdmiy6/cWJGZ7799QPybOVVd5Z7ic4EY5tK0N7K7ceHE8hj0PiEWEC6U3DHofUIsIFwoOfI+IZyMGyU3I++T2l4gZt4kWr1KkxAFKe4zNsOFRbU5UfUVUTNM2iTcjAslNzPvk1peIHXtTBhjWSEZKBMdHxnMCsmeuAQxHBiK5dU1kVy0B31qeY5Lay4mvfUjWQlX4EbJFRaXjBiguDDcGFyj5VhFhfMdIW8yLQJieijU192eykiQRoYUxaVVBy0lajMHRZAAhGxpddHfFVPqG/Ansu1RDxcYivVpr/F71e/+oACvat3At7brTRIux4WSm6H3SS0vkEbsTAiiIdwquel7n9TwArG2M9HGNSneGVU8DcrsLANDsXzJ/I4gAJdKbkbeJzW8QKztTAQYTELKH2ErTpR9EZ6P9MUQ9TRgO0QcC7gwRJW8Twgn48KHVIr3ifKdYwDAGAcwMHA4drxPCIfiQsmR9wnhZFw4sSQIJ0P/5ROErZDkCMJWSHIEYSskOYKwFZIcQdjKQnpI8NovXxjc93/zrNXDjfjO/pPVF1423z0iiGnjxIcEL2UrnUtOX+k/fPTEbb8dv+3Md//w46v+6pWDLy9qeeDj4yaqk+I+TyrUoAP/jPejmdZZCMLA/wew3AtkUd3olwAAAABJRU5ErkJggg==" alt="" />

1.1导入jar包

MyEclipse 搭建webservice  (axis1.4)

1.2jar包说明

axis.jar               SOAP引擎包
commons-discovery-0.2.jar    用来发现、查找和实现可插入式接口,提供一些一般类实例化、单件的生命周期管理的常用方法
commons-logging-1.1.1.jar    日志包
jaxrpc.jar             Axis运行所需要的组件包
wsdl4j-1.6.2.jar           用来解析服务的WSDl文件

1.3修改web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<servlet>
<display-name>Apache-Axis Servlet</display-name>
<servlet-name>AxisServlet</servlet-name>
<servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
</servlet>
<servlet>
<display-name>Axis Admin Servlet</display-name>
<servlet-name>AdminServlet</servlet-name>
<servlet-class>org.apache.axis.transport.http.AdminServlet</servlet-class>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/servlet/AxisServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>*.jws</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>

1.4在lib下添加server-config.wsdd (webservice配置)文件

<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

    <!-- 处理器 -->
<handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper" />
    
  <!-- 待添加的服务 -->
<!-- 指定处理器 -->
<transport name="http">
<requestFlow>
<handler type="URLMapper"/>
</requestFlow>
</transport> </deployment>

好 这样就搭建成功了

然后开始上代码

2 服务端与客户端的数据传输

2.0这里我们分4中情况来实践

  情况1 传值:String         返回值: String

  情况2 传值:User(自定义对象)    返回值: String

  情况3 传值:String         返回值: User(自定义对象)

  情况4 传值:User(自定义对象)    返回值: UserInfo(自定义对象)

2.1 情况1 (传值:String 返回值: String)

2.1.1

新建一个实现类 UserService.java   并新建接收方法 showName

package lqb.manage;
public class UserService { public String showName(String name){
System.out.println("UserService --- showName "+name);
return String.format("name:%s",name);
} }

2.1.2

然后 在server-config.wsdd文件中添加服务

<!-- provider="java:RPC"  webservice是以javabean的形式提供的-->
<service name="userService" provider="java:RPC">
<!-- 指定类名 -->
<parameter name="className" value="lqb.manage.UserService" /> </service>

ok 这样就可以了

2.1.3

然后写客户端我们也再新建个类  Cline.java

并写一个跟这个服务通讯的测试方法 getNameWBSC()

/**
*
* @param: String
* @return: String
*/
public static void getNameWBSC(){ Service service = new Service();
String url="http://127.0.0.1:8080/wbsDemo/services/userService";
String methodName="showName";
String name="李";
System.out.println("Cline -- getNameWBSC");
System.out.println("para String "+name);
try {
Call call=(Call)service.createCall();
call.setTargetEndpointAddress(new URL(url));
call.setOperationName(new QName("", methodName));
//设置要传入参数,如果没有要传入的参数,则不要写这个
call.addParameter("name", XMLType.XSD_STRING, ParameterMode.IN);
//设置返回的类型
call.setReturnType(org.apache.axis.Constants.XSD_STRING); //执行,调用webservice
String result = (String) call.invoke(new Object[]{name});
System.out.println("返回的结果是:"+result); } catch (Exception e) {
e.printStackTrace();
}
}

2.1.4

然后运行

客户端显示                                                             服务端显示

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPEAAABeCAIAAAB942VlAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAKx0lEQVR4nO2dPW/izBbHj69uv/4MEeRKKNUWKUydXUEatkjaUJknzQ1NipW2jETxNKZahYptobhpAGlTx2WqKNITo/0MfAPfwsae8bwaGwzD+RVRPJ6XMzN/j2eGOQDj8XjF5XVwDtCdphfr/6fdNHw17Ub/khGiOOeDV/H/aXTy7uvg/HzwSoURVihtIANfB+dAZZxeCKHTrFbT7tqa7nSlsplvEsU6I8Ymfn2jvLvd8/U9UTSyACowuWb6kmhSXji3ymnjDwav6j6i06bNmibkNiMdTMDvnUzPvg7Ozwf/AhEnt79XK+8ivvj67Xx8Zdtffv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IaqGnENFDTiGmgphHTQE0jpoGaRkwDNY2YBmoaMQ3UNGIaqGnENFDTiGmgphHTQE0jpoGaRkwDNY2YBmoaMQ3UNGIaqGnENP4P69UHJmi8wgIAAAAASUVORK5CYII=" alt="" />                         aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAASUAAABGCAIAAAAFEhVgAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAJUElEQVR4nO2cv2/iyhbHj5/eH+Dm1U9iIZFQbvFSUJjmNSQCmqSANlROaBI3FEhbrkSRxqQhoeK1UIQGUEJxq3WBdFNFkRK8/A3+D3iFf83YM8ZgMnA351OsFnvmzMw55ztzmEQBy7J6vd6ff83//GtuWS+tHNQGlmVZljWoAeRaL5b/yX4zqIH7YlADcB/7XemO9rua+9m3Q47lMqhRPW37VCuyhWfhpZUjmvlNvAYxeoUm4r6wm9kEJhe2uaZz2N5gWmZN0Vtm2L0MJzCjwLMZnAPlXmLOrOeu85KkxGqPDWqUe90mgRQKe5Qk0NF3SajDSytnP2AEJEZ2uY//ATymo16udV9POR8L161cbzR1085+USjXINe6LgAApNJZeDMXoY4AAKm6XofOiSzLcqXHHREWndterUH0LOiWZb203iqyLGtTZ1Ywax7LsizL8nFzZg9pJ7ZecHqVa7PHpwXA4ulxVisX4vWKxI3wrHk39f3DtrmOcyivwirLPFjuDTshRhSmo17u/DRF9fc84LmXmjPvecjuZimxKg8d956e5zjdo0nVn61nx3ahXONMn+6SzkKvIp90PN/EyS63F19vDHKH39Zp7rHonMjyFdz7eyK7mZcZFKn6s2UNar2KrbjAvvNMRdHGyZXF0yM4AYnTazUFnZjGlmyyvRrD8sJ8g2w6BTz3hpywOgpU4lR6QOwu2yZmSrBZPw+DuwevUe/WkdG3w9zs/Rfx8tf7zG2mW5Zl3cOVLHuqi5GTdi++3grl2qx55al4etcEZ+uLsTYvUNNOZwG/3mfuFrV4epxx+k3vmr48AGDROdHIcOcOvwWMw1TTmAlRuG7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gXpDEHGg3hBEHKg3BBEH6g1BxIF6QxBxoN4QRByoNwQRB+oNQcSBekMQcaDeEEQcqDcEEQfqDUHEgXpDEHGg3hBEHKg3BBEH6g1BxIF6QxBxoN4QRByoNwQRB+oNQcSBekMQcaDeEEQcqDcEEQfqDUHEgXpDEHGg3hBEHKg3BBEH6g1BxPF/qbm7eXyUqewAAAAASUVORK5CYII=" alt="" />

ok 测试通过

2.2然后我们来看情况2

2.2.1

为了测试 我们新建一个自定义类 User.Class

package lqb.bean;

public class User {

    private String name;
private int age;
/*省略get set 构造函数*/
}

2.2.2

然后在UserService.java中添加 方法

public User showUser(String name){
System.out.println("UserService --- showUser "+name);
User u=new User(name,10);
return u;
}

2.2.3

接着 在配置文件server-config.wsdd中添加服务

<!-- 一个服务 -->
<!-- provider="java:RPC" webservice是以javabean的形式提供的-->
<service name="userService" provider="java:RPC">
<!-- 指定类名 -->
<parameter name="className" value="lqb.manage.UserService" />
<!-- 参数返回值的bean -->
<beanMapping languageSpecificType="java:lqb.bean.User" qname="ns1:User" xmlns:ns1="BeanService"/>
</service>

与情况一不同 这里需要传输bean 所以需要添加一个beanMapping 

2.2.4

好 写测试方法 我们还是在Cline.java 中添加 getUserWBSC()

/**
* 需要在wsdd文件中写Mapping
* @param: String
* @return: User
*/
public static void getUserWBSC(){ Service service = new Service();
String url="http://127.0.0.1:8080/wbsDemo/services/userService";
String methodName="showUser";
String qnv="User";
String name="王"; System.out.println("Cline -- getUserWBSC");
System.out.println("para String "+name);
try {
Call call=(Call)service.createCall();
call.setTargetEndpointAddress(new URL(url));
call.setOperationName(new QName("", methodName));
QName qn = new QName(qnv, methodName);
call.registerTypeMapping(User.class, qn, new BeanSerializerFactory(User.class, qn), new BeanDeserializerFactory(User.class, qn)); //设置要传入参数,如果没有要传入的参数,则不要写这个
call.addParameter("name", XMLType.XSD_STRING, ParameterMode.IN);
//设置返回的类型
call.setReturnClass(User.class); //执行,调用webservice
User u = (User) call.invoke(new Object[]{name});
System.out.println("返回的结果是:"+u.getName()+"-"+u.getAge()); } catch (Exception e) {
e.printStackTrace();
}
}

好 然后运行测试 ...(这里就不再呈现了 和情况1类似 大家脑补下)

2.3然后我们来看情况3

2.3.1

bean还是使用刚才的User

2.3.2

然后在UserService中添加方法 showAge

public String showAge(User u){
System.out.println("UserService --- showAge "+u.getAge());
return String.format("age:%d",u.getAge());
}

2.3.3

swdd文件同第二种情况 (略)

2.3.4

然后是测试方法  还是在Cline.java中添加

/**
*
* @param: User
* @return: String
*/
public static void getAgeWBSC(){ Service service = new Service();
String url="http://127.0.0.1:8080/wbsDemo/services/userService";
String methodName="showAge";
User u=new User("张",10);
System.out.println("Cline -- getAgeWBSC");
System.out.println("para User:"+u.getName()+" - "+u.getAge());
try {
Call call=(Call)service.createCall();
call.setTargetEndpointAddress(new URL(url));
call.setOperationName(new QName("", methodName));
//设置要传入参数,如果没有要传入的参数,则不要写这个
// QName qn = new QName("urn:BeanService", methodName);
QName qn = new QName("User", methodName);
call.registerTypeMapping(User.class, qn, new BeanSerializerFactory(User.class, qn), new BeanDeserializerFactory(User.class, qn)); call.addParameter("name", qn, ParameterMode.IN);
//设置返回的类型
call.setReturnType(Constants.XSD_STRING); //执行,调用webservice
String result = (String) call.invoke(new Object[]{u});
System.out.println("返回的结果是:"+result); } catch (Exception e) {
e.printStackTrace();
}
}

好 测试通过 (继续脑补)

2.4最后是第四种情况

2.4.1

为不混淆参数和返回值 我们再new一个自定义的bean UserInfo.Class

package lqb.bean;

public class UserInfo{

    private String name;
private String desc; /*省略get set 构造函数*/
}

2.4.2

然后是服务端 在UserService中添加 方法showUserInfo

public UserInfo showUserInfo(User u){
System.out.println("UserService --- showUserInfo "+u.getName());
UserInfo ui=new UserInfo(u.getName(),"1234");
return ui;
}

2.4.3

这次 对应的配置文件觉有不同 需要再添加一个 beanMapping

<!-- 一个服务 -->
<!-- provider="java:RPC" webservice是以javabean的形式提供的-->
<service name="userService" provider="java:RPC">
<!-- 指定类名 -->
<parameter name="className" value="lqb.manage.UserService" />
<!-- 参数返回值的bean -->
<beanMapping languageSpecificType="java:lqb.bean.User" qname="ns1:User" xmlns:ns1="BeanService"/>
<beanMapping languageSpecificType="java:lqb.bean.UserInfo" qname="ns1:UserInfo" xmlns:ns1="BeanService"/>
</service>

2.4.4

最后还是Cline的测试方法getUserInfoWBSC

/**
*
* @param: User
* @return: UserInfo
*/
public static void getUserInfoWBSC(){ Service service = new Service();
String url="http://127.0.0.1:8080/wbsDemo/services/userService";
String methodName="showUserInfo";
User u=new User("赵",10);
System.out.println("Cline -- getUserInfoWBSC");
System.out.println("para User:"+u.getName()+" - "+u.getAge());
try {
Call call=(Call)service.createCall();
call.setTargetEndpointAddress(new URL(url));
call.setOperationName(new QName("", methodName));
//设置要传入参数,如果没有要传入的参数,则不要写这个
QName qn = new QName("User", methodName);
call.registerTypeMapping(User.class, qn, new BeanSerializerFactory(User.class, qn), new BeanDeserializerFactory(User.class, qn)); QName qn1 = new QName("UserInfo", methodName);
call.registerTypeMapping(UserInfo.class, qn1, new BeanSerializerFactory(UserInfo.class, qn1), new BeanDeserializerFactory(UserInfo.class, qn1)); call.addParameter("name", qn, ParameterMode.IN);
//设置返回的类型
call.setReturnClass(UserInfo.class); //执行,调用webservice
UserInfo ui = (UserInfo) call.invoke(new Object[]{u});
System.out.println("返回的结果是:"+ui.getName()+" - "+ui.getDesc()); } catch (Exception e) {
e.printStackTrace();
}
}

好 ....通过 继续脑补

2.5 至于其他情况(无传值 或者 无返回值)这里就不多说了 根据上面的例子 大家应该可以写出来

3 demo下载

百度云链接  密码:ybnx