首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

xfire关于webservice简略对象传输(都没有人给过评论)

2012-06-27 
xfire关于webservice简单对象传输(都没有人给过评论)服务端接口@WebService@SOAPBinding(style Style.RP

xfire关于webservice简单对象传输(都没有人给过评论)
服务端接口
@WebService
@SOAPBinding(style = Style.RPC)
public interface DownLoadFeederPdfService {

/**
* 下载馈线图 --PDF 格式 文件位置如: D:\PDF\白云供电局\槎头变电站\槎头F3.pdf
* 系统变量配置:PW_FEEDER_PDF_ROOT, 值如:D:\PDF
*
* @return 若文件不存在,返回null
* @author rxh 20101019
*/
public abstract FeederPdfByteBean DownloadFeederPdf(
@WebParam(name = "formAllowFeederPdfBean")
FormAllowFeederPdfBean formAllowFeederPdfBean);

}

实现类
@WebService
@SOAPBinding(style = Style.RPC)
public class DownLoadFeederPdfServiceImp implements DownLoadFeederPdfService {
/*
* (non-Javadoc)
*
* @see com.pwmis.webservice.inspect.service.impl.DownLoadFeederPdfService#DownloadFeederPdf(java.lang.String,
*      java.lang.String, java.lang.String)
*/
public FeederPdfByteBean DownloadFeederPdf(
@WebParam(name = "formAllowFeederPdfBean")
FormAllowFeederPdfBean formAllowFeederPdfBean) {
FeederPdfByteBean feederPdfByteBean = new FeederPdfByteBean();
// 获取系统属性中配置的馈线图文件目录,如D:/PDF
String feederPdfRoot = "";
StringBuffer filePath = new StringBuffer("D:\\101224最新PDF图");
filePath.append("\")
.append("-----");
filePath.append("\").append("-----");
filePath.append("\").append("-----")
.append(".pdf");
System.out.println(filePath.toString());
File file = new File(filePath.toString());
// 将文件读进字节数组并返回
byte[] bytes = null;
try {
FileInputStream fis = new FileInputStream(file);
int length = fis.available();
bytes = new byte[length];
fis.read(bytes, 0, length);
fis.close();
feederPdfByteBean.setFeederPdfByte(bytes);
} catch (IOException e) {
throw new RuntimeException("文件找不到", e);
}
return feederPdfByteBean;
}
}


简单对象
@XmlRootElement(name="FormAllowFeederPdfBean")   
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"departmentName","stationName","feederName"})
public class FormAllowFeederPdfBean implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private String departmentName;//名称
private String stationName;//名称
private String feederName;//名称
public String getDepartmentName() {
return departmentName;
}
public void setDepartmentName(String departmentName) {
this.departmentName = departmentName;
}
public String getStationName() {
return stationName;
}
public void setStationName(String stationName) {
this.stationName = stationName;
}
public String getFeederName() {
return feederName;
}
public void setFeederName(String feederName) {
this.feederName = feederName;
}

}


客户端用myeclipse生成xfire客户端,并且可以写测试类,不过对象传输,转换比较麻烦,需要转换对应的格式
XfireDownFeederPdfServiceClient client = new XfireDownFeederPdfServiceClient();
       
//create a default service endpoint
        XfireDownFeederPdfServicePortType service = client.getXfireDownFeederPdfServiceHttpPort();
        FormAllowFeederPdfBean FormAllowFeederPdfBean=new FormAllowFeederPdfBean();
        JAXBElement<String> departmentName1 = new JAXBElement<String>(new 
                QName("http://domain.inspectpdf.webservice.pwmis.com", "departmentName"),String.class,"-------");
        JAXBElement<String> stationName1 = new JAXBElement<String>(new 
                QName("http://domain.inspectpdf.webservice.pwmis.com", "stationName"),String.class,"-------");
        JAXBElement<String> feederName1 = new JAXBElement<String>(new 
                QName("http://domain.inspectpdf.webservice.pwmis.com", "feederName"),String.class,"-------");
        System.out.println(departmentName1+"--------"+stationName1+"-------"+feederName1);
        FormAllowFeederPdfBean.setDepartmentName(departmentName1);
        FormAllowFeederPdfBean.setStationName(stationName1);
        FormAllowFeederPdfBean.setFeederName(feederName1);
        FeederPdfByteBean feederPdfByteBean=service.downloadFeederPdf(FormAllowFeederPdfBean);

热点排行