----------------------------------------------------------------------------------------------------------------------------------------------------------

 泡牛吧!

                                       希望越来越多的光棍能够泡到牛

-----------------------------------------------------------------------------------------------------------------------------------------------------------

spring+xfire+webservice+helloworld
    由于我们网站的sso系统要实行夸语言,跨服务器的特点,按照领导的指示
要用webService 我就google找了一下关于webService的资料,发现webService还非常复杂,自然我只能最简单的办法来搞了,找了近一个小时,终于在一个老外的网站上看到了关于xfire插件支持java,最重要的是支持spring框架而且非常简单就实现了功能,好在简单提示英语只有初中水平就可以看懂,要不以我这我英语水平是根本看不懂的,我把例子download下来后查看代码,发现老外还是非常友好的代码在ecilpse下打包后直接在tomcat发布就ok了,和想像的结果一样
我就不这webService的例子拿出来和大家分享了。

Echo.java
package org.codehaus.xfire.spring.example;
public interface Echo{
    String echo(String in);
}
EchoImpl.java
package org.codehaus.xfire.spring.example;
public class EchoImpl  implements Echo{
    public String echo(String in){
        return in;
    }
}
applicationContext.xml
<?xml version=1.0 encoding=UTF-8?>
<beans>
    <bean id=echoBean class=org.codehaus.xfire.spring.example.EchoImpl/>
</beans>
这上面的就最简单的spring IoC 下helloworld的例子
这文件xfire-servlet.xml配置是关键:
xfire-servlet.xml
<?xml version=1.0 encoding=UTF-8?>
<beans>
    <bean class=org.springframework.web.servlet.handler.SimpleUrlHandlerMapping>
        <property name=urlMap>
            <map>
                <entry key=/EchoService>
                    <ref bean=echo>
                </entry>
            </map>
        </property>
    </bean>
    <bean id=echo     class=org.codehaus.xfire.spring.remoting.XFireExporter>
        <property name=serviceFactory>
            <ref bean=xfire.serviceFactory
        </property>
        <property name=xfire>
            <ref bean=xfire
        </property>
        <property name=serviceBean>
            <ref bean=echoBean
        </property>
        <property name=serviceClass>
            <value>org.codehaus.xfire.spring.example.Echo</value>
        </property>
    </bean>
</beans>
接下来是客户端的test就更简单了
客户端

applicationContext-client.xml
<?xml version=1.0 encoding=UTF-8?>
<beans>
<beanid=testWebService class=org.codehaus.xfire.spring.remoting.XFireClientFactoryBean>
      <property name=serviceClass>
         <value>org.codehaus.xfire.spring.example.Echo</value>
      </property>
      <property name=wsdlDocumentUrl>
        <value>http://127.0.0.1:8080/xfire/EchoService?wsdl</value>
      </property>
     </bean>
<beans>
package test;
import java.util.*;
import junit.framework.TestCase;
import org.codehaus.xfire.spring.example.*;
public class WebServiceClientTest extends TestCase {
Echo echo=null;
static {
ApplicationContextFactory.init(/test/applicationContext-client.xml);
}
public static void main(String[] args) {
junit.swingui.TestRunner.run(PlayContextDaoTest.class);
}
protected void setUp() throws Exception {
echo=(Echo)ApplicationContextFactory.getApplicationContext().getBean(testWebService);
super.setUp();
}
protected void tearDown() throws Exception {
super.tearDown();
}
public  void testCilient(){
   System.out.print(echo.echo(haoha i haohao));
}
}

XmlSchema-1.0.3.jar  activation-1.1.jar
bcprov-jdk15-133.jar
commons-attributes-api-2.1.jar
commons-beanutils-1.7.0.jar
commons-codec-1.3.jar
commons-discovery-0.2.jar
commons-httpclient-3.0.jar
commons-logging-1.0.4.jar
jaxb-api-1.0.jar
jaxb-api-2.0EA3.jar
jaxb-impl-1.0.5.jar
jaxb-impl-2.0EA3.jar
jaxb-xjc-2.0EA3.jar
jaxen-1.1-beta-8.jar
jdom-1.0.jar
jmock-1.0.1.jar
junit-3.8.1.jar
log4j-1.2.6.jar
mail-1.4.jar
opensaml-1.0.1.jar
org.mortbay.jetty-5.1.3.jar
relaxngDatatype-20050913.jar
spring-1.2.6.jar
stax-api-1.0.1.jar
stax-utils-snapshot-20040917.jar
sun-jaxws-api-2.0-ea3.jar
sun-saaj-api-2.0-ea3.jar
sun-saaj-impl-2.0-ea3.jar
wsdl4j-1.5.2.jar
wss4j-1.5.0.jar
wstx-asl-2.9.3.jar
xbean-2.1.0.jar
xbean-spring-2.3.jar
xercesImpl-2.6.2.jar
xfire-aegis-1.1.jar
xfire-annotations-1.1.jar
xfire-core-1.1.jar
xfire-distribution-1.1.jar
xfire-generator-1.1.jar
xfire-java5-1.1.jar
xfire-jaxb-1.1.jar
xfire-jaxb2-1.1.jar
xfire-jaxws-1.1.jar
xfire-jsr181-api-1.0-M1.jar
xfire-spring-1.1.jar
xfire-ws-security-1.1.jar
xfire-xmlbeans-1.1.jar
xml-apis-1.0.b2.jar
xmlsec-1.3.0.jar
xsdlib-20050913.jar
haohao   2006-06-20 19:03:55 评论:4   阅读:8249   引用:0
笨 @2008-08-08 10:25:32  ?|??|?
请说清楚嘛。。。
乱七八糟 @2008-08-05 15:27:56  JAVA
怎么这样。后面那个WebServiceClientTest 根本就不知道你是些什么鬼东西。要搞就搞个好点的出来看看。郁闷啦。。
@2007-10-20 11:33:45  cary
java群:45836394
主题 @2006-09-06 22:13:29  姓名
署名发表(评论可管理,不必输入下面的姓名

发表评论>>

署名发表(评论可管理,不必输入下面的姓名)

姓名:

主题:

内容: 最少15个,最长1000个字符

认证码: (如不清楚,请刷新)


一切版权属于个人(转载例外)