出现错误:http:从Hyperledger Composer中的“事务处理器"功能读取封闭的响应正文 [英] Getting Error: http: read on closed response body from Transaction Processor function in Hyperledger Composer
问题描述
我有一个运行有简单BNA的结构网络.该BNA定义了两种类型的参与者.公司和个人.在这里,每个人与公司都有关系,如下所示(cto文件):
I've a fabric network running with a simple BNA. This BNA defines two types of participants viz. Corporate and Person. Here, each Person has a relationship with the corporate as shown below (cto file):
participant Corporate identified by corporateId {
o String corporateId
o String corporateName
}
participant Person identified by personId {
o String personId
--> Corporate corporate
}
我要做什么:
- 使用事务处理程序功能创建公司:成功
- 使用事务处理器功能创建人员:失败
以下是#2的交易处理器功能片段:
Following is the snippet from transaction processor function for #2:
let corporateIdExpected = personDetails.corporate;
if(corporateIdExpected && corporateIdExpected != '') {
let corporateRetrieved = await query("GetCorporateByCorporateId", {corporateId: corporateIdExpected});
if(!corporateRetrieved || corporateRetrieved == '') {
throw new Error("Corporate details not valid. Please check if your corporate is present on the network.");
}
}
我的querys.qry中的代码段:
Snippet from my queries.qry:
query GetCorporateByCorporateId {
description: "Returns all corporates in the registry"
statement:
SELECT org.samplenetwork.participants.Corporate
WHERE (corporateId == _$corporateId)
}
因此,尝试#2时出现以下错误:
So, I get the following error when I try the #2:
错误:2 UNKNOWN:执行链代码时出错:事务以失败返回:错误:错误:http:在关闭的响应正文上读取
Error: 2 UNKNOWN: error executing chaincode: transaction returned with failure: Error: Error: http: read on closed response body
但是,当我尝试直接从招摇中执行查询时,它会成功运行.
However, when I try to execute the query directly from the swagger, it runs successfully.
我正在使用:
超级账本面料:1.1 Hyperledger Composer:0.19.8
Hyperledger Fabric: 1.1 Hyperledger Composer: 0.19.8
我为此错过任何检查或步骤吗?
Am I missing out any checks or steps for this one?
推荐答案
第2项-您实际上不必每次都执行命名查询.
for item 2 - you don't really need to execute a named query each time.
您可以按以下方式进行等效检查(他已经存在吗?")(其中下面的trxn
是您的事务定义中定义的事务对象,等等):
You can do the equivalent check ("does he exist already?") as follows (where trxn
below is the transaction object defined in your transaction definition etc):
const personRegistry = await getParticipantRegistry('org.acme.example.Person');
console.log("The person identifier to check is " + trxn.corporate.getIdentifier() )
const exists = await personRegistry.exists(trxn.corporate.getIdentifier() ) ;
console.log("exists is set to " + exists); // boolean
if (exists)
console.log("he exists")
else
console.log("he doesn't exist");
这篇关于出现错误:http:从Hyperledger Composer中的“事务处理器"功能读取封闭的响应正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!