Http Invoker是否能返回对象?
代码如下
PrintApplay.java(服务端与客户端的都一样)
- Java code
public class PrintApply implements Serializable { private static final long serialVersionUID = 1L; private String yybs; private String sjbbs; private String fqbs; public String getYybs() { return yybs; } public void setYybs(String yybs) { this.yybs = yybs; } public String getSjbbs() { return sjbbs; } public void setSjbbs(String sjbbs) { this.sjbbs = sjbbs; } public String getFqbs() { return fqbs; } public void setFqbs(String fqbs) { this.fqbs = fqbs; }
服务端interface
- Java code
import com.hxsmart.sicard.si.model.PrintApply;public interface RemoteService { public PrintApply receivePrintApply(String name,String idcd,String bankId,String nodeName,String nodeId);}
服务端实现类
- Java code
public class RemoteServiceImpl implements RemoteService { private ClientService clientService; @Override public PrintApply receivePrintApply(String name, String idcd, String bankId, String nodeName, String nodeId) { StringBuffer sb = new StringBuffer(); sb.append(name).append(idcd).append(bankid).append(nodeName).append(nodeId); List<PrintApply> list = clientService.sentMsg(sb.toString()); PrintApply printApply = list.get(0); return printApply; }}
客户端调用服务端接口
- Java code
public class RemoteExchgsvrServerImpl implements RemoteExchgsvrServer { @Override public List PrintInfoApply(String idcd, String name, String bankId, String nodeId, String nodeName) { ApplicationContext applicationContext = new ClassPathXmlApplicationContext("remote.xml"); try { RequestService service = (RequestService) applicationContext.getBean("remoteService"); PrintApply printApply = service.receivePrintApply(name, idcd, bankId, nodeName, nodeId); } catch (Exception e) { e.printStackTrace(); } return null; }}
报错代码:
- Java code
PrintApply printApply = service.receivePrintApply(name, idcd, bankId, nodeName, nodeId);
客户端报错信息:
Caused by: java.lang.ClassNotFoundException: com.hxsmart.sicard.si.model.PrintApply
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:604)
at org.springframework.remoting.rmi.CodebaseAwareObjectInputStream.resolveClass(CodebaseAwareObjectInputStream.java:79)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)