xfilre

搭建环境
 
xfilre_第1张图片

配置servlet
<servlet>
    <servlet-name>XFire</servlet-name>
    
    <servlet-class>
        org.codehaus.xfire.transport.http.XFireConfigurableServlet
    </servlet-class>    
  </servlet>

  <servlet-mapping>
    <servlet-name>XFire</servlet-name>
    <url-pattern>/servlet/XFireServlet/*</url-pattern>
  </servlet-mapping>
编写接口和实现类
 com.service.IPayService
 com.service.impl.PayService
配置service.xml文件(文件路径为类路径下的META-INF/xfire/services.xml)
<beans xmlns="http://xfire.codehaus.org/config/1.0">
  <service>
    <name>HelloWorldService</name>
    <namespace>http://www.cc.com:8080/xfiretest/services/HelloWorldService</namespace>
    <serviceClass>
        com.service.IPayService
    </serviceClass>    
     <implementationClass>
     com.service.impl.PayService
     </implementationClass>
     
  </service>
</beans>

检查服务

xfilre_第2张图片


调用服务:
            XFire xfire = XFireFactory.newInstance().getXFire();
        ServiceFactory factory = new ObjectServiceFactory(xfire.getTransportManager(), null);

        Service service = factory.create(IPayService.class,
                                         "HelloWorldService",
                                         "http://www.cc.com:8080/xfiretest/services/HelloWorldService",
                                         null);
        IPayService client = (IPayService)new XFireProxyFactory).createservice,"http://www.cc.com:8080/xfiretest/services/HelloWorldService");
//此处没有?wsdl")
        
        client.payMoney(100.0d);//方法调用



一、服务提供者告诉你interface,你可以使用如下三种方式来开发:
YourService即是服务提供者告诉给你的一个interface(当然,也可以根据WSDL的定义,自己定义一个同样的interface)。
1,简单的方式
Service serviceModel = new ObjectServiceFactory().create(YourService.class);
YourService service = (YourService)
    new XFireProxyFactory().create(serviceModel, "http://your/remote/url");
2,JSR 181注释的方式
Service serviceModel = new AnnotationServiceFactory().create(YourService.class);
YourService client = (YourService)
    new XFireProxyFactory().create(serviceModel, "http://your/remote/url");
3,混合方式
Service serviceModel =
  new AnnotationServiceFactory(
   new Jsr181WebAnnotations(),
   XFireFactory.newInstance().getXFire().getTransportManager(),
   new AegisBindingProvider(new JaxbTypeRegistry())).create(YourService.class);



你可能感兴趣的:(service,null,interface)