使用Mule发布Web Service服务

7 篇文章 0 订阅

一、编写接口代码

1 package cn.com.songjy.mule;
2  
3 public interface IHelloWord {
4  
5     String hello(String name);
6      
7 }

 

二、编写接口实现类代码

1 package cn.com.songjy.mule;
2  
3 public class HelloWord implements IHelloWord {
4  
5     public String hello(String name) {
6         return "你好:" + name + ",现在的时间是:" new java.util.Date();
7     }
8  
9 }

三、编写mule配置文件【mule-config.xml】,路径是在classpath根目录下,即平常的src目录中

01 <?xml version="1.0" encoding="UTF-8"?>
02  
03 <!DOCTYPE mule-configuration PUBLIC "-//MuleSource //DTD mule-configuration XML V1.0//EN"
04                                 "http://mule.mulesource.org/dtds/mule-configuration.dtd">
05 <mule-configuration id="Ws-adapter" version="1.0">
06     <model name="helloTest">
07         <mule-descriptor name="helloService" implementation="cn.com.songjy.mule.HelloWord">
08             <inbound-router>
09                 <endpoint address="axis:http://localhost:8281/services"></endpoint>
10             </inbound-router>
11             <properties>
12                 <list name="serviceInterfaces">
13                     <entry value="cn.com.songjy.mule.IHelloWord" />
14                 </list>
15             </properties>
16         </mule-descriptor>
17     </model>
18 </mule-configuration>

四、编写发布Web Service接口代码

01 package cn.com.songjy.mule;
02  
03 import org.mule.config.ConfigurationException;
04 import org.mule.config.builders.MuleXmlConfigurationBuilder;
05  
06 public class PublicServer {
07  
08     /**
09      * create on 2013-5-27 下午2:01:15 by songjy
10      * @param args
11      */
12     public static void main(String[] args) {
13         try {
14             MuleXmlConfigurationBuilder xmlConfiguration = new MuleXmlConfigurationBuilder();
15             xmlConfiguration.configure("mule-config.xml");
16         catch (ConfigurationException e) {
17             e.printStackTrace();
18         }
19          
20     }
21  
22 }

 

五、运行测试

在浏览器中输入http://localhost:8281/services/helloService?wsdl 即可看到效果。

示例代码:http://yunpan.cn/QeKkjgcum4dKp

Java使用XFire调用WebService接口:

http://www.cnblogs.com/simle/archive/2011/10/31/2230091.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值