webservice我发布了一个services参数用的是一个实体类NodeInfo这样参数用实体类是不是不好啊.是否有局限呢?我觉得有一些.是不是最好都换到string或者是array啊?以下是我的测试代码,在发布webservice的项目中好使.同样的代码在另外一个单独的项目中调用不好使..不知道为什么.String serviceURL = "http://localhost:8080/Collect/services/IDataService";
Service serviceModel = new ObjectServiceFactory().create(
IDataService.class, null,
"http://localhost:8080/Collect/services/IDataService",
null); XFireProxyFactory serviceFactory = new XFireProxyFactory(); try {
IDataService service = (IDataService) serviceFactory.create(
serviceModel, serviceURL); // 忽略http连接的超时时间,0为不设置超时时间,》=1为超时毫秒数
Client client = Client.getInstance(service);
client.setProperty(CommonsHttpMessageSender.HTTP_TIMEOUT, "0");

String hello = service.sayHello("admin");
System.out.println("服务器对[张山疯] 的回答是:" + hello);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}

解决方案 »

  1.   

    webService 设计提供类做为参数,这是没有问题的
    至于使不使用实体类这个要看你如何来设计,我只能说现在很多大应该提供出的webService是用类的
      

  2.   

    java调用xfire做的webservice怎么总不行啊....
    谁有例子啊..
      

  3.   

    这个错误..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 org.codehaus.xfire.service.binding.ObjectServiceFactory.create(ObjectServiceFactory.java:374)
    at org.codehaus.xfire.service.binding.ObjectServiceFactory.create(ObjectServiceFactory.java:355)
    at test.arws.com.tweb.main(tweb.java:24)
    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)
    ... 22 more