init 2
parent
a714b77e7d
commit
fb6c1ba46b
Binary file not shown.
47
pom.xml
47
pom.xml
|
@ -55,11 +55,48 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- JSON转换工具 -->
|
<!-- JSON转换工具 -->
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.alibaba</groupId>-->
|
||||||
|
<!-- <artifactId>fastjson</artifactId>-->
|
||||||
|
<!-- <version>2.0.53</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>jackson-core</artifactId>
|
||||||
<version>2.0.35</version>
|
<version>2.18.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>2.18.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
<version>2.18.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-annotations</artifactId>
|
||||||
|
<version>2.18.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 其他依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>2.8.8</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-poi</artifactId>
|
<artifactId>hutool-poi</artifactId>
|
||||||
|
@ -70,6 +107,10 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.jayway.jsonpath</groupId>
|
||||||
|
<artifactId>json-path</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package org.lsh.webservice.ui.config;
|
||||||
|
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
|
||||||
|
import javax.xml.datatype.DatatypeConfigurationException;
|
||||||
|
import javax.xml.datatype.DatatypeFactory;
|
||||||
|
import javax.xml.datatype.XMLGregorianCalendar;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
|
public class XMLGregorianCalendarTypeAdapter extends TypeAdapter<XMLGregorianCalendar> {
|
||||||
|
@Override
|
||||||
|
public void write(JsonWriter jsonWriter, XMLGregorianCalendar value) throws IOException {
|
||||||
|
// 将XMLGregorianCalendar转换为字符串写入JSON
|
||||||
|
jsonWriter.value(value.toXMLFormat());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public XMLGregorianCalendar read(JsonReader in) throws IOException {
|
||||||
|
// 从JSON读取字符串并转换为XMLGregorianCalendar
|
||||||
|
try {
|
||||||
|
String dateString = in.nextString();
|
||||||
|
GregorianCalendar calendar = new GregorianCalendar();
|
||||||
|
Date date = DateFormat.getDateInstance().parse(dateString);
|
||||||
|
calendar.setTime(date);
|
||||||
|
return DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);
|
||||||
|
} catch (ParseException | DatatypeConfigurationException e) {
|
||||||
|
throw new IOException("Failed to parse XMLGregorianCalendar", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,8 @@
|
||||||
package org.lsh.webservice.ui.controller;
|
package org.lsh.webservice.ui.controller;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.lsh.webservice.ui.common.Result;
|
import org.lsh.webservice.ui.common.Result;
|
||||||
import org.lsh.webservice.ui.entity.FormField;
|
import org.lsh.webservice.ui.entity.FormField;
|
||||||
import org.lsh.webservice.ui.entity.FormItemV2;
|
import org.lsh.webservice.ui.entity.FormItemV2;
|
||||||
|
@ -10,6 +11,7 @@ import org.lsh.webservice.ui.entity.dto.ServerInfo;
|
||||||
import org.lsh.webservice.ui.entity.tree.Operation;
|
import org.lsh.webservice.ui.entity.tree.Operation;
|
||||||
import org.lsh.webservice.ui.entity.tree.Project;
|
import org.lsh.webservice.ui.entity.tree.Project;
|
||||||
import org.lsh.webservice.ui.entity.tree.Webservice;
|
import org.lsh.webservice.ui.entity.tree.Webservice;
|
||||||
|
import org.lsh.webservice.ui.entity.vo.DynamicWebVO;
|
||||||
import org.lsh.webservice.ui.entity.vo.OperationQueryVO;
|
import org.lsh.webservice.ui.entity.vo.OperationQueryVO;
|
||||||
import org.lsh.webservice.ui.entity.vo.Wsdl;
|
import org.lsh.webservice.ui.entity.vo.Wsdl;
|
||||||
import org.lsh.webservice.ui.mapper.OperationMapper;
|
import org.lsh.webservice.ui.mapper.OperationMapper;
|
||||||
|
@ -34,6 +36,8 @@ public class MainController {
|
||||||
OperationMapper operationMapper;
|
OperationMapper operationMapper;
|
||||||
@Resource
|
@Resource
|
||||||
ServerInfoMapper serverInfoMapper;
|
ServerInfoMapper serverInfoMapper;
|
||||||
|
@Resource
|
||||||
|
ObjectMapper objectMapper;
|
||||||
|
|
||||||
@PostMapping("/add-webservice")
|
@PostMapping("/add-webservice")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@ -63,8 +67,12 @@ public class MainController {
|
||||||
Operation operation = new Operation();
|
Operation operation = new Operation();
|
||||||
operation.setWebserviceId(webservice.getId());
|
operation.setWebserviceId(webservice.getId());
|
||||||
operation.setName(formItemV2.getOperation());
|
operation.setName(formItemV2.getOperation());
|
||||||
operation.setInput(JSON.toJSONString(formItemV2.getInput()));
|
try {
|
||||||
operation.setOutput(JSON.toJSONString(formItemV2.getOutput()));
|
operation.setInput(objectMapper.writeValueAsString(formItemV2.getInput()));
|
||||||
|
operation.setOutput(objectMapper.writeValueAsString(formItemV2.getOutput()));
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
return Result.failed(e.getMessage());
|
||||||
|
}
|
||||||
operationMapper.insert(operation);
|
operationMapper.insert(operation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +89,12 @@ public class MainController {
|
||||||
ServerInfo serverInfo = serverInfoMapper.findByWebserviceId(webservice.getId());
|
ServerInfo serverInfo = serverInfoMapper.findByWebserviceId(webservice.getId());
|
||||||
if(serverInfo != null){
|
if(serverInfo != null){
|
||||||
String formJson = serverInfo.getFormJson();
|
String formJson = serverInfo.getFormJson();
|
||||||
FormV2 formV2 = JSON.parseObject(formJson, FormV2.class);
|
FormV2 formV2 = null;
|
||||||
|
try {
|
||||||
|
formV2 = objectMapper.readValue(formJson, FormV2.class);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
return Result.failed(e.getMessage());
|
||||||
|
}
|
||||||
return Result.ok(formV2);
|
return Result.ok(formV2);
|
||||||
}
|
}
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
|
@ -90,20 +103,23 @@ public class MainController {
|
||||||
@PostMapping("/query-projects")
|
@PostMapping("/query-projects")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result<List<Project>> queryProjects(
|
public Result<List<Project>> queryProjects(
|
||||||
|
@RequestParam(value = "loadWebservice",defaultValue = "true")String loadWebservice,
|
||||||
|
@RequestParam(value = "loadOperation",defaultValue = "true")String loadOperation
|
||||||
){
|
){
|
||||||
//
|
//
|
||||||
List<Project> projects = projectMapper.findAll();
|
List<Project> projects = projectMapper.findAll();
|
||||||
|
if(loadWebservice.equals("true")) {
|
||||||
for (Project project : projects) {
|
for (Project project : projects) {
|
||||||
List<Webservice> webserviceList = webserviceMapper.findByProjectId(project.getId());
|
List<Webservice> webserviceList = webserviceMapper.findByProjectId(project.getId());
|
||||||
project.setChildren(webserviceList);
|
project.setChildren(webserviceList);
|
||||||
if(CollectionUtil.isNotEmpty(webserviceList)){
|
if (CollectionUtil.isNotEmpty(webserviceList) && loadOperation.equals("true")) {
|
||||||
for (Webservice webservice : webserviceList) {
|
for (Webservice webservice : webserviceList) {
|
||||||
List<Operation> operationList = operationMapper.findByWebserviceId(webservice.getId());
|
List<Operation> operationList = operationMapper.findByWebserviceId(webservice.getId());
|
||||||
webservice.setChildren(operationList);
|
webservice.setChildren(operationList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return Result.ok(projects);
|
return Result.ok(projects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,8 +136,12 @@ public class MainController {
|
||||||
Webservice webservice = webserviceMapper.findById(operation.getWebserviceId());
|
Webservice webservice = webserviceMapper.findById(operation.getWebserviceId());
|
||||||
operationQueryVO.setOperation(operation.getName());
|
operationQueryVO.setOperation(operation.getName());
|
||||||
operationQueryVO.setId(operation.getId());
|
operationQueryVO.setId(operation.getId());
|
||||||
operationQueryVO.setInput(JSON.parseObject(operation.getInput(), FormField.class));
|
try {
|
||||||
operationQueryVO.setOutput(JSON.parseObject(operation.getOutput(), FormField.class));
|
operationQueryVO.setInput(objectMapper.readValue(operation.getInput(), FormField.class));
|
||||||
|
operationQueryVO.setOutput(objectMapper.readValue(operation.getOutput(), FormField.class));
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
return Result.failed(e.getMessage());
|
||||||
|
}
|
||||||
if(webservice != null){
|
if(webservice != null){
|
||||||
operationQueryVO.setWsdl(webservice.getWsdl());
|
operationQueryVO.setWsdl(webservice.getWsdl());
|
||||||
operationQueryVO.setWebserviceName(webservice.getName());
|
operationQueryVO.setWebserviceName(webservice.getName());
|
||||||
|
@ -130,6 +150,24 @@ public class MainController {
|
||||||
return Result.ok(operationQueryVO);
|
return Result.ok(operationQueryVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/invoke")
|
||||||
|
@ResponseBody
|
||||||
|
public Result<FormField> invoke(
|
||||||
|
@RequestBody DynamicWebVO webservice
|
||||||
|
){
|
||||||
|
try {
|
||||||
|
FormField formField = ExplainWebservice.dynamicInvoke(webservice.getWsdl()
|
||||||
|
, webservice.getMethod()
|
||||||
|
, webservice.getInput()
|
||||||
|
, webservice.getOutput()
|
||||||
|
, webservice.getJson());
|
||||||
|
return Result.ok(formField);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return Result.failed("调用发生了异常~"+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping("/index")
|
@RequestMapping("/index")
|
||||||
public String hello(){
|
public String hello(){
|
||||||
return "index"; // index.html页面
|
return "index"; // index.html页面
|
||||||
|
|
|
@ -7,7 +7,10 @@ public class FormField implements Serializable {
|
||||||
|
|
||||||
protected String fieldName;
|
protected String fieldName;
|
||||||
protected String typeName;
|
protected String typeName;
|
||||||
|
protected String genericType;
|
||||||
protected boolean require;
|
protected boolean require;
|
||||||
|
protected Object value;
|
||||||
|
|
||||||
private List<FormField> fields;
|
private List<FormField> fields;
|
||||||
|
|
||||||
public String getFieldName() {
|
public String getFieldName() {
|
||||||
|
@ -41,4 +44,20 @@ public class FormField implements Serializable {
|
||||||
public void setFields(List<FormField> fields) {
|
public void setFields(List<FormField> fields) {
|
||||||
this.fields = fields;
|
this.fields = fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(Object value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGenericType() {
|
||||||
|
return genericType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGenericType(String genericType) {
|
||||||
|
this.genericType = genericType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package org.lsh.webservice.ui.entity;
|
||||||
|
|
||||||
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
public class MyParameterizedType implements ParameterizedType {
|
||||||
|
private Type[] args;
|
||||||
|
|
||||||
|
private Class rawType;
|
||||||
|
|
||||||
|
public MyParameterizedType( Class rawType,Type[] args) {
|
||||||
|
this.args = args;
|
||||||
|
this.rawType = rawType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type[] getActualTypeArguments() {
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getRawType() {
|
||||||
|
return rawType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getOwnerType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,9 @@ public class ServerInfo {
|
||||||
private int webserviceId;
|
private int webserviceId;
|
||||||
private String formJson;
|
private String formJson;
|
||||||
|
|
||||||
|
public ServerInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
public ServerInfo(int webserviceId, String formJson) {
|
public ServerInfo(int webserviceId, String formJson) {
|
||||||
this.webserviceId = webserviceId;
|
this.webserviceId = webserviceId;
|
||||||
this.formJson = formJson;
|
this.formJson = formJson;
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package org.lsh.webservice.ui.entity.vo;
|
||||||
|
|
||||||
|
import org.lsh.webservice.ui.entity.FormField;
|
||||||
|
|
||||||
|
public class DynamicWebVO {
|
||||||
|
|
||||||
|
private String wsdl;
|
||||||
|
private String method;
|
||||||
|
private FormField input;
|
||||||
|
private FormField output;
|
||||||
|
private String json;
|
||||||
|
|
||||||
|
public String getWsdl() {
|
||||||
|
return wsdl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWsdl(String wsdl) {
|
||||||
|
this.wsdl = wsdl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMethod() {
|
||||||
|
return method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMethod(String method) {
|
||||||
|
this.method = method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormField getInput() {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInput(FormField input) {
|
||||||
|
this.input = input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormField getOutput() {
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOutput(FormField output) {
|
||||||
|
this.output = output;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJson() {
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJson(String json) {
|
||||||
|
this.json = json;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package org.lsh.webservice.ui.utils;
|
package org.lsh.webservice.ui.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import org.lsh.webservice.ui.entity.FormField;
|
import org.lsh.webservice.ui.entity.FormField;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
|
@ -13,7 +14,16 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ExplainField {
|
public class ExplainField {
|
||||||
public static void explain(Field declaredField, List<FormField> formFieldList) throws ClassNotFoundException {
|
|
||||||
|
public static void explain(Object o,Field declaredField, List<FormField> formFieldList) throws ClassNotFoundException, IllegalAccessException {
|
||||||
|
// 集合
|
||||||
|
FormField complexType = new FormField();
|
||||||
|
Object currentValue = null;
|
||||||
|
if(o != null){
|
||||||
|
declaredField.setAccessible(true);
|
||||||
|
currentValue = declaredField.get(o);
|
||||||
|
complexType.setValue(currentValue);
|
||||||
|
}
|
||||||
// 判断Field类型
|
// 判断Field类型
|
||||||
if(declaredField.getType() == List.class || declaredField.getType() == Array.class){
|
if(declaredField.getType() == List.class || declaredField.getType() == Array.class){
|
||||||
// 获取List的泛型类型
|
// 获取List的泛型类型
|
||||||
|
@ -22,9 +32,9 @@ public class ExplainField {
|
||||||
ParameterizedType parameterizedType = (ParameterizedType)genericType;
|
ParameterizedType parameterizedType = (ParameterizedType)genericType;
|
||||||
Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
|
Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
|
||||||
if(actualTypeArguments.length>0){
|
if(actualTypeArguments.length>0){
|
||||||
FormField complexType = new FormField();
|
|
||||||
complexType.setFieldName(declaredField.getName());
|
complexType.setFieldName(declaredField.getName());
|
||||||
complexType.setTypeName(declaredField.getType().getTypeName());
|
complexType.setTypeName(declaredField.getType().getTypeName());
|
||||||
|
|
||||||
List<FormField> formFields = new ArrayList<>();
|
List<FormField> formFields = new ArrayList<>();
|
||||||
complexType.setFields(formFields);
|
complexType.setFields(formFields);
|
||||||
// 获取List的泛型类型
|
// 获取List的泛型类型
|
||||||
|
@ -32,9 +42,53 @@ public class ExplainField {
|
||||||
Class classes = (Class) actualTypeArgument;
|
Class classes = (Class) actualTypeArgument;
|
||||||
// 泛型类加载器
|
// 泛型类加载器
|
||||||
if(classes != null) {
|
if(classes != null) {
|
||||||
|
complexType.setGenericType(classes.getTypeName());
|
||||||
|
if(currentValue != null){
|
||||||
|
List<?> list = (List)currentValue;
|
||||||
|
if(CollectionUtil.isEmpty(list)){
|
||||||
|
currentValue = null;
|
||||||
|
// 集合第一个对象
|
||||||
|
FormField firstObj = new FormField();
|
||||||
|
firstObj.setFieldName("0");
|
||||||
|
firstObj.setTypeName(classes.getTypeName());
|
||||||
|
formFields.add(firstObj);
|
||||||
|
|
||||||
|
List<FormField> firstObjFields = new ArrayList<>();
|
||||||
|
firstObj.setFields(firstObjFields);
|
||||||
Field[] declaredFields2 = classes.getDeclaredFields();
|
Field[] declaredFields2 = classes.getDeclaredFields();
|
||||||
for (Field declaredField2 : declaredFields2) {
|
for (Field declaredField2 : declaredFields2) {
|
||||||
explain(declaredField2, formFields);
|
explain(currentValue,declaredField2, firstObjFields);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
Object o1 = list.get(i);
|
||||||
|
// 集合第一个对象
|
||||||
|
FormField firstObj = new FormField();
|
||||||
|
firstObj.setFieldName(i+"");
|
||||||
|
firstObj.setTypeName(classes.getTypeName());
|
||||||
|
formFields.add(firstObj);
|
||||||
|
|
||||||
|
List<FormField> firstObjFields = new ArrayList<>();
|
||||||
|
firstObj.setFields(firstObjFields);
|
||||||
|
Field[] declaredFields2 = classes.getDeclaredFields();
|
||||||
|
for (Field declaredField2 : declaredFields2) {
|
||||||
|
explain(o1,declaredField2, firstObjFields);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
// 集合第一个对象
|
||||||
|
FormField firstObj = new FormField();
|
||||||
|
firstObj.setFieldName("0");
|
||||||
|
firstObj.setTypeName(classes.getTypeName());
|
||||||
|
formFields.add(firstObj);
|
||||||
|
|
||||||
|
List<FormField> firstObjFields = new ArrayList<>();
|
||||||
|
firstObj.setFields(firstObjFields);
|
||||||
|
Field[] declaredFields2 = classes.getDeclaredFields();
|
||||||
|
for (Field declaredField2 : declaredFields2) {
|
||||||
|
explain(currentValue,declaredField2, firstObjFields);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
formFieldList.add(complexType);
|
formFieldList.add(complexType);
|
||||||
|
@ -52,26 +106,37 @@ public class ExplainField {
|
||||||
|| declaredField.getType() == LocalDate.class
|
|| declaredField.getType() == LocalDate.class
|
||||||
|| declaredField.getType().getTypeName().equals("int")
|
|| declaredField.getType().getTypeName().equals("int")
|
||||||
|| declaredField.getType().getTypeName().equals("long")){
|
|| declaredField.getType().getTypeName().equals("long")){
|
||||||
FormField basic = new FormField();
|
|
||||||
basic.setFieldName(declaredField.getName());
|
complexType.setFieldName(declaredField.getName());
|
||||||
basic.setTypeName(declaredField.getType().getTypeName());
|
complexType.setTypeName(declaredField.getType().getTypeName());
|
||||||
formFieldList.add(basic);
|
formFieldList.add(complexType);
|
||||||
System.out.println(declaredField);
|
|
||||||
}else {
|
}else {
|
||||||
// 自定义的数据类型
|
// 自定义的数据类型
|
||||||
System.out.println("进入自定义数据类型:" + declaredField.getName() + "====" + declaredField.getType());
|
System.out.println("进入自定义数据类型:" + declaredField.getName() + "====" + declaredField.getType());
|
||||||
// 获取该字段的参数类型
|
// 获取该字段的参数类型
|
||||||
Class class2 = (Class)declaredField.getGenericType();
|
Class class2 = (Class)declaredField.getGenericType();
|
||||||
Field[] declaredFields = class2.getDeclaredFields();
|
Field[] declaredFields = class2.getDeclaredFields();
|
||||||
FormField complexType = new FormField();
|
|
||||||
complexType.setFieldName(declaredField.getName());
|
complexType.setFieldName(declaredField.getName());
|
||||||
complexType.setTypeName(declaredField.getType().getTypeName());
|
complexType.setTypeName(declaredField.getType().getTypeName());
|
||||||
List<FormField> formFields = new ArrayList<>();
|
List<FormField> formFields = new ArrayList<>();
|
||||||
complexType.setFields(formFields);
|
complexType.setFields(formFields);
|
||||||
for (Field field : declaredFields) {
|
for (Field field : declaredFields) {
|
||||||
explain(field, formFields);
|
explain(currentValue,field, formFields);
|
||||||
}
|
}
|
||||||
formFieldList.add(complexType);
|
formFieldList.add(complexType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isList(String typeName){
|
||||||
|
return "java.util.List".equals(typeName) || "java.lang.Arrays".equals(typeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String switchToObject(String typeName1,String typeName2){
|
||||||
|
if(isList(typeName1)){
|
||||||
|
return typeName2;
|
||||||
|
}
|
||||||
|
return typeName1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,26 @@
|
||||||
package org.lsh.webservice.ui.utils;
|
package org.lsh.webservice.ui.utils;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.JavaType;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
import org.apache.cxf.endpoint.Client;
|
import org.apache.cxf.endpoint.Client;
|
||||||
import org.apache.cxf.endpoint.Endpoint;
|
import org.apache.cxf.endpoint.Endpoint;
|
||||||
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
|
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
|
||||||
import org.apache.cxf.service.model.*;
|
import org.apache.cxf.service.model.*;
|
||||||
|
import org.lsh.webservice.ui.config.XMLGregorianCalendarTypeAdapter;
|
||||||
import org.lsh.webservice.ui.entity.FormItemV2;
|
import org.lsh.webservice.ui.entity.FormItemV2;
|
||||||
import org.lsh.webservice.ui.entity.FormV2;
|
import org.lsh.webservice.ui.entity.FormV2;
|
||||||
import org.lsh.webservice.ui.entity.FormField;
|
import org.lsh.webservice.ui.entity.FormField;
|
||||||
|
import org.lsh.webservice.ui.entity.MyParameterizedType;
|
||||||
|
|
||||||
|
import javax.xml.datatype.XMLGregorianCalendar;
|
||||||
import javax.xml.namespace.QName;
|
import javax.xml.namespace.QName;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class ExplainWebservice {
|
public class ExplainWebservice {
|
||||||
|
@ -32,13 +41,6 @@ public class ExplainWebservice {
|
||||||
formV2.setServerName(serviceInfo.getName().getLocalPart());
|
formV2.setServerName(serviceInfo.getName().getLocalPart());
|
||||||
/**创建Service*/
|
/**创建Service*/
|
||||||
Collection<BindingInfo> bindings = serviceInfo.getBindings();
|
Collection<BindingInfo> bindings = serviceInfo.getBindings();
|
||||||
Map<QName, Object> extensionAttributes = serviceInfo.getExtensionAttributes();
|
|
||||||
if(extensionAttributes != null) {
|
|
||||||
extensionAttributes.forEach((key, val) -> {
|
|
||||||
System.out.println("key:" + key + " values:" + val);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// portType
|
// portType
|
||||||
// 对于某个访问入口点类型所支持的操作的抽象集合; ----》服务端SEI
|
// 对于某个访问入口点类型所支持的操作的抽象集合; ----》服务端SEI
|
||||||
// 指出了这个WebService所有支持的操作,就是说有哪些方法可供调用。
|
// 指出了这个WebService所有支持的操作,就是说有哪些方法可供调用。
|
||||||
|
@ -71,11 +73,11 @@ public class ExplainWebservice {
|
||||||
System.out.println("====>"+aClass);
|
System.out.println("====>"+aClass);
|
||||||
for (Field declaredField : declaredFields) {
|
for (Field declaredField : declaredFields) {
|
||||||
System.out.println("declaredField:" + declaredField);
|
System.out.println("declaredField:" + declaredField);
|
||||||
org.lsh.webservice.ui.utils.ExplainField.explain(declaredField, formFields);
|
org.lsh.webservice.ui.utils.ExplainField.explain(null,declaredField, formFields);
|
||||||
}
|
}
|
||||||
System.out.println("解析表单结果:" + JSON.toJSONString(complex));
|
//System.out.println("解析表单结果:" + JSON.toJSONString(complex));
|
||||||
messageMap.put(aClass.getSimpleName(),complex);
|
messageMap.put(aClass.getSimpleName(),complex);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException | IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,25 +94,140 @@ public class ExplainWebservice {
|
||||||
String inputTypeName = "";
|
String inputTypeName = "";
|
||||||
String outputTypeName = "";
|
String outputTypeName = "";
|
||||||
|
|
||||||
|
FormItemV2 itemV2 = new FormItemV2();
|
||||||
|
itemV2.setOperation(function);
|
||||||
|
|
||||||
OperationInfo operationInfo = operation.getOperationInfo();
|
OperationInfo operationInfo = operation.getOperationInfo();
|
||||||
List<MessagePartInfo> inputMessageParts = operationInfo.getInput().getMessageParts();
|
if(operation.isUnwrapped()){
|
||||||
|
operationInfo = operation.getUnwrappedOperation().getOperationInfo();
|
||||||
|
}
|
||||||
|
BindingMessageInfo messageInfo = null;
|
||||||
|
if(operation.isUnwrapped()){
|
||||||
|
messageInfo = operation.getUnwrappedOperation().getInput();
|
||||||
|
}else{
|
||||||
|
messageInfo = operation.getWrappedOperation().getInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MessagePartInfo> messageParts = messageInfo.getMessageInfo().getMessageParts();
|
||||||
|
StringBuilder params = new StringBuilder();
|
||||||
|
for (MessagePartInfo messagePart : messageParts) {
|
||||||
|
String typeName = messagePart.getTypeClass().getTypeName();
|
||||||
|
String param = messagePart.getName().getLocalPart();
|
||||||
|
if(params.length()>0){
|
||||||
|
params.append(",");
|
||||||
|
}
|
||||||
|
params.append(typeName+" "+param);
|
||||||
|
}
|
||||||
|
System.out.println("function==================>:" + function + "(" + params.toString()+")");
|
||||||
|
|
||||||
|
List<MessagePartInfo> inputMessageParts = messageInfo.getMessageParts();
|
||||||
for (MessagePartInfo inputMessagePart : inputMessageParts) {
|
for (MessagePartInfo inputMessagePart : inputMessageParts) {
|
||||||
inputTypeName = inputMessagePart.getTypeClass().getSimpleName();
|
inputTypeName = inputMessagePart.getTypeClass().getSimpleName();
|
||||||
|
String name = inputMessagePart.getName().getLocalPart();
|
||||||
|
// 如果是参数命名,那么再往下,获取实际传参
|
||||||
|
FormField input = messageMap.get(inputTypeName);
|
||||||
|
// if("parameters".equals(name) && input.getFields().size()>0){
|
||||||
|
// input = input.getFields().get(0);
|
||||||
|
// }
|
||||||
|
itemV2.setInput(input);
|
||||||
}
|
}
|
||||||
List<MessagePartInfo> outputMessageParts = operationInfo.getOutput().getMessageParts();
|
List<MessagePartInfo> outputMessageParts = operationInfo.getOutput().getMessageParts();
|
||||||
for (MessagePartInfo outputMessagePart : outputMessageParts) {
|
for (MessagePartInfo outputMessagePart : outputMessageParts) {
|
||||||
outputTypeName = outputMessagePart.getTypeClass().getSimpleName();
|
outputTypeName = outputMessagePart.getTypeClass().getSimpleName();
|
||||||
|
String name = outputMessagePart.getName().getLocalPart();
|
||||||
|
// 如果是参数命名,那么再往下,获取实际传参
|
||||||
|
FormField output = messageMap.get(outputTypeName);
|
||||||
|
// if("parameters".equals(name) && output.getFields().size()>0){
|
||||||
|
// output = output.getFields().get(0);
|
||||||
|
// }
|
||||||
|
itemV2.setOutput(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FormItemV2 itemV2 = new FormItemV2();
|
|
||||||
itemV2.setOperation(function);
|
|
||||||
itemV2.setInput(messageMap.get(inputTypeName));
|
|
||||||
itemV2.setOutput(messageMap.get(outputTypeName));
|
|
||||||
itemV2s.add(itemV2);
|
itemV2s.add(itemV2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return formV2;
|
return formV2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static FormField dynamicInvoke(String wsdl
|
||||||
|
,String method
|
||||||
|
,FormField input
|
||||||
|
,FormField output
|
||||||
|
,String json) throws Exception {
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
// 创建动态客户端
|
||||||
|
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
|
||||||
|
Client client = factory.createClient(wsdl);
|
||||||
|
String inputClassName = ExplainField.switchToObject(input.getTypeName(),input.getGenericType());
|
||||||
|
Class<?> inputClass = Thread.currentThread().getContextClassLoader().loadClass(inputClassName);
|
||||||
|
// 如果输入值是集合,那么需要将集合转化为对应类型
|
||||||
|
JavaType inputJavaType = objectMapper.getTypeFactory().constructCollectionType(List.class, inputClass);
|
||||||
|
MyParameterizedType type = new MyParameterizedType(List.class, new Type[]{inputClass});
|
||||||
|
|
||||||
|
String outputClassName = ExplainField.switchToObject(output.getTypeName(),output.getGenericType());
|
||||||
|
Class<?> outputClass = Thread.currentThread().getContextClassLoader().loadClass(outputClassName);
|
||||||
|
JavaType outputJavaType = objectMapper.getTypeFactory().constructCollectionType(List.class, outputClass);
|
||||||
|
|
||||||
|
|
||||||
|
Object request = null;
|
||||||
|
if(ExplainField.isList(input.getTypeName())){
|
||||||
|
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||||
|
//objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
|
||||||
|
objectMapper.configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES,false);
|
||||||
|
// request = objectMapper.readValue(json, inputJavaType);
|
||||||
|
Gson gson = new GsonBuilder()
|
||||||
|
.registerTypeAdapter(XMLGregorianCalendar.class, new XMLGregorianCalendarTypeAdapter())
|
||||||
|
.create();
|
||||||
|
request = gson.fromJson(json, type);
|
||||||
|
}else{
|
||||||
|
request = objectMapper.readValue(json, inputClass);
|
||||||
|
}
|
||||||
|
Object[] invoke = client.invoke(method,request);
|
||||||
|
FormField complex = new FormField();
|
||||||
|
|
||||||
|
if(invoke != null && invoke.length>0){
|
||||||
|
String responseJson = objectMapper.writeValueAsString(invoke[0]);
|
||||||
|
System.out.println("=====response======>"+responseJson);
|
||||||
|
Object response = null;
|
||||||
|
if(ExplainField.isList(output.getTypeName())){
|
||||||
|
response = objectMapper.readValue(responseJson, outputJavaType);
|
||||||
|
System.out.println("=====response======>"+response);
|
||||||
|
List<FormField> formFields = new ArrayList<>();
|
||||||
|
complex.setFieldName(output.getFieldName());
|
||||||
|
complex.setFields(formFields);
|
||||||
|
complex.setTypeName(output.getTypeName());
|
||||||
|
complex.setGenericType(output.getGenericType());
|
||||||
|
|
||||||
|
// 如果本身就是集合,那么字段名称就是下标
|
||||||
|
List list = (List) response;
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
Object o1 = list.get(i);
|
||||||
|
List<FormField> indexFormFields = new ArrayList<>();
|
||||||
|
FormField indexForm = new FormField();
|
||||||
|
indexForm.setTypeName(o1.getClass().getTypeName());
|
||||||
|
indexForm.setFields(indexFormFields);
|
||||||
|
indexForm.setFieldName(i+"");
|
||||||
|
Field[] declaredFields = o1.getClass().getDeclaredFields();
|
||||||
|
for (Field declaredField : declaredFields) {
|
||||||
|
org.lsh.webservice.ui.utils.ExplainField.explain(o1,declaredField, indexFormFields);
|
||||||
|
}
|
||||||
|
formFields.add(indexForm);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
response = objectMapper.readValue(responseJson, outputClass);
|
||||||
|
System.out.println("=====response======>"+response);
|
||||||
|
List<FormField> formFields = new ArrayList<>();
|
||||||
|
complex.setFields(formFields);
|
||||||
|
complex.setTypeName(outputClassName);
|
||||||
|
complex.setFieldName(output.getFieldName());
|
||||||
|
Field[] declaredFields = outputClass.getDeclaredFields();
|
||||||
|
for (Field declaredField : declaredFields) {
|
||||||
|
org.lsh.webservice.ui.utils.ExplainField.explain(response,declaredField, formFields);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return complex;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@ spring:
|
||||||
username: sa
|
username: sa
|
||||||
password: password
|
password: password
|
||||||
platform: h2
|
platform: h2
|
||||||
|
hikari:
|
||||||
|
pool-name: h2-
|
||||||
h2:
|
h2:
|
||||||
console:
|
console:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
|
@ -4,8 +4,7 @@ Vue.component('add-wsdl', {
|
||||||
<el-form ref="form" :model="form" label-width="80px">
|
<el-form ref="form" :model="form" label-width="80px">
|
||||||
<el-form-item label="项目">
|
<el-form-item label="项目">
|
||||||
<el-select v-model="form.projectId" placeholder="请选择活动区域">
|
<el-select v-model="form.projectId" placeholder="请选择活动区域">
|
||||||
<el-option label="IMES-嘉兴-正式155" value="1"></el-option>
|
<el-option v-for="project in projectList" :key="project.id" :label="project.name" :value="project.id"></el-option>
|
||||||
<el-option label="IMES-嘉兴-测试116" value="2"></el-option>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="WSDL">
|
<el-form-item label="WSDL">
|
||||||
|
@ -21,9 +20,10 @@ Vue.component('add-wsdl', {
|
||||||
props: ['isshow'], // html接收字段名都是小写,单向传递
|
props: ['isshow'], // html接收字段名都是小写,单向传递
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
projectList: [],
|
||||||
form: {
|
form: {
|
||||||
wsdl: '',
|
wsdl: '',
|
||||||
projectId: '1'
|
projectId: 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -37,7 +37,32 @@ Vue.component('add-wsdl', {
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
},
|
},
|
||||||
|
created(){
|
||||||
|
this.queryProjects();
|
||||||
|
},
|
||||||
methods: { // 组件内方法
|
methods: { // 组件内方法
|
||||||
|
queryProjects(){
|
||||||
|
var _this = this;
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: '/query-projects?loadWebservice=false&loadOperation=false',
|
||||||
|
contentType:'application/json',
|
||||||
|
timeout: 5000,
|
||||||
|
data: JSON.stringify({}),
|
||||||
|
dataType: "JSON",
|
||||||
|
success: function ({code,data}, textStatus, jqXHR) {
|
||||||
|
if(data && code === 0){
|
||||||
|
_this.projectList = data;
|
||||||
|
if(_this.projectList && _this.projectList.length>0){
|
||||||
|
_this.form.projectId = _this.projectList[0].id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (xhrJson,status,error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
onSubmit(){
|
onSubmit(){
|
||||||
var _this = this;
|
var _this = this;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -54,6 +79,7 @@ Vue.component('add-wsdl', {
|
||||||
console.log(data)
|
console.log(data)
|
||||||
if(code === 0){
|
if(code === 0){
|
||||||
_this.$message.success(msg);
|
_this.$message.success(msg);
|
||||||
|
_this.$emit('reload-projects');
|
||||||
}else{
|
}else{
|
||||||
_this.$message.error(msg);
|
_this.$message.error(msg);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -103,6 +103,7 @@
|
||||||
<el-tree :data="projectList"
|
<el-tree :data="projectList"
|
||||||
node-key="id"
|
node-key="id"
|
||||||
:props="defaultProps"
|
:props="defaultProps"
|
||||||
|
v-loading="projectsLoading"
|
||||||
@node-click="handleNodeClick"></el-tree>
|
@node-click="handleNodeClick"></el-tree>
|
||||||
<!-- <template v-slot="{node}">-->
|
<!-- <template v-slot="{node}">-->
|
||||||
<!-- <span :title="node.name" class="node-label">{{node.name}}</span>-->
|
<!-- <span :title="node.name" class="node-label">{{node.name}}</span>-->
|
||||||
|
@ -120,7 +121,7 @@
|
||||||
:name="item.name"
|
:name="item.name"
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
<component :is="item.content" :operation="item.data"></component>
|
<component :is="item.content" :operation="item.data" @reload-projects="queryProjects"></component>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
</el-main>
|
</el-main>
|
||||||
|
@ -142,6 +143,7 @@
|
||||||
el: '#app',
|
el: '#app',
|
||||||
data: {
|
data: {
|
||||||
loading: false,
|
loading: false,
|
||||||
|
projectsLoading: false,
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
children: 'children',
|
children: 'children',
|
||||||
label: 'name'
|
label: 'name'
|
||||||
|
@ -179,6 +181,8 @@
|
||||||
},
|
},
|
||||||
queryProjects(){
|
queryProjects(){
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
_this.projectsLoading = true;
|
||||||
|
_this.projectList = []
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: '/query-projects',
|
url: '/query-projects',
|
||||||
|
@ -187,13 +191,13 @@
|
||||||
data: JSON.stringify({}),
|
data: JSON.stringify({}),
|
||||||
dataType: "JSON",
|
dataType: "JSON",
|
||||||
success: function ({code,data}, textStatus, jqXHR) {
|
success: function ({code,data}, textStatus, jqXHR) {
|
||||||
console.log(data)
|
|
||||||
if(data && code === 0){
|
if(data && code === 0){
|
||||||
_this.projectList = data;
|
_this.projectList = data;
|
||||||
}
|
}
|
||||||
|
_this.projectsLoading = false;
|
||||||
},
|
},
|
||||||
error: function (xhrJson,status,error) {
|
error: function (xhrJson,status,error) {
|
||||||
|
_this.projectsLoading = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.lsh;
|
||||||
|
|
||||||
|
import javax.xml.datatype.XMLGregorianCalendar;
|
||||||
|
|
||||||
|
public class TestCalendar {
|
||||||
|
private XMLGregorianCalendar calendar;
|
||||||
|
|
||||||
|
public XMLGregorianCalendar getCalendar() {
|
||||||
|
return calendar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCalendar(XMLGregorianCalendar calendar) {
|
||||||
|
this.calendar = calendar;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.lsh;
|
||||||
|
|
||||||
|
import org.lsh.webservice.ui.entity.dto.ServerInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TestDTO {
|
||||||
|
private String name;
|
||||||
|
private String value;
|
||||||
|
private String qOrE;
|
||||||
|
private List<ServerInfo> children;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ServerInfo> getChildren() {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChildren(List<ServerInfo> children) {
|
||||||
|
this.children = children;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getqOrE() {
|
||||||
|
return qOrE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setqOrE(String qOrE) {
|
||||||
|
this.qOrE = qOrE;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.lsh;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.lsh.webservice.ui.entity.FormV2;
|
||||||
|
import org.lsh.webservice.ui.utils.ExplainWebservice;
|
||||||
|
|
||||||
|
public class test {
|
||||||
|
public static void main(String[] args) throws JsonProcessingException {
|
||||||
|
String [] arr = {
|
||||||
|
"http://10.30.35.155:8088/services/containerQueryWebService?wsdl",
|
||||||
|
"http://ws.webxml.com.cn/WebServices/WeatherWebService.asmx?WSDL",
|
||||||
|
"http://10.30.35.116:35180/services/queryPersonPostInfoWebService?wsdl",
|
||||||
|
"http://10.30.35.116:35180/services/itemSyncWebService?wsdl",
|
||||||
|
"http://10.30.35.59/weixin.asmx?WSDL",
|
||||||
|
"http://10.30.35.116:35180/services/okWebService?wsdl"
|
||||||
|
};
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
FormV2 formV2 = ExplainWebservice.explainWsdlV2(arr[4]);
|
||||||
|
System.out.println(objectMapper.writeValueAsString(formV2));
|
||||||
|
System.out.println(formV2);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.lsh;
|
||||||
|
|
||||||
|
import javax.xml.namespace.QName;
|
||||||
|
import javax.xml.ws.Service;
|
||||||
|
import javax.xml.ws.WebServiceClient;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Parameter;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
public class test2 {
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
URL wsdlUrl = new URL("http://10.30.35.116:35180/services/queryPersonPostInfoWebService?wsdl");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.lsh;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.JavaType;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import org.lsh.webservice.ui.entity.MyParameterizedType;
|
||||||
|
import org.lsh.webservice.ui.entity.dto.ServerInfo;
|
||||||
|
|
||||||
|
import javax.xml.datatype.DatatypeConfigurationException;
|
||||||
|
import javax.xml.datatype.DatatypeFactory;
|
||||||
|
import javax.xml.datatype.XMLGregorianCalendar;
|
||||||
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class test3 {
|
||||||
|
public static void main(String[] args) throws JsonProcessingException {
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
String json = "[{\"bomDTO\":[{\"backFlush\":\"11\",\"bmeng\":\"11\",\"componentGbo\":\"11\",\"ebort\":\"11\",\"erpStep\":\"11\",\"menge\":\"11\",\"operation\":\"11\",\"qOrE\":\"11\",\"qty\":\"11\",\"reservedLine\":\"11\",\"reservedNumber\":\"11\",\"salesOrder\":\"11\",\"sequence\":\"11\",\"shopOrder\":\"11\",\"soLine\":\"11\",\"sumQty\":\"11\",\"unit\":\"11\"}],\"routingDTO\":[{\"description\":\"11\",\"erpControlKey\":\"11\",\"erpStep\":\"11\",\"manSeconds\":\"11\",\"manUnit\":\"11\",\"operation\":\"11\",\"sequence\":\"11\",\"shopOrder\":\"11\",\"staffQty\":\"11\",\"workCenter\":\"11\"}],\"shopOrderDTO\":{\"agingRatio\":\"11\",\"agingTime\":\"11\",\"agingVoltage\":\"11\",\"agingWay\":\"11\",\"baseSealRule\":\"11\",\"crestClampNum\":\"11\",\"deliveryDate\":\"2024-10-30\",\"demandPlant\":\"11\",\"demandQty\":\"11\",\"demandUser\":\"11\",\"erpStatus\":\"11\",\"fatherSo\":\"11\",\"hopeFinishTime\":\"2024-10-30\",\"innerBoxSeal\":\"11\",\"kdkg2\":\"11\",\"oriQty\":\"11\",\"outerBoxSeal\":\"11\",\"phosphorFatherSo\":\"11\",\"planNote\":\"11\",\"plannedCompDate\":\"2024-10-30\",\"plannedItem\":\"11\",\"plannedStartDate\":\"2024-10-30\",\"plannedWorkCenter\":\"11\",\"priorityNum\":\"11\",\"qtyOrdered\":\"11\",\"salesNote\":\"11\",\"salesOrder\":\"11\",\"salesOrderQuantity\":\"11\",\"salesman\":\"11\",\"shopOrder\":\"11\",\"shopOrderType\":\"11\",\"site\":\"11\",\"soItem\":\"11\",\"soLine\":\"11\",\"status\":\"11\",\"steelSealNum\":\"11\",\"stencilNum\":\"11\",\"stickerSealRule\":\"11\",\"supplyQty\":\"11\",\"switchingTime\":\"11\",\"targetLine\":\"11\",\"targetStorage\":\"11\",\"wbs\":\"11\",\"zext4\":\"11\",\"zrqyz10\":\"11\",\"zrqyz11\":\"11\",\"zrqyz5\":\"11\",\"zrqyz6\":\"11\",\"zrqyz7\":\"11\",\"zrqyz8\":\"11\",\"zrqyz9\":\"11\",\"zyp\":\"11\"}}]";
|
||||||
|
Gson gson = new Gson();
|
||||||
|
|
||||||
|
MyParameterizedType type = new MyParameterizedType(List.class, new Type[]{ShopOrderSyncDTO.class});
|
||||||
|
|
||||||
|
// Type type = new TypeToken(ShopOrderSyncDTO.class.getTypeParameters()){}.getType();
|
||||||
|
List<?> deserializedList = gson.fromJson(json, type);
|
||||||
|
System.out.println(deserializedList);
|
||||||
|
|
||||||
|
JavaType javaType = objectMapper.getTypeFactory().constructCollectionType(List.class, ShopOrderSyncDTO.class);
|
||||||
|
List list2 = objectMapper.readValue(json, javaType);
|
||||||
|
|
||||||
|
System.out.println(list2);
|
||||||
|
System.out.println(ShopOrderSyncDTO.class.getGenericSuperclass());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XMLGregorianCalendar dateToXmlDate(Date date) {
|
||||||
|
GregorianCalendar gregorianCalendar = new GregorianCalendar();
|
||||||
|
gregorianCalendar.setTime(date);
|
||||||
|
try {
|
||||||
|
return DatatypeFactory.newInstance().newXMLGregorianCalendar(gregorianCalendar);
|
||||||
|
} catch (DatatypeConfigurationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue