我遇到一个错误,上面写着:“引起:groovy.lang.GroovyRuntimeException:在运行时找不到匹配的构造函数:groovyx.net.http.HttpResponseException(java.lang.Integer,java.lang.String)”代码如下。我错过了什么吗?谢谢!
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1')
import groovyx.net.http.Method
import groovyx.net.http.RESTClient
import org.apache.http.entity.StringEntity
import groovyx.net.http.ContentType
import groovyx.net.http.HttpResponseException
import groovyx.net.http.HttpResponseDecorator
class callmpgPortout implements Runnable {
// Input variables
String MSISDN;
Date REQUEST_START_TIME;
String NP_TXN_ID;
String PORT_ID;
String LOG_ID;
String OLO;
String VARIABLE1;
String VARIABLE2;
String VARIABLE3;
String VARIABLE4;
String VARIABLE5;
// Output variables
String MSGCODE;
String MSGDESC;
private Long status;
public void run() {
def client = new RESTClient('http://sgbdcmpweb01:7980')
client.handler.failure = { resp, data ->
resp.setData(data)
String headers = ""
resp.headers.each {
headers = headers+"${it.name} : ${it.value}\n"
}
throw new HttpResponseException(resp.getStatus(),"HTTP call failed. Status code: ${resp.getStatus()}\n${headers}\n"+
"Response: "+(resp as HttpResponseDecorator).getData())
return resp
}
def resp = client.post(
path : '/RTDM/rest/runtime/decisions/mpgPortout',
requestContentType : ContentType.JSON,
body: [ version:'1', correlationId:'91', clientTimeZone:'GMT', inputs: [MSISDN:'MSISDN',REQUEST_START_TIME:'REQUEST_START_TIME',NP_TXN_ID:'NP_TXN_ID',PORT_ID:'PORT_ID',LOG_ID:'LOG_ID',OLO:'OLO',VARIABLE1:'VARIABLE1',VARIABLE2:'VARIABLE2',VARIABLE3:'VARIABLE3',VARIABLE4:'VARIABLE4',VARIABLE5:'VARIABLE5'] ]
)
status = resp.status;
}
public Long getStatus() {
return status;
}
}
答案 0 :(得分:0)
groovyx.net.http.HttpResponseException只有一个构造函数,它只接受groovyx.net.http.HttpResponseDecorator(即样本中的resp)。