Getting Error: http: read on closed response body from Transaction Processor function in Hyperledger Composer
Getting Error: http: read on closed response body from Transaction Processor function in Hyperledger Composer
我有一个结构网络 运行 一个简单的 BNA。该 BNA 定义了两种类型的参与者,即。公司和个人。在这里,每个人与公司的关系如下所示(cto 文件):
participant Corporate identified by corporateId {
o String corporateId
o String corporateName
}
participant Person identified by personId {
o String personId
--> Corporate corporate
}
我想做什么:
- 使用交易处理器功能创建公司:成功
- 使用交易处理器功能创建个人:失败
以下是 #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.");
}
}
来自我的 queries.qry 的片段:
query GetCorporateByCorporateId {
description: "Returns all corporates in the registry"
statement:
SELECT org.samplenetwork.participants.Corporate
WHERE (corporateId == _$corporateId)
}
因此,当我尝试 #2 时出现以下错误:
Error: 2 UNKNOWN: error executing chaincode: transaction returned with failure: Error: Error: http: read on closed response body
但是,当我尝试直接从 swagger 执行查询时,它运行成功。
我正在使用:
超级账本结构:1.1
超级账本作曲家:0.19.8
我是否遗漏了这一项的任何检查或步骤?
对于第 2 项 - 您真的不需要每次都执行命名查询。
您可以按如下方式进行等效检查 ("does he exist already?")(其中 trxn
下面是您的交易定义等中定义的交易对象):
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");
我有一个结构网络 运行 一个简单的 BNA。该 BNA 定义了两种类型的参与者,即。公司和个人。在这里,每个人与公司的关系如下所示(cto 文件):
participant Corporate identified by corporateId {
o String corporateId
o String corporateName
}
participant Person identified by personId {
o String personId
--> Corporate corporate
}
我想做什么:
- 使用交易处理器功能创建公司:成功
- 使用交易处理器功能创建个人:失败
以下是 #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.");
}
}
来自我的 queries.qry 的片段:
query GetCorporateByCorporateId {
description: "Returns all corporates in the registry"
statement:
SELECT org.samplenetwork.participants.Corporate
WHERE (corporateId == _$corporateId)
}
因此,当我尝试 #2 时出现以下错误:
Error: 2 UNKNOWN: error executing chaincode: transaction returned with failure: Error: Error: http: read on closed response body
但是,当我尝试直接从 swagger 执行查询时,它运行成功。
我正在使用:
超级账本结构:1.1 超级账本作曲家:0.19.8
我是否遗漏了这一项的任何检查或步骤?
对于第 2 项 - 您真的不需要每次都执行命名查询。
您可以按如下方式进行等效检查 ("does he exist already?")(其中 trxn
下面是您的交易定义等中定义的交易对象):
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");