diff --git a/usergw-service/pom.xml b/usergw-service/pom.xml
index 0317901..ce71062 100644
--- a/usergw-service/pom.xml
+++ b/usergw-service/pom.xml
@@ -58,6 +58,12 @@
snakeyaml
1.21
+
+
+ com.alibaba
+ fastjson
+ 1.2.58
+
cn.ecpark.service
diff --git a/usergw-service/src/main/java/cn/ecpark/service/usergw/biz/filters/DubboFilter.java b/usergw-service/src/main/java/cn/ecpark/service/usergw/biz/filters/DubboFilter.java
index 1d6b4df..c197910 100644
--- a/usergw-service/src/main/java/cn/ecpark/service/usergw/biz/filters/DubboFilter.java
+++ b/usergw-service/src/main/java/cn/ecpark/service/usergw/biz/filters/DubboFilter.java
@@ -1,18 +1,31 @@
package cn.ecpark.service.usergw.biz.filters;
+import java.nio.ByteBuffer;
+import java.util.Map;
+
+
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.utils.ReferenceConfigCache;
import org.apache.dubbo.rpc.service.GenericService;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
+import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
+import com.alibaba.fastjson.*;
import reactor.core.publisher.Mono;
+
+
+
+
+
+
@Component
public class DubboFilter implements GlobalFilter, Ordered {
@@ -32,11 +45,19 @@ public class DubboFilter implements GlobalFilter, Ordered {
reference.setInterface("ocean.demo.api.IExchange"); // 弱类型接口名
reference.setVersion("1.0.0");
reference.setGeneric(true); // 声明为泛化接口
- GenericService gs = reference.get();
+
+ ReferenceConfigCache cache = ReferenceConfigCache.getCache();
+ GenericService gs = cache.get(reference);
+
+
Object result = gs.$invoke("Hello", new String[]{}, new Object[]{});
- return null;
+ if (result != null) {
+ ServerHttpResponse response = exchange.getResponse();
+ return response.writeWith( Mono.just(response.bufferFactory().wrap(ByteBuffer.wrap(JSON.toJSONString(result).getBytes()))));
+ }
+ return chain.filter(exchange);
}
}
\ No newline at end of file
diff --git a/usergw-service/src/main/java/cn/ecpark/service/usergw/biz/filters/VerifyFilter.java b/usergw-service/src/main/java/cn/ecpark/service/usergw/biz/filters/VerifyFilter.java
index c512bd1..08f2385 100644
--- a/usergw-service/src/main/java/cn/ecpark/service/usergw/biz/filters/VerifyFilter.java
+++ b/usergw-service/src/main/java/cn/ecpark/service/usergw/biz/filters/VerifyFilter.java
@@ -25,6 +25,8 @@ public class VerifyFilter implements GlobalFilter {
if(true) return chain.filter(exchange);
+
+
ServerHttpRequest request = exchange.getRequest();
HttpHeaders header = request.getHeaders();
diff --git a/usergw-service/src/main/resources/application.properties b/usergw-service/src/main/resources/application.properties
index a574dd0..bfb7c87 100644
--- a/usergw-service/src/main/resources/application.properties
+++ b/usergw-service/src/main/resources/application.properties
@@ -5,3 +5,5 @@ dubbo.protocol.name=dubbo
dubbo.protocol.port=20999
dubbo.registry.address=zookeeper://127.0.0.1:2181
server.port=8888
+
+logging.level.org.springframework.cloud.gateway=debug