新增docus-soap-client-api
commit
ec2f2fa26d
@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>framework</artifactId>
|
||||
<groupId>com.docus</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>docus-soap-api-client</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<name>docus-soap-api-client</name>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-core</artifactId>
|
||||
<version>${spring-ws.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.docus</groupId>
|
||||
<artifactId>docus-tool-starter</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
<version>1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,13 @@
|
||||
package com.docus.soap.api;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class DocusSoapApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DocusSoapApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.docus.soap.api;
|
||||
|
||||
import org.springframework.ws.client.core.WebServiceTemplate;
|
||||
|
||||
public class SoapAPIClient {
|
||||
private WebServiceTemplate webServiceTemplate;
|
||||
private SoapAPIMessageGenerator messageGenerator;
|
||||
private SoapAPIResponseExtractor responseExtractor;
|
||||
|
||||
public Object soapCall(Object requestBody, String soapAction, String uri) {
|
||||
SoapMessageEnvelope messageEnvelope = new SoapMessageEnvelope();
|
||||
messageEnvelope.setSoapBody(requestBody);
|
||||
messageEnvelope.setSoapAction(soapAction);
|
||||
webServiceTemplate.setDefaultUri(uri);
|
||||
return webServiceTemplate.sendAndReceive(messageGenerator.generateSoapMessage(messageEnvelope), responseExtractor.generateExtractor());
|
||||
}
|
||||
|
||||
public void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) {
|
||||
this.webServiceTemplate = webServiceTemplate;
|
||||
}
|
||||
|
||||
public void setMessageGenerator(SoapAPIMessageGenerator messageGenerator) {
|
||||
this.messageGenerator = messageGenerator;
|
||||
}
|
||||
|
||||
public void setResponseExtractor(SoapAPIResponseExtractor responseExtractor) {
|
||||
this.responseExtractor = responseExtractor;
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package com.docus.soap.api;
|
||||
|
||||
import com.docus.soap.api.service.ComplaintAPIService;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
|
||||
import org.springframework.ws.client.core.WebServiceTemplate;
|
||||
import org.springframework.ws.client.support.interceptor.ClientInterceptor;
|
||||
import org.springframework.ws.soap.SoapVersion;
|
||||
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
|
||||
import org.springframework.ws.transport.http.HttpComponentsMessageSender;
|
||||
|
||||
import javax.inject.Named;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
public class SoapAPIConfig {
|
||||
|
||||
@Bean
|
||||
public WebServiceTemplate webServiceTemplate() {
|
||||
WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
|
||||
webServiceTemplate.setMessageFactory(saajSoapMessageFactory());
|
||||
webServiceTemplate.setMarshaller(marshaller());
|
||||
webServiceTemplate.setUnmarshaller(unmarshaller());
|
||||
webServiceTemplate.setMessageSender(new HttpComponentsMessageSender());
|
||||
webServiceTemplate.setInterceptors(interceptors());
|
||||
return webServiceTemplate;
|
||||
}
|
||||
|
||||
private ClientInterceptor[] interceptors() {
|
||||
List<ClientInterceptor> clientInterceptors = new ArrayList<>();
|
||||
clientInterceptors.add(new SoapAPILogIntercepter());
|
||||
return clientInterceptors.toArray(new ClientInterceptor[clientInterceptors.size()]);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SaajSoapMessageFactory saajSoapMessageFactory() {
|
||||
SaajSoapMessageFactory factory = new SaajSoapMessageFactory();
|
||||
factory.setSoapVersion(SoapVersion.SOAP_11);
|
||||
return factory;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Named(value = "marshaller")
|
||||
public Jaxb2Marshaller marshaller() {
|
||||
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
|
||||
marshaller.setBeanClassLoader(ClassLoader.getSystemClassLoader());
|
||||
marshaller.setPackagesToScan(new String[]{"com.docus.soap.api.request"});
|
||||
return marshaller;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Named(value = "unmarshaller")
|
||||
public Jaxb2Marshaller unmarshaller() {
|
||||
Jaxb2Marshaller unmarshaller = new Jaxb2Marshaller();
|
||||
unmarshaller.setBeanClassLoader(ClassLoader.getSystemClassLoader());
|
||||
unmarshaller.setPackagesToScan(new String[]{"com.docus.soap.api.response"});
|
||||
return unmarshaller;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SoapAPIMessageGenerator soapAPIMessageGenerator() {
|
||||
SoapAPIMessageGenerator soapApiMessageGenerator = new SoapAPIMessageGenerator();
|
||||
soapApiMessageGenerator.setMarshaller(marshaller());
|
||||
return soapApiMessageGenerator;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SoapAPIResponseExtractor soapAPIResponseExtractor() {
|
||||
SoapAPIResponseExtractor soapApiResponseExtractor = new SoapAPIResponseExtractor();
|
||||
soapApiResponseExtractor.setUnmarshaller(unmarshaller());
|
||||
return soapApiResponseExtractor;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SoapAPIClient soapApiClient() {
|
||||
SoapAPIClient soapAPIClient = new SoapAPIClient();
|
||||
soapAPIClient.setWebServiceTemplate(webServiceTemplate());
|
||||
soapAPIClient.setMessageGenerator(soapAPIMessageGenerator());
|
||||
soapAPIClient.setResponseExtractor(soapAPIResponseExtractor());
|
||||
return soapAPIClient;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ComplaintAPIService complaintApiService() {
|
||||
ComplaintAPIService complaintApiService = new ComplaintAPIService();
|
||||
complaintApiService.setWebServiceClient(soapApiClient());
|
||||
return complaintApiService;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.docus.soap.api;
|
||||
|
||||
import com.docus.soap.api.util.XmlUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.client.WebServiceClientException;
|
||||
import org.springframework.ws.client.support.interceptor.ClientInterceptor;
|
||||
import org.springframework.ws.context.MessageContext;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
|
||||
public class SoapAPILogIntercepter implements ClientInterceptor {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(SoapAPILogIntercepter.class);
|
||||
|
||||
@Override
|
||||
public boolean handleRequest(MessageContext messageContext) throws WebServiceClientException {
|
||||
WebServiceMessage request = messageContext.getRequest();
|
||||
SoapMessage soapMessage = (SoapMessage) request;
|
||||
logger.debug("soap-action:{}", soapMessage.getSoapAction());
|
||||
logger.debug("soap-request:\n{}", XmlUtils.pretty(soapMessage.getDocument()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleResponse(MessageContext messageContext) throws WebServiceClientException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleFault(MessageContext messageContext) throws WebServiceClientException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(MessageContext messageContext, Exception ex) throws WebServiceClientException {
|
||||
WebServiceMessage request = messageContext.getResponse();
|
||||
SoapMessage soapMessage = (SoapMessage) request;
|
||||
logger.debug("response:\n{}", XmlUtils.pretty(soapMessage.getDocument()));
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.docus.soap.api;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.oxm.Marshaller;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.client.core.WebServiceMessageCallback;
|
||||
import org.springframework.ws.soap.saaj.SaajSoapMessage;
|
||||
import org.springframework.ws.support.MarshallingUtils;
|
||||
|
||||
import javax.xml.transform.TransformerException;
|
||||
import java.io.IOException;
|
||||
|
||||
public class SoapAPIMessageGenerator {
|
||||
private final Logger logger = LoggerFactory.getLogger(SoapAPIMessageGenerator.class);
|
||||
private Marshaller marshaller;
|
||||
|
||||
public WebServiceMessageCallback generateSoapMessage(final SoapMessageEnvelope envelope) {
|
||||
return new WebServiceMessageCallback() {
|
||||
@Override
|
||||
public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
|
||||
try {
|
||||
SaajSoapMessage soapMessage = (SaajSoapMessage) message;
|
||||
marshallerRequestSoapBody(soapMessage, envelope.getSoapBody());
|
||||
soapMessage.setSoapAction(envelope.getSoapAction());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void marshallerRequestSoapBody(SaajSoapMessage soapMessage, Object soapBody) throws IOException {
|
||||
if (null == marshaller) {
|
||||
throw new IllegalStateException("Not marshaller registered ,please check your configuration.");
|
||||
}
|
||||
MarshallingUtils.marshal(marshaller, soapBody, soapMessage);
|
||||
}
|
||||
|
||||
public void setMarshaller(Marshaller marshaller) {
|
||||
this.marshaller = marshaller;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.docus.soap.api;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.oxm.Unmarshaller;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.client.core.WebServiceMessageExtractor;
|
||||
import org.springframework.ws.soap.SoapFault;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.ws.support.MarshallingUtils;
|
||||
|
||||
import javax.xml.transform.TransformerException;
|
||||
import java.io.IOException;
|
||||
|
||||
public class SoapAPIResponseExtractor {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(SoapAPIResponseExtractor.class);
|
||||
private Unmarshaller unmarshaller;
|
||||
|
||||
public WebServiceMessageExtractor generateExtractor() {
|
||||
return new WebServiceMessageExtractor() {
|
||||
@Override
|
||||
public Object extractData(WebServiceMessage message) throws IOException, TransformerException {
|
||||
SoapMessage soapMessage = (SoapMessage) message;
|
||||
SoapFault fault = soapMessage.getSoapBody().getFault();
|
||||
if (null != fault) {
|
||||
logger.info("{}", fault.getFaultStringOrReason());
|
||||
} else {
|
||||
return MarshallingUtils.unmarshal(unmarshaller, message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void setUnmarshaller(Unmarshaller unmarshaller) {
|
||||
this.unmarshaller = unmarshaller;
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.docus.soap.api;
|
||||
|
||||
public class SoapAPISettings {
|
||||
private String action;
|
||||
private String testAction;
|
||||
private String uri;
|
||||
private String systemCode;
|
||||
private String password;
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getTestAction() {
|
||||
return testAction;
|
||||
}
|
||||
|
||||
public void setTestAction(String testAction) {
|
||||
this.testAction = testAction;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public String getSystemCode() {
|
||||
return systemCode;
|
||||
}
|
||||
|
||||
public void setSystemCode(String systemCode) {
|
||||
this.systemCode = systemCode;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.docus.soap.api;
|
||||
|
||||
public class SoapMessageEnvelope {
|
||||
|
||||
private Object soapBody;
|
||||
|
||||
private String soapAction;
|
||||
|
||||
public Object getSoapBody() {
|
||||
return soapBody;
|
||||
}
|
||||
|
||||
public void setSoapBody(Object soapBody) {
|
||||
this.soapBody = soapBody;
|
||||
}
|
||||
|
||||
public String getSoapAction() {
|
||||
return soapAction;
|
||||
}
|
||||
|
||||
public void setSoapAction(String soapAction) {
|
||||
this.soapAction = soapAction;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.docus.soap.api.request.complain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public enum ComplaintProcessStatus {
|
||||
|
||||
/*受理中*/
|
||||
RECEIVED(0),
|
||||
/*网友已给出方案*/
|
||||
BUYER_GIVE_SOLUTION(1),
|
||||
/*商家已给出方案*/
|
||||
SELLER_GIVE_SOLUTION(2),
|
||||
/*安排监理上门*/
|
||||
SUPERVISOR_CALL(3),
|
||||
/*双方达成协议*/
|
||||
REACH_AGREEMENT(4),
|
||||
/*协调未果*/
|
||||
CONSULTATION_NO_RESULT(5),
|
||||
/*无理投诉*/
|
||||
UNJUSTIFIABLE_COMPLAINT(6),
|
||||
/*处理完成*/
|
||||
FINISH(7),
|
||||
/*节后处理*/
|
||||
PROCESS_AFTER_HOLIDAY(8);
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ComplaintProcessStatus.class);
|
||||
|
||||
private int value;
|
||||
|
||||
ComplaintProcessStatus(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static ComplaintProcessStatus fromValue(int code) {
|
||||
for (ComplaintProcessStatus status : ComplaintProcessStatus.values()) {
|
||||
if (status.value == code) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
LOGGER.warn(ComplaintProcessStatus.class.getName() + " can not find value :" + code);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package com.docus.soap.api.request.complain;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "GetTableByIdDateDataRequest")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class GetTableByIdDateDataRequest {
|
||||
|
||||
@XmlElement(name = "store_id")
|
||||
private int storeId;
|
||||
@XmlElement(name = "startDate")
|
||||
private String startDate;
|
||||
@XmlElement(name = "endDate")
|
||||
private String endDate;
|
||||
@XmlElement(name = "complaintGrade")
|
||||
private Integer complaintGrade;
|
||||
@XmlElement(name = "currentpage")
|
||||
private int currentpage;
|
||||
@XmlElement(name = "pagesize")
|
||||
private int pagesize;
|
||||
|
||||
public int getStoreId() {
|
||||
return storeId;
|
||||
}
|
||||
|
||||
public void setStoreId(int storeId) {
|
||||
this.storeId = storeId;
|
||||
}
|
||||
|
||||
public String getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(String startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public String getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(String endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public Integer getComplaintGrade() {
|
||||
return complaintGrade;
|
||||
}
|
||||
|
||||
public void setComplaintGrade(Integer complaintGrade) {
|
||||
this.complaintGrade = complaintGrade;
|
||||
}
|
||||
|
||||
public int getCurrentpage() {
|
||||
return currentpage;
|
||||
}
|
||||
|
||||
public void setCurrentpage(int currentpage) {
|
||||
this.currentpage = currentpage;
|
||||
}
|
||||
|
||||
public int getPagesize() {
|
||||
return pagesize;
|
||||
}
|
||||
|
||||
public void setPagesize(int pagesize) {
|
||||
this.pagesize = pagesize;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.docus.soap.api.request.complain;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "SOF_GetQRCodeBySys", namespace = "http://webservice.qrcode.pki.jhsec.com.cn/")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class GetTableByIdDateRequest {
|
||||
|
||||
@XmlElement(name = "sys")
|
||||
private String sys;
|
||||
|
||||
public String getSys() {
|
||||
return sys;
|
||||
}
|
||||
|
||||
public void setSys(String sys) {
|
||||
this.sys = sys;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.docus.soap.api.response.complain;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class ComplaintListResult {
|
||||
|
||||
@XmlElement(name = "DataItem")
|
||||
private final List<DataItem> dataItem = new ArrayList<>();
|
||||
|
||||
@XmlElement(name = "totalpage")
|
||||
private int totalPage;
|
||||
|
||||
@XmlElement(name = "totalrecord")
|
||||
private int totalRecord;
|
||||
|
||||
public List<DataItem> getDataItem() {
|
||||
return dataItem;
|
||||
}
|
||||
|
||||
public int getTotalPage() {
|
||||
return totalPage;
|
||||
}
|
||||
|
||||
public void setTotalPage(int totalPage) {
|
||||
this.totalPage = totalPage;
|
||||
}
|
||||
|
||||
public int getTotalRecord() {
|
||||
return totalRecord;
|
||||
}
|
||||
|
||||
public void setTotalRecord(int totalRecord) {
|
||||
this.totalRecord = totalRecord;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.docus.soap.api.response.complain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class DataItem implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2657976429770220410L;
|
||||
@XmlElement(name = "qrCodeImg")
|
||||
private String qrCodeImg;
|
||||
|
||||
@XmlElement(name = "qrCode")
|
||||
private String qrCode;
|
||||
|
||||
@XmlElement(name = "resultCode")
|
||||
private String resultCode;
|
||||
|
||||
@XmlElement(name = "resultMsg")
|
||||
private String resultMsg;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.docus.soap.api.response.complain;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "SOF_GetQRCodeBySysResponse", namespace = "http://webservice.qrcode.pki.jhsec.com.cn/")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class GetComplaintListExResponse {
|
||||
|
||||
@XmlElement(name = "return")
|
||||
private String result;
|
||||
|
||||
public String getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(String result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.docus.soap.api.response.complain;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "GetComplaintListResponse")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class GetComplaintListResponse {
|
||||
|
||||
@XmlElement(name = "GetComplaintListResult")
|
||||
private String complaintListResult;
|
||||
|
||||
public String getComplaintListResult() {
|
||||
return complaintListResult;
|
||||
}
|
||||
|
||||
public void setComplaintListResult(String complaintListResult) {
|
||||
this.complaintListResult = complaintListResult;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.docus.soap.api.response.complain;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "GetTableByIdDateResponse")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class GetTableByIdDateResponse {
|
||||
|
||||
@XmlElement(name = "GetTableByIdDateResult")
|
||||
private String result;
|
||||
|
||||
public String getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(String result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.docus.soap.api.response.complain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class GetTableByIdDateResult {
|
||||
|
||||
@XmlElementWrapper
|
||||
@XmlElement(name = "data")
|
||||
private final List<DataItem> results = new ArrayList<>();
|
||||
|
||||
@XmlElement(name = "msg")
|
||||
private String msg;
|
||||
|
||||
@XmlElement(name = "code")
|
||||
private int code;
|
||||
|
||||
@XmlElement(name = "return")
|
||||
private String res;
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
@XmlSchema(namespace = "http://webservice.qrcode.pki.jhsec.com.cn/", elementFormDefault = XmlNsForm.QUALIFIED)
|
||||
package com.docus.soap.api.response.complain;
|
||||
|
||||
import javax.xml.bind.annotation.XmlNsForm;
|
||||
import javax.xml.bind.annotation.XmlSchema;
|
@ -0,0 +1,21 @@
|
||||
package com.docus.soap.api.service;
|
||||
|
||||
import com.docus.soap.api.SoapAPIClient;
|
||||
import com.docus.soap.api.SoapAPISettings;
|
||||
import com.docus.soap.api.request.complain.GetTableByIdDateRequest;
|
||||
import com.docus.soap.api.response.complain.GetComplaintListExResponse;
|
||||
import com.docus.soap.api.response.complain.GetTableByIdDateResult;
|
||||
|
||||
public class ComplaintAPIService {
|
||||
private SoapAPIClient soapAPIClient;
|
||||
|
||||
public GetTableByIdDateResult getTableByIdDate(GetTableByIdDateRequest targetRequest, SoapAPISettings soapAPISettings) {
|
||||
GetComplaintListExResponse o = (GetComplaintListExResponse) soapAPIClient.soapCall(targetRequest, soapAPISettings.getAction(), soapAPISettings.getUri());
|
||||
System.out.println("1");
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setWebServiceClient(SoapAPIClient webServiceClient) {
|
||||
this.soapAPIClient = webServiceClient;
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.docus.soap.api.service;
|
||||
|
||||
public class a {
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.docus.soap.api.util;
|
||||
|
||||
import com.docus.core.util.json.ObjectMapperBuilder;
|
||||
import com.fasterxml.jackson.databind.AnnotationIntrospector;
|
||||
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
|
||||
import com.fasterxml.jackson.databind.type.TypeFactory;
|
||||
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
|
||||
|
||||
public final class NullObjectMapperBuilder {
|
||||
|
||||
private final ObjectMapperBuilder builder;
|
||||
|
||||
private NullObjectMapperBuilder() {
|
||||
this.builder = ObjectMapperBuilder.defaultObjectMapper();
|
||||
AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
|
||||
AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
|
||||
this.builder.get().setAnnotationIntrospector(AnnotationIntrospector.pair(primary, secondary));
|
||||
this.builder.get().getSerializerProvider().setNullValueSerializer(NullSerializer.INSTANCE);
|
||||
}
|
||||
|
||||
private static final NullObjectMapperBuilder INSTANCE = new NullObjectMapperBuilder();
|
||||
|
||||
public static ObjectMapperBuilder get() {
|
||||
return INSTANCE.builder;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.docus.soap.api.util;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public final class NullSerializer extends StdSerializer<Object> {
|
||||
|
||||
public static final NullSerializer INSTANCE = new NullSerializer();
|
||||
|
||||
private NullSerializer() {
|
||||
super(Object.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
|
||||
jgen.writeString("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException {
|
||||
return createSchemaNode("null");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException {
|
||||
visitor.expectNullFormat(typeHint);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.docus.soap.api.util;
|
||||
|
||||
import com.docus.core.util.Convert;
|
||||
import com.docus.core.util.StringUtils;
|
||||
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
import java.util.Date;
|
||||
|
||||
public class StringDateTimeAdapter extends XmlAdapter<String, Date> {
|
||||
|
||||
private static final String SIMPLE_ISO_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
|
||||
private static final String DATE_FORMAT_ISO_WITHOUT_TIMEZONE = "yyyy-MM-dd'T'HH:mm:ss.SSS";
|
||||
|
||||
@Override
|
||||
public Date unmarshal(String v) throws Exception {
|
||||
if (!StringUtils.hasText(v)) {
|
||||
return null;
|
||||
}
|
||||
if (v.length() > SIMPLE_ISO_FORMAT.length()) {
|
||||
return Convert.toDate(v, DATE_FORMAT_ISO_WITHOUT_TIMEZONE, null);
|
||||
} else {
|
||||
return Convert.toDate(v, SIMPLE_ISO_FORMAT, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String marshal(Date v) throws Exception {
|
||||
if (v == null) {
|
||||
return null;
|
||||
}
|
||||
return Convert.toString(v, SIMPLE_ISO_FORMAT);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.docus.soap.api.util;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
public final class XmlUtils {
|
||||
|
||||
public static String pretty(Document xml) {
|
||||
return pretty(new DOMSource(xml));
|
||||
}
|
||||
|
||||
public static String pretty(Source source) {
|
||||
try {
|
||||
Transformer tf = TransformerFactory.newInstance().newTransformer();
|
||||
tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
|
||||
tf.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
Writer out = new StringWriter();
|
||||
tf.transform(source, new StreamResult(out));
|
||||
return out.toString();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
soap:
|
||||
complaint.api.url: http://101.132.67.155:8087/PKIQRCode/services/v1?wsdl
|
||||
complaint.api.action: SOF_GetQRCodeBySys
|
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration debug="false" scan="true" scanPeriod="1 seconds">
|
||||
<contextName>basicviewtaskcollect</contextName>
|
||||
<property name="log.path" value="logs/logback"/>
|
||||
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>[%d{yyyy-MM-dd' 'HH:mm:ss.sss}] [%contextName] [%thread] [%X{traceId}] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
|
||||
<encoder>
|
||||
<!-- 指定日志输出格式 -->
|
||||
<pattern>[%d{yyyy-MM-dd' 'HH:mm:ss.sss}] [%C] [%t] [%X{traceId}] [%L] [%-5p] %m%n</pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
<!-- 指定收集策略:滚动策略-->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!--指定生成日志保存地址 -->
|
||||
<fileNamePattern>${log.path}%d.%i.log</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy
|
||||
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>500MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<MaxHistory>30</MaxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<root level="debug">
|
||||
<appender-ref ref="console"/>
|
||||
<appender-ref ref="file"/>
|
||||
</root>
|
||||
|
||||
</configuration>
|
@ -0,0 +1,46 @@
|
||||
package com.docus.soap.api;
|
||||
|
||||
import com.docus.core.util.AssertUtils;
|
||||
import com.docus.soap.api.request.complain.GetTableByIdDateRequest;
|
||||
import com.docus.soap.api.response.complain.GetTableByIdDateResult;
|
||||
import com.docus.soap.api.service.ComplaintAPIService;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = DocusSoapApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
public class ComplaintAPIServiceTest {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(ComplaintAPIServiceTest.class);
|
||||
|
||||
@Value("${soap.complaint.api.url}")
|
||||
public String soapComplaintUrl;
|
||||
@Value("${soap.complaint.api.action}")
|
||||
public String soapComplaintAction;
|
||||
|
||||
@Inject
|
||||
private ComplaintAPIService complaintAPIService;
|
||||
|
||||
|
||||
@Test
|
||||
public void getTableByIdDateTest() {
|
||||
GetTableByIdDateRequest request = new GetTableByIdDateRequest();
|
||||
request.setSys("JSScan");
|
||||
GetTableByIdDateResult result = complaintAPIService.getTableByIdDate(request, getTableByIdDateSettings());
|
||||
AssertUtils.assertNotNull(result, "not null");
|
||||
}
|
||||
|
||||
private SoapAPISettings getTableByIdDateSettings() {
|
||||
SoapAPISettings soapAPISettings = new SoapAPISettings();
|
||||
soapAPISettings.setAction(soapComplaintAction);
|
||||
soapAPISettings.setUri(soapComplaintUrl);
|
||||
return soapAPISettings;
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
soap:
|
||||
complaint.api.url: http://101.132.67.155:8087/PKIQRCode/services/v1?wsdl
|
||||
complaint.api.action: SOF_GetQRCodeBySys
|
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration debug="false" scan="true" scanPeriod="1 seconds">
|
||||
<contextName>basicviewtaskcollect</contextName>
|
||||
<property name="log.path" value="logs/logback"/>
|
||||
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>[%d{yyyy-MM-dd' 'HH:mm:ss.sss}] [%contextName] [%thread] [%X{traceId}] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
|
||||
<encoder>
|
||||
<!-- 指定日志输出格式 -->
|
||||
<pattern>[%d{yyyy-MM-dd' 'HH:mm:ss.sss}] [%C] [%t] [%X{traceId}] [%L] [%-5p] %m%n</pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
<!-- 指定收集策略:滚动策略-->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!--指定生成日志保存地址 -->
|
||||
<fileNamePattern>${log.path}%d.%i.log</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy
|
||||
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>500MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<MaxHistory>30</MaxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<root level="debug">
|
||||
<appender-ref ref="console"/>
|
||||
<appender-ref ref="file"/>
|
||||
</root>
|
||||
|
||||
</configuration>
|
Loading…
Reference in New Issue