NutzCN Logo
问答 求助,如何发送Get拼接参数的请求,我用的方法好像不能用
发布于 1435天前 作者 ThxYouForComing 1206 次浏览 复制 上一个帖子 下一个帖子
标签:
public Object execStore1(String timestamp,String seqNo,String transNo,String businessType) {
	
		//设置一下时间戳
		SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
		//给时间戳赋值
    	timestamp = df2.format(new Date());
    	seqNo = "4635768786756";
    	transNo = "234567845678";
    	businessType = "HOTEL";
    	
    	//调用UUIDUtils获取一个reqId
    	String reqString = UUIDUtils.creatUUID();
    	//这个Map是存的URL参数,请求头Header(sign除外)
    	Map<String, Object> params = new HashMap<String, Object>();
    	params.put("requestId", "WAC");
    	params.put("targetId", "MMS");
    	params.put("serviceId", "QueryStoreList");
    	params.put("timestamp", "2020-12-14 17:27:04");
    	params.put("seqNo", seqNo);
    	params.put("transNo", transNo);
    	params.put("businessType", businessType);
    	//这个是调用签名方法 然后用code接收一下签名串
    	String code = SignUtil.signToRequestGet(params,"BE266D8CC0","5924e0cfeb5b4214b4e448613e55bcf3");
    	try {
    		//获取拼接的参数
        	String pinjie = SignUtil.signToRequestmap(params);
    		Request req =Request.create("http://183.63.76.163:9880/operation-service/v1/operation/item/queryStoreList?"+pinjie, METHOD.GET);
    		Header header = Header.create();
    		header.set("Content-Type", "application/json; charset=utf-8");
    		header.set("x-dtyunxi-instanceId", "1260634217255523340");
    		header.set("x-dtyunxi-reqId", "5924e0cfeb5b4214b4e448613e55bcf3");
    		header.set("x-dtyunxi-sign", code);
    		req.setHeader(header);
    		Response response = Sender.create(req).setTimeout(10000).send();
    		response.getContent();
    	} catch (Exception e) {
        	log.error(e.getMessage());
        	e.printStackTrace();
    	}
    	return result;
	}

这个是我写的方法,但是他好像是不太可行

1 回复

这些是日志

2020-12-17 14:49:44,265 com.bsdkj.hhd.modules.service.webservice.WebService.execStore1(WebService.java:720) ERROR - java.io.IOException: Stream closed
java.lang.RuntimeException: java.io.IOException: Stream closed
	at org.nutz.lang.Lang.wrapThrow(Lang.java:153)
	at org.nutz.lang.Streams.readAndClose(Streams.java:291)
	at org.nutz.http.Response.getContent(Response.java:148)
	at org.nutz.http.Response.getContent(Response.java:141)
	at com.bsdkj.hhd.modules.service.webservice.WebService.execStore1(WebService.java:718)
	at com.bsdkj.hhd.modules.mvc.test.TestAction.GetStore(TestAction.java:80)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:25)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.bsdkj.hhd.common.mvc.processor.NutShiroProcessor.process(NutShiroProcessor.java:54)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.bsdkj.hhd.common.mvc.processor.XSSProcessor.process(XSSProcessor.java:43)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.bsdkj.hhd.common.mvc.processor.GlobalsSettingProcessor.process(GlobalsSettingProcessor.java:39)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.bsdkj.hhd.common.mvc.processor.LogTimeProcessor.process(LogTimeProcessor.java:21)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:196)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at com.bsdkj.hhd.common.mvc.filter.XssFilter.doFilter(XssFilter.java:23)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:670)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Stream closed
	at java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:159)
	at java.io.BufferedInputStream.read1(BufferedInputStream.java:284)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
	at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
	at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
	at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
	at java.io.InputStreamReader.read(InputStreamReader.java:184)
	at java.io.Reader.read(Reader.java:140)
	at org.nutz.lang.Streams.read(Streams.java:270)
	at org.nutz.lang.Streams.readAndClose(Streams.java:288)
	... 69 more
添加回复
请先登陆
回到顶部