package cn.org.bjca.treport.ws.demo;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Test;
import cn.org.bjca.treport.ws.demo.element.DeleteReport;
import cn.org.bjca.treport.ws.demo.element.DeleteReportResponse;
import cn.org.bjca.treport.ws.demo.element.DownloadReport;
import cn.org.bjca.treport.ws.demo.element.DownloadReportResponse;
import cn.org.bjca.treport.ws.demo.element.QueryReport;
import cn.org.bjca.treport.ws.demo.element.QueryReportResponse;
import cn.org.bjca.treport.ws.demo.element.ReportWSReqMessage;
import cn.org.bjca.treport.ws.demo.element.ReportWSRespMessage;
import cn.org.bjca.treport.ws.demo.element.UploadReport;
import cn.org.bjca.treport.ws.demo.element.UploadReportResponse;
/***************************************************************************
* 可信报告单 ws客户端测试
***************************************************************************/
public class TrustReportWSClientTest {
//命名空间
public static final String targetNamespace = "urn:edms:names:jaxws:ws";
//服务名
public static final String serverName = "DocumentLifeCycleProviderService";
//端口名
public static final String portName = "DocumentLifeCycleProviderPort";
//服务地址
public static final String endpointAddress = "http://127.0.0.1:82/tdms/DocumentLifeCycleProviderService?wsdl";
//webservice 服务
private static Service service;
//webservice 端口
private static QName portQName;
/**
* 初始化webservice连接信息
* @Description:
*/
@Before
public void init() {
try {
URL wsdlURL = new URL(endpointAddress);
QName serviceQName = new QName(targetNamespace, serverName);
service = Service.create(wsdlURL, serviceQName);
portQName = new QName(targetNamespace, portName);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
@Test
public void testUploadReportFile() throws JAXBException, IOException{
// jaxb 绑定请求GenDocument 响应GenDocumentResponse
JAXBContext ctxt = JAXBContext.newInstance(UploadReport.class, UploadReportResponse.class);
// 创建与生成的 JAXB 对象一起使用的 Dispatch 实例
Dispatch
package cn.org.bjca.treport.ws.demo.element;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/***************************************************************************
* 撤销请求
***************************************************************************/
@XmlRootElement(name = "undoReport", namespace = "urn:edms:names:jaxws:ws")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "undoReport", namespace = "urn:edms:names:jaxws:ws", propOrder = {
"reportReqMessage"
})
public class DeleteReport {
@XmlElement(name = "reportReqMessage", namespace = "")
private ReportWSReqMessage reportReqMessage;
public ReportWSReqMessage getReportReqMessage() {
return reportReqMessage;
}
public void setReportReqMessage(ReportWSReqMessage reportReqMessage) {
this.reportReqMessage = reportReqMessage;
}
}
package cn.org.bjca.treport.ws.demo.element;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/***************************************************************************
* 撤销响应
***************************************************************************/
@XmlRootElement(name = "undoReportResponse", namespace = "urn:edms:names:jaxws:ws")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "undoReportResponse", namespace = "urn:edms:names:jaxws:ws")
public class DeleteReportResponse {
@XmlElement(name = "return", namespace = "")
private ReportWSRespMessage _return;
public ReportWSRespMessage get_return() {
return _return;
}
public void set_return(ReportWSRespMessage _return) {
this._return = _return;
}
}
package cn.org.bjca.treport.ws.demo.element;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/***************************************************************************
* 下载请求
***************************************************************************/
@XmlRootElement(name = "downloadReport", namespace = "urn:edms:names:jaxws:ws")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "downloadReport", namespace = "urn:edms:names:jaxws:ws", propOrder = {
"reportReqMessage"
})
public class DownloadReport {
@XmlElement(name = "reportReqMessage", namespace = "")
private ReportWSReqMessage reportReqMessage;
public ReportWSReqMessage getReportReqMessage() {
return reportReqMessage;
}
public void setReportReqMessage(ReportWSReqMessage reportReqMessage) {
this.reportReqMessage = reportReqMessage;
}
}
package cn.org.bjca.treport.ws.demo.element;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/***************************************************************************
* 下载响应
***************************************************************************/
@XmlRootElement(name = "downloadReportResponse", namespace = "urn:edms:names:jaxws:ws")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "downloadReportResponse", namespace = "urn:edms:names:jaxws:ws")
public class DownloadReportResponse {
@XmlElement(name = "return", namespace = "")
private ReportWSRespMessage _return;
public ReportWSRespMessage get_return() {
return _return;
}
public void set_return(ReportWSRespMessage _return) {
this._return = _return;
}
}
package cn.org.bjca.treport.ws.demo.element;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/***************************************************************************
* 查询报告单
***************************************************************************/
@XmlRootElement(name = "queryReport", namespace = "urn:edms:names:jaxws:ws")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "queryReport", namespace = "urn:edms:names:jaxws:ws", propOrder = {
"reportReqMessage"
})
public class QueryReport {
@XmlElement(name = "reportReqMessage", namespace = "")
private ReportWSReqMessage reportReqMessage;
public ReportWSReqMessage getReportReqMessage() {
return reportReqMessage;
}
public void setReportReqMessage(ReportWSReqMessage reportReqMessage) {
this.reportReqMessage = reportReqMessage;
}
}
package cn.org.bjca.treport.ws.demo.element;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/***************************************************************************
* 查询响应
***************************************************************************/
@XmlRootElement(name = "queryReportResponse", namespace = "urn:edms:names:jaxws:ws")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "queryReportResponse", namespace = "urn:edms:names:jaxws:ws")
public class QueryReportResponse {
@XmlElement(name = "return", namespace = "")
private ReportWSRespMessage _return;
public ReportWSRespMessage get_return() {
return _return;
}
public void set_return(ReportWSRespMessage _return) {
this._return = _return;
}
}
package cn.org.bjca.treport.ws.demo.element;
import java.io.Serializable;
/***************************************************************************
* 请求信息
***************************************************************************/
public class ReportWSReqMessage implements Serializable {
private static final long serialVersionUID = -4791087393335555937L;
private String reportNum;
private String reportTitle;
private String visitNum;
private String patientName;
private String clientType;
private String startTime;
private String endTime;
private String documentRuleNum;
private byte[] reportFileBty;
private String barcodeContent;
public String getReportNum() {
return reportNum;
}
public void setReportNum(String reportNum) {
this.reportNum = reportNum;
}
public String getReportTitle() {
return reportTitle;
}
public void setReportTitle(String reportTitle) {
this.reportTitle = reportTitle;
}
public String getVisitNum() {
return visitNum;
}
public void setVisitNum(String visitNum) {
this.visitNum = visitNum;
}
public String getPatientName() {
return patientName;
}
public void setPatientName(String patientName) {
this.patientName = patientName;
}
public String getClientType() {
return clientType;
}
public void setClientType(String clientType) {
this.clientType = clientType;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getDocumentRuleNum() {
return documentRuleNum;
}
public void setDocumentRuleNum(String documentRuleNum) {
this.documentRuleNum = documentRuleNum;
}
public byte[] getReportFileBty() {
return reportFileBty;
}
public void setReportFileBty(byte[] reportFileBty) {
this.reportFileBty = reportFileBty;
}
public String getBarcodeContent() {
return barcodeContent;
}
public void setBarcodeContent(String barcodeContent) {
this.barcodeContent = barcodeContent;
}
}
package cn.org.bjca.treport.ws.demo.element;
import java.io.Serializable;
/***************************************************************************
* 响应信息
***************************************************************************/
public class ReportWSRespMessage implements Serializable {
private static final long serialVersionUID = 2737051535444407591L;
private String statusCode;
private String reportInfos;
private byte[] reportFileBty;
public String getStatusCode() {
return statusCode;
}
public void setStatusCode(String statusCode) {
this.statusCode = statusCode;
}
public String getReportInfos() {
return reportInfos;
}
public void setReportInfos(String reportInfos) {
this.reportInfos = reportInfos;
}
public byte[] getReportFileBty() {
return reportFileBty;
}
public void setReportFileBty(byte[] reportFileBty) {
this.reportFileBty = reportFileBty;
}
}
package cn.org.bjca.treport.ws.demo.element;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/***************************************************************************
* 上传报告单请求
***************************************************************************/
@XmlRootElement(name = "uploadReport", namespace = "urn:edms:names:jaxws:ws")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "uploadReport", namespace = "urn:edms:names:jaxws:ws", propOrder = {
"reportReqMessage"
})
public class UploadReport {
@XmlElement(name = "reportReqMessage", namespace = "")
private ReportWSReqMessage reportReqMessage;
public ReportWSReqMessage getReportReqMessage() {
return reportReqMessage;
}
public void setReportReqMessage(ReportWSReqMessage reportReqMessage) {
this.reportReqMessage = reportReqMessage;
}
}
package cn.org.bjca.treport.ws.demo.element;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/***************************************************************************
* 上传报告单响应
***************************************************************************/
@XmlRootElement(name = "uploadReportResponse", namespace = "urn:edms:names:jaxws:ws")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "uploadReportResponse", namespace = "urn:edms:names:jaxws:ws")
public class UploadReportResponse {
@XmlElement(name = "return", namespace = "")
private ReportWSRespMessage _return;
public ReportWSRespMessage get_return() {
return _return;
}
public void set_return(ReportWSRespMessage _return) {
this._return = _return;
}
}