xfire关于webservice复杂对象传输

主要思路是将需要传输的对象用xml,json将对象描述,然后客户端接受对象后将xml,json解析成自己的对象,解析xml的工具有很多如dom4j


服务端接口
@WebService
@SOAPBinding(style = Style.RPC)
public interface XfireInspectRecoredXmlService {

/**
* xml文本记录对象信息
* @param xmlStr
* @return
*/
public abstract UpRecordBack insertRecord(@WebParam(name = "xmlStr")
String xmlStr);

}


服务端实现类
@WebService
@SOAPBinding(style = Style.RPC)
public class XfireInspectRecoredXmlServiceImp implements XfireInspectRecoredXmlService {
private InspectRecDefSixService inspectRecDefSixService;

/* (non-Javadoc)
* @see com.pwmis.webservice.inspectrecord.service.impl.XfireInspectRecoredXmlService#insertRecord(java.lang.String)
*/
public UpRecordBack insertRecord(@WebParam(name = "xmlStr")
String  xmlStr){
InspectRecored inspectRecored=new InspectRecored(); //将对象封装成字符串后解析插入记录
return inspectRecDefSixService.insertRecord(xmlStr);
}

public InspectRecDefSixService getInspectRecDefSixService() {
return inspectRecDefSixService;
}

public void setInspectRecDefSixService(
InspectRecDefSixService inspectRecDefSixService) {
this.inspectRecDefSixService = inspectRecDefSixService;
}


}

客户端调用需要将对象整合成xml格式字符串传输,客户端组合,服务端解析

猜你喜欢

转载自awen7916.iteye.com/blog/1257584