日期:2014-05-20  浏览次数:20814 次

求xfire Client 例子一个...可追加分数.
我创建了一个java project 用一个main方法来调用测试一下总是报一下错误...

我不知道client该怎么写好....

网上的...写的...不太好使...

我吧接口贴出来吧...

这2种形式....

我在发布web services 的项目中测试是可以通过的.

但是换了项目调用就不可以了....

我不太明白为什么........

问题帮我解决我在帖子送分......
Java code

public String sayHello(String str);
public String login(User user);




Java code
Exception in thread "main" java.lang.NoClassDefFoundError
    at org.codehaus.xfire.aegis.type.DefaultTypeMappingRegistry.class$(DefaultTypeMappingRegistry.java:64)
    at org.codehaus.xfire.aegis.type.DefaultTypeMappingRegistry.createDefaultMappings(DefaultTypeMappingRegistry.java:406)
    at org.codehaus.xfire.aegis.type.DefaultTypeMappingRegistry.createDefaultMappings(DefaultTypeMappingRegistry.java:311)
    at org.codehaus.xfire.aegis.type.DefaultTypeMappingRegistry.<init>(DefaultTypeMappingRegistry.java:131)
    at org.codehaus.xfire.aegis.type.DefaultTypeMappingRegistry.<init>(DefaultTypeMappingRegistry.java:137)
    at org.codehaus.xfire.aegis.type.DefaultTypeMappingRegistry.<init>(DefaultTypeMappingRegistry.java:118)
    at org.codehaus.xfire.aegis.AegisBindingProvider.<init>(AegisBindingProvider.java:67)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.codehaus.xfire.service.binding.ObjectServiceFactory.getBindingProvider(ObjectServiceFactory.java:173)
    at org.codehaus.xfire.service.binding.DefaultServiceConfiguration.getInParameterName(DefaultServiceConfiguration.java:162)
    at org.codehaus.xfire.service.binding.ObjectServiceFactory.getInParameterName(ObjectServiceFactory.java:1063)
    at org.codehaus.xfire.service.binding.ObjectServiceFactory.addOperation(ObjectServiceFactory.java:817)
    at org.codehaus.xfire.service.binding.ObjectServiceFactory.initializeOperations(ObjectServiceFactory.java:761)
    at org.codehaus.xfire.service.binding.ObjectServiceFactory.create(ObjectServiceFactory.java:444)
    at test.arws.com.webServiceTest.main(webServiceTest.java:20)
Caused by: java.lang.ClassNotFoundException: org.jdom.Element
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    ... 20 more



------解决方案--------------------
讲的不够清楚!!

------解决方案--------------------
我的调用,是一个简单调用..

其他复杂的....需要时

找我....
Java code
Client client;
        try {
            client = new Client(new URL(
            "http://localhost:8080/A/services/Service?wsdl"));
            Object[] results = client
            .invoke("sayHello", new Object[] { "Firends" });
            System.out.println(results[0]);
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }