一、编写接口代码
1 | package cn.com.songjy.mule; |
3 | public interface IHelloWord { |
5 | String hello(String name); |
二、编写接口实现类代码
1 | package cn.com.songjy.mule; |
3 | public class HelloWord implements IHelloWord { |
5 | public String hello(String name) { |
6 | return "你好:" + name + ",现在的时间是:" + new java.util.Date(); |
三、编写mule配置文件【mule-config.xml】,路径是在classpath根目录下,即平常的src目录中
01 | <? xml version = "1.0" encoding = "UTF-8" ?> |
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" > |
09 | < endpoint address = "axis:http://localhost:8281/services" ></ endpoint > |
12 | < list name = "serviceInterfaces" > |
13 | < entry value = "cn.com.songjy.mule.IHelloWord" /> |
四、编写发布Web Service接口代码
01 | package cn.com.songjy.mule; |
03 | import org.mule.config.ConfigurationException; |
04 | import org.mule.config.builders.MuleXmlConfigurationBuilder; |
06 | public class PublicServer { |
09 | * create on 2013-5-27 下午2:01:15 by songjy |
12 | public static void main(String[] args) { |
14 | MuleXmlConfigurationBuilder xmlConfiguration = new MuleXmlConfigurationBuilder(); |
15 | xmlConfiguration.configure( "mule-config.xml" ); |
16 | } catch (ConfigurationException e) { |
五、运行测试
在浏览器中输入http://localhost:8281/services/helloService?wsdl 即可看到效果。
示例代码:http://yunpan.cn/QeKkjgcum4dKp
Java使用XFire调用WebService接口:
http://www.cnblogs.com/simle/archive/2011/10/31/2230091.html