标签:out rri 技术 port 设置 小明 pac ima server
package com.mangoubiubiu.cxf.test; import javax.jws.WebService; @WebService //对外发布服务 public interface HelloWorld { public String sayHello(String name); }
package com.mangoubiubiu.cxf.test; import javax.jws.WebService; public class HelloWorldImpl implements HelloWorld { @Override public String sayHello(String name) { return "cxf1022"+name; } }
package com.mangoubiubiu.cxf.test; import org.apache.cxf.endpoint.Server; import org.apache.cxf.jaxws.JaxWsClientFactoryBean; import org.apache.cxf.jaxws.JaxWsServerFactoryBean; public class MainServer { public static void main(String args[]){ JaxWsServerFactoryBean jaxWsServerFactoryBean=new JaxWsServerFactoryBean(); jaxWsServerFactoryBean.setAddress("http://127.0.0.1:9999/cxf1022_server"); jaxWsServerFactoryBean.setServiceClass(HelloWorldImpl.class); Server server= jaxWsServerFactoryBean.create(); server.start(); } }
http://127.0.0.1:9999/cxf1022_server?wsdl
package com.mangoubiubiu.cxf.test; import org.apache.cxf.endpoint.Server; import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; import org.apache.cxf.jaxws.JaxWsServerFactoryBean; public class ClientServer { public static void main(String args[]){ // TODO Auto-generated method stub //创建调用服务的类... JaxWsProxyFactoryBean bean=new JaxWsProxyFactoryBean(); //设置访问地址 bean.setAddress("http://127.0.0.1:8888/cxf1022_server"); //设置接口类型... bean.setServiceClass(HelloWorld.class); HelloWorld us=(HelloWorld) bean.create(); String data=us.sayHello("小明"); System.out.println(data); } }
webservice 从入门到精通(二)helloworld(Webservice + cxf)
标签:out rri 技术 port 设置 小明 pac ima server
原文地址:https://www.cnblogs.com/mangoubiubiu/p/14833520.html