@EnableSoapAPIClient

master
beeajax 2 years ago
parent ec2f2fa26d
commit c799fe152b

@ -0,0 +1,14 @@
package com.docus.soap.api;
import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.Import;
import java.lang.annotation.*;
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Import(EnableSoapAPIClientSelector.class)
@Inherited
public @interface EnableSoapAPIClient {
AdviceMode mode() default AdviceMode.PROXY;
}

@ -0,0 +1,14 @@
package com.docus.soap.api;
import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.AdviceModeImportSelector;
public class EnableSoapAPIClientSelector extends AdviceModeImportSelector<EnableSoapAPIClient> {
@Override
protected String[] selectImports(AdviceMode adviceMode) {
if (adviceMode != AdviceMode.PROXY)
throw new IllegalStateException("@EnableSoapAPIClient only support PROXY advice mode.");
return new String[]{SoapAPIConfig.class.getName()};
}
}

@ -5,6 +5,9 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
/**
* @author nicle.lin
*/
@XmlRootElement(name = "SOF_GetQRCodeBySys", namespace = "http://webservice.qrcode.pki.jhsec.com.cn/") @XmlRootElement(name = "SOF_GetQRCodeBySys", namespace = "http://webservice.qrcode.pki.jhsec.com.cn/")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class GetTableByIdDateRequest { public class GetTableByIdDateRequest {

@ -3,39 +3,43 @@ package com.docus.soap.api.response.complain;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import java.util.ArrayList;
import java.util.List;
/**
* @author nicle.lin
*/
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class ComplaintListResult { public class ComplaintListResult {
@XmlElement(name = "DataItem") @XmlElement(name = "data")
private final List<DataItem> dataItem = new ArrayList<>(); private DataItem data;
@XmlElement(name = "code")
private String code;
@XmlElement(name = "totalpage") @XmlElement(name = "msg")
private int totalPage; private String msg;
@XmlElement(name = "totalrecord") public DataItem getData() {
private int totalRecord; return data;
}
public List<DataItem> getDataItem() { public void setData(DataItem data) {
return dataItem; this.data = data;
} }
public int getTotalPage() { public String getCode() {
return totalPage; return code;
} }
public void setTotalPage(int totalPage) { public void setCode(String code) {
this.totalPage = totalPage; this.code = code;
} }
public int getTotalRecord() { public String getMsg() {
return totalRecord; return msg;
} }
public void setTotalRecord(int totalRecord) { public void setMsg(String msg) {
this.totalRecord = totalRecord; this.msg = msg;
} }
} }

@ -1,22 +1,21 @@
package com.docus.soap.api.response.complain; package com.docus.soap.api.response.complain;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.XmlAccessorType; import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "SOF_GetQRCodeBySysResponse", namespace = "http://webservice.qrcode.pki.jhsec.com.cn/") @XmlRootElement(name = "SOF_GetQRCodeBySysResponse")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class GetComplaintListExResponse { public class GetComplaintListExResponse {
@XmlElement(name = "return") @XmlAnyElement
private String result; public List<Object> results;
public String getResult() {
return result; public List<Object> getResults() {
return results;
} }
public void setResult(String result) { public void setResults(List<Object> results) {
this.result = result; this.results = results;
} }
} }

@ -2,21 +2,25 @@ package com.docus.soap.api.response.complain;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
@XmlRootElement(name = "GetTableByIdDateResponse") /**
* @author nicle.lin
*/
@XmlRootElement(name = "SOF_GetQRCodeBySysResponse")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class GetTableByIdDateResponse { public class GetTableByIdDateResponse {
@XmlAnyElement
public List<Object> results;
@XmlElement(name = "GetTableByIdDateResult")
private String result;
public String getResult() { public List<Object> getResults() {
return result; return results;
} }
public void setResult(String result) { public void setResults(List<Object> results) {
this.result = result; this.results = results;
} }
} }

@ -1,18 +1,20 @@
package com.docus.soap.api.service; package com.docus.soap.api.service;
import com.docus.core.util.json.JSON;
import com.docus.soap.api.SoapAPIClient; import com.docus.soap.api.SoapAPIClient;
import com.docus.soap.api.SoapAPISettings; import com.docus.soap.api.SoapAPISettings;
import com.docus.soap.api.request.complain.GetTableByIdDateRequest; import com.docus.soap.api.request.complain.GetTableByIdDateRequest;
import com.docus.soap.api.response.complain.GetComplaintListExResponse; import com.docus.soap.api.response.complain.ComplaintListResult;
import com.docus.soap.api.response.complain.GetTableByIdDateResult; import com.docus.soap.api.response.complain.GetTableByIdDateResponse;
import com.sun.org.apache.xerces.internal.dom.ElementNSImpl;
public class ComplaintAPIService { public class ComplaintAPIService {
private SoapAPIClient soapAPIClient; private SoapAPIClient soapAPIClient;
public GetTableByIdDateResult getTableByIdDate(GetTableByIdDateRequest targetRequest, SoapAPISettings soapAPISettings) { public ComplaintListResult getTableByIdDate(GetTableByIdDateRequest targetRequest, SoapAPISettings soapAPISettings) {
GetComplaintListExResponse o = (GetComplaintListExResponse) soapAPIClient.soapCall(targetRequest, soapAPISettings.getAction(), soapAPISettings.getUri()); GetTableByIdDateResponse response = (GetTableByIdDateResponse) soapAPIClient.soapCall(targetRequest, soapAPISettings.getAction(), soapAPISettings.getUri());
System.out.println("1"); ComplaintListResult complaintListResult = JSON.fromJSON((((ElementNSImpl) response.getResults().get(0)).getFirstChild().getTextContent()), ComplaintListResult.class);
return null; return complaintListResult;
} }
public void setWebServiceClient(SoapAPIClient webServiceClient) { public void setWebServiceClient(SoapAPIClient webServiceClient) {

@ -2,7 +2,7 @@ package com.docus.soap.api;
import com.docus.core.util.AssertUtils; import com.docus.core.util.AssertUtils;
import com.docus.soap.api.request.complain.GetTableByIdDateRequest; import com.docus.soap.api.request.complain.GetTableByIdDateRequest;
import com.docus.soap.api.response.complain.GetTableByIdDateResult; import com.docus.soap.api.response.complain.ComplaintListResult;
import com.docus.soap.api.service.ComplaintAPIService; import com.docus.soap.api.service.ComplaintAPIService;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -33,7 +33,7 @@ public class ComplaintAPIServiceTest {
public void getTableByIdDateTest() { public void getTableByIdDateTest() {
GetTableByIdDateRequest request = new GetTableByIdDateRequest(); GetTableByIdDateRequest request = new GetTableByIdDateRequest();
request.setSys("JSScan"); request.setSys("JSScan");
GetTableByIdDateResult result = complaintAPIService.getTableByIdDate(request, getTableByIdDateSettings()); ComplaintListResult result = complaintAPIService.getTableByIdDate(request, getTableByIdDateSettings());
AssertUtils.assertNotNull(result, "not null"); AssertUtils.assertNotNull(result, "not null");
} }

Loading…
Cancel
Save