请用过xfire的朋友不要客气唱所欲谈吧

解决方案 »

  1.   

    这里有一个中文版的PDF,http://www.kuaff.com,还不错楼主下到了别忘了给偶分哦
      

  2.   

    因为项目需要,正在研究xfire,我目前已经配好了xfire和spring的集成,正准备着手写一个综合的demo
    大家多交流交流
      

  3.   

    还有JR里关于 Xfire的文章也比较多:
    http://www.javaresearch.org/article/column.jsp?column=5
      

  4.   

    大家如给的一件有意义我肯定不会吝啬的,http://www.kuaff.com我已经看过了
    里面的
    <taskdef name="wsgen" classname="org.codehaus.xfire.gen.WsGenTask"
    classpathref="xfire ¨ jar &copy;l&ordf; " />
    <wsgen outputDirectory="client" wsdl="MathService.
    package="com.kuaff.xfire.samples" />
    不知道该写到那块?
      

  5.   

    发布web服务已经没什么问题了!
    不知怎样开发客户端程序?
    大家继续!!!
      

  6.   

    开发客户端程序有两种,一种自己手写,还有是用工具通过wsdl来自动生成client
    我是手写的,比如:
    Service serviceModel = new ObjectServiceFactory(new AegisBindingProvider())
    .create(MathService.class);
    "http://localhost:8080/xfire/MathService.soap");
    System.out.println(service.add(10, 20));
      

  7.   

    上面的代码不小心漏掉了一部分,现在补全我自己现在也有个问题,当方法参数是JavaBean该怎么处理,我写了配置文件MathService.aegis.xml,但是好像没有用,不知楼主这个问题解决了没有
    Service serviceModel = new ObjectServiceFactory(new AegisBindingProvider())
    .create(MathService.class); MathService service = (MathService) new XFireProxyFactory().create(
    serviceModel, "http://localhost:8080/xfire/MathService.soap"); System.out.println(service.add(10, 20));
      

  8.   

    leafxx(我是你装满回忆的盒饭,你的承诺)
    十分感激你的回复!
    我刚接触xfire,以前都是用axis来开发webservice
    我现在只做到了这一步:
    就是web服务可以发布成功,现在想开发个客户端程序来调用这个web服务,不知道怎么继续下去!可否把你的源码发给我借鉴一下!十分感谢!
      

  9.   

    不好意思,我们公司屏蔽邮箱,代码没法给你你现在不是已经配置好服务了么,那么我把Client的代码发上来不就可以了?代码就在上面,已经是全部了
      

  10.   

    MathService.soap这个是什么东西?
    是一个配置文件?
      

  11.   

    leafxx(我是你装满回忆的盒饭,你的承诺)把你的发给我看看吧!(打个包!)
    多谢了!
      

  12.   

    实际上是这样:
    把开发好的一个web服务放到一台服务器上,在另一台机器上开发一个客户端去调用这个web服务,之后再作一些后续的处理!!!
      

  13.   

    最好是支持spring的!
    大哥求你了!
    行行好了!
      

  14.   

    确实是支持spring的,可我们这里不能用任何聊天工具(除了内部的)和email,所以无法直接把包发给你,我贴代码吧
      

  15.   

    HelloService.javapackage xfire;public interface HelloService { public abstract String sayHello(String name);
             
            //不能用,目前还没配置好传递JavaBean
    //public abstract String sayHelloBean(Employee name);}HelloServiceImpl.java
    package xfire;public class HelloServiceImpl implements HelloService {
    public String sayHello(String name) {
    return "Hello, " + name;
    } //public String sayHelloBean(Employee name) {
    // return "Hello, " + name;
    //}
    }applicationContext.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    <bean id="helloBean" class="xfire.HelloServiceImpl" />
    </beans>
      

  16.   

    xfire-servlet.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    <import resource="classpath:org/codehaus/xfire/spring/xfire.xml" />
    <bean
    class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="urlMap">
    <map>
    <entry key="/HelloService.soap">
    <ref bean="hello" />
    </entry>
    </map>
    </property>
    </bean> <bean id="baseWebService" class="org.codehaus.xfire.spring.remoting.XFireExporter" abstract="true">
    <property name="serviceFactory">
    <ref bean="xfire.serviceFactory" />
    </property>
    <property name="xfire">
    <ref bean="xfire" />
    </property>
    </bean>

    <bean id="math" parent="baseWebService">
    <property name="serviceBean">
    <ref bean="mathBean" />
    </property>
    <property name="serviceClass">
    <value>xfire.MathService</value>
    </property>
    </bean>

    <bean id="hello" parent="baseWebService">
    <property name="serviceBean">
    <ref bean="helloBean" />
    </property>
    <property name="serviceClass">
    <value>xfire.HelloService</value>
    </property>
    </bean>
    </beans>
    web.xml
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <!-- START SNIPPET: xfire -->
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
    /WEB-INF/applicationContext.xml
    </param-value>
    </context-param> <context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/log4j.properties</param-value>
    </context-param> <listener>
    <listener-class>
    org.springframework.web.util.Log4jConfigListener
    </listener-class>
    </listener>  <listener> 
        <listener-class>
         org.springframework.web.context.ContextLoaderListener
        </listener-class> 
      </listener>  <servlet>
    <servlet-name>xfire</servlet-name>
    <servlet-class>
    org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    </servlet> <servlet-mapping>
    <servlet-name>xfire</servlet-name>
    <url-pattern>*.soap</url-pattern>
    </servlet-mapping>
    <!-- END SNIPPET: xfire -->

    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.htm</welcome-file>
    </welcome-file-list>
    </web-app>
      

  17.   

    Service serviceModel = new ObjectServiceFactory(new AegisBindingProvider())
    .create(MathService.class);MathService service = (MathService) new XFireProxyFactory().create(
    serviceModel, "http://localhost:8080/xfire/MathService.soap");System.out.println(service.add(10, 20));
    这是客户端的代码?
    我客户端调用web服务的时候,本地根本不能得到MathService.class这个类的!
    实际上是这样:
    把开发好的一个web服务放到一台服务器上,在另一台机器上开发一个客户端去调用这个web服务,之后再作一些后续的处理!!!
      

  18.   

    客户端代码:Service helloServiceModel = new ObjectServiceFactory().create(HelloService.class);
    HelloService hello = (HelloService) new XFireProxyFactory().create(helloServiceModel, "http://localhost:8080/xfire/HelloService.soap");
    Employee e = new Employee();
    e.setEmployeeName("jeff");
    //原来的代码:System.out.println(hello.sayHelloBean(new Employee("jeffrey"));
    System.out.println(hello.sayHelloBean(e));我原来的问题已经被我老大解决了,原来我写的JavaBean有问题,Employee里我把默认构造方法给去掉了,就不是一个JavaBean因此无法传输
      

  19.   

    在浏览器上你怎么调用web服务?
    http://localhost:8080/XfireSpring/MathService这样?我这么调用提示我:Invalid SOAP request.
    不知何解?
      

  20.   

    web service无所谓在哪个服务器上,客户端只要知道服务器的url就可以了
    在例子里就是http://localhost:8080/......本地客户端需要知道你所要调用的Service的接口,然后xfire用这些接口来作动态代理,得到运行期的Service,就好像在本地调用一样。如果你用过apache soap就知道写客户端代码有多么烦,只有自己来写一个soap的动态代理的包装类,在xfire里已经为你完成一切了,just need:
    Service helloServiceModel = new ObjectServiceFactory().create(HelloService.class);
    HelloService hello = (HelloService) new XFireProxyFactory().create(helloServiceModel, "http://localhost:8080/xfire/HelloService.soap");
      

  21.   


    在浏览器上你怎么调用web服务?
    http://localhost:8080/XfireSpring/MathService这样?我这么调用提示我:Invalid SOAP request.
    不知何解?---------------------------------------------Invalid SOAP request.这表示你已经能够访问了,配置是没有问题的
    你可以试试看:http://localhost:8080/XfireSpring/MathService?wsdl
    如果你能看到xml文件,配置肯定是没有问题的SOAP是给客户端访问的不是浏览器
      

  22.   

    >? 
    兄弟!
    有啥好学习资料给整点!
    我叫姚立锋!---------------
    :)
    XFire 的资料真的非常少,这是一个非常新的SOAP框架,号称“下一代”,别说中文的,英文的都没有什么资料。我在TTS的web services/xml论坛里也没找到什么英文的:
    <Webservices with Spring, XFire and jsr181>
    http://www.logemann.org/blojsom/blog/default/?permalink=Webservices-with-Spring-XFire-and-jsr181.htmlAppFuse有关xfire和spring集成的文章
    http://raibledesigns.com/wiki/Wiki.jsp?page=AppFuseXFire#ref-AppFuseXFire-2中文的:
    SpringSide有关Xfire的介绍:(你可以下载SpringSide的源代码参考一下)
    http://www.springside.org.cn/docs/reference/XFire.htm
      

  23.   

    接触过xfire的都进来讨论讨论了!
      

  24.   

    这是我的web服务:
    http://localhost:8080/XfireSpring/MathService
      

  25.   

    Service mathServiceModel = new ObjectServiceFactory().create(MathService.class);
    MathService math = (MathService) new XFireProxyFactory().create(mathServiceModel, "http://localhost:8080/XfireSpring/MathService");
    System.out.println(math.add(1, 2)); // should print 3
    具体类所在位置请查api
      

  26.   

    我的意思是:
    远程调用我这个服务的时候,比如说你现在要调用我的服务,你那面应该怎么做?
    MathService.class这个类你那边根本没有,我只能给你提供一个“http://localhost:8080/XfireSpring/MathService”你怎么来调用我这个服务???
      

  27.   

    也就是说:你怎样开发一个应用程序来消费我的这个web服务!!!
    呵呵!我还是有点郁闷
      

  28.   

    MathService只是一个接口,你为什么不能提供给客户端程序员,我觉得很奇怪
      

  29.   

    对呀,实现类是在服务端配置在Spring里的,客户端只需要知道Service的接口和服务的url就可以调用了,你得到的其实是一个动态代理,使用方式仿佛在本地一般,那个代理类代理了远程调用真正的服务
    你也可以自己写一个包装类进一步的简化客户端代码