客户端调用webservice接口返回值为null问题~!!!!
package test;
import java.io.Serializable;
public class Course implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package test;
import java.io.Serializable;
public class User implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package test;
import java.util.List;
public interface IHelloService {
public String sayHello(String ttt);
public Course choose(User u);
public List test(List t);
}
package test;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class HelloServiceImpl implements IHelloService,Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
public String sayHello(String ttt) {
return "Hello, "+ttt;
}
public Course choose(User u){
System.out.println("u.getname-------------->"+u.getName());
Course c=new Course();
// c.setName("Eeee");
System.out.println(c.getName());
return c;
}
public List test(List t){
for (int i = 0; i < t.size(); i++) {
System.out.println("t的第"+i+"个--------------->"+(String) t.get(i));
}
List al=new ArrayList();
Course c=new Course();
//c.setName("EeeDDDDDD");
al.add(c);
return al;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<mappings>
<mapping>
<method name="test">
<parameter index="0" componentType="java.lang.String" />
<return-type componentType="test.Course" />
</method>
</mapping>
</mappings>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xfire.codehaus.org/config/1.0">
<service>
<name>HelloService</name>
<namespace>http://test/HelloService</namespace>
<serviceClass>test.IHelloService</serviceClass>
<implementationClass>test.HelloServiceImpl</implementationClass>
<style>wrapped</style>
<use>literal</use>
<scope>application</scope>
</service>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>XFireServlet</servlet-name>
<servlet-class>org.codehaus.xfire.transport.http.XFireConfigurableServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>XFireServlet</servlet-name>
<url-pattern>/servlet/XFireServlet/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>XFireServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
package com.client;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
public class testClient {
public static void main(String[] args) {
Service srvcModel = new ObjectServiceFactory()
.create(IHelloService.class);
XFireProxyFactory factory = new XFireProxyFactory(XFireFactory
.newInstance().getXFire());
String helloWorldURL = "http://localhost:8080/testWebService/services/HelloService";
try {
IHelloService srvc = (IHelloService) factory.create(srvcModel,
helloWorldURL);
System.out.println(srvc.sayHello("Robin"));
User u=new User();
u.setName("RRRRR");
Course c = srvc.choose(u);
//System.out.println(srvc.choose(u));
System.out.println(c.getName());
List t=new ArrayList();
t.add("1212");
t.add("2222");
List al=srvc.test(t);
System.out.println(al.size());
for (int i = 0; i < al.size(); i++) {
Course co=(Course)al.get(i);
System.out.println(co.getName());
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
}
[解决办法]
晕,你干脆把你项目传上去让高手帮忙解决吧,你光把代码传了架构没有啊
[解决办法]
具体问题出在哪?