NodeJS SOAP WSDL动态体不工作- Amdeus

p3rjfoxz  于 2023-06-29  发布在  Node.js
关注(0)|答案(1)|浏览(158)

我试图调用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正在添加吗?

相关问题