我试图调用Amadeus服务,导入本地wsdl文件并使用soap npm将该wsdl连接到soap客户端。我的客户端成功连接,但请求正文自动添加了意外的标记。
这里我添加了我的示例代码和错误。如果有人对此有任何解决办法,请帮助我。
示例编码:
const path = process.cwd();
import * as soap from 'soap';
const filePath = `${path}/Hotel_Content.wsdl`;
const inputBody = {
HotelDescriptiveInfos: {
HotelDescriptiveInfo: {
'@HotelCode': 'RTNYCNOV',
},
},
};
function main() {
soap.createClient(filePath, (err, client) => {
if (err) {
console.log(err);
return;
}
client.Hotel_DescriptiveInfo(inputBody, (err: any, data: any) => {
if (err) {
console.log("err ====", err)
}
console.log("data ==", data)
})
});
}
main()
需要来自上述请求的SOAP主体
<soap:Body>
<OTA_HotelDescriptiveInfoRQ EchoToken="PartialWithParsing" Version="6.001" PrimaryLangID="en" >
<HotelDescriptiveInfos>
<HotelDescriptiveInfo HotelCode="RTNYCNOV" >
</HotelDescriptiveInfo>
</HotelDescriptiveInfos>
</OTA_HotelDescriptiveInfoRQ>
</soap:Body>
调用上述SOAP客户端时生成的SOAP Body.Hotel_DescriptiveInfo.
<soap:Body>
<ota_2003_05:OTA_HotelDescriptiveInfoRQ
xmlns:ota_2003_05="http://www.opentravel.org/OTA/2003/05"
xmlns="http://www.opentravel.org/OTA/2003/05">
<ota_2003_05:HotelDescriptiveInfos>
<ota_2003_05:HotelDescriptiveInfo>
<ota_2003_05: @HotelCode>RTNYCNOV</ota_2003_05:@HotelCode>
</ota_2003_05:HotelDescriptiveInfo>
</ota_2003_05:HotelDescriptiveInfos>
</ota_2003_05:OTA_HotelDescriptiveInfoRQ>
</soap:Body>
有人能告诉我为什么这个不需要的ota_2003_05正在添加吗?
1条答案
按热度按时间zlwx9yxi1#
它看起来像SOAP中的namespace-prefix,也许这篇文章会帮助你找到解决方案:
Soap envelope namespace prefix in Java web service
https://help.mulesoft.com/s/article/How-to-Set-a-Custom-Namespace-Prefix-for-the-SOAP-Envelope-Header-and-Body-Elements-in-the-Response-of-the-SOAPKit-Router
http://corpus.hubwiz.com/2/node.js/23984016.html