如何使用Amadeus WSDL和XSD文件发送SOAP请求并获取响应

时间:2018-08-31 08:34:23

标签: jquery ajax soap wsdl amadeus

我正在使用Amadeus Web服务创建一个网站。因此,我从Amadeus获得了WSDL文件和XSD文件。我将所有文件上传到服务器。然后,我创建了一个Jquery,Ajax脚本来访问Amadeus Web服务。但是,很不幸,我无法访问Amadeus Web服务。

当我尝试访问Amadeus Web服务时,应该在代码中提及WSDL链接吗?如果是这样,我该怎么办? 因为我只使用Amadex和Action URL在Ajax脚本中提供的端点,如下所示。

这是脚本和SOAP请求。

<script type="text/javascript">

    //Main Function
                    $(document).ready(function () {

                        $.getScript("PwJs.js", function () {
                        });

                    $('#ghsubmitbtn').on('click', function(e) {
                            var country = $('#country').val();
                            var year = $('#year').val();
                            var month = $('#month').val();

                            var messageid = guid();
                            var pw = 'DDDDD';

                            var str = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sec="http://xml.amadeus.com/2010/06/Security_v1" xmlns:typ="http://xml.amadeus.com/2010/06/Types_v1" xmlns:iat="http://www.iata.org/IATA/2007/00/IATA2010.1" xmlns:app="http://xml.amadeus.com/2010/06/AppMdw_CommonTypes_v3" xmlns:link="http://wsdl.amadeus.com/2010/06/ws/Link_v1" xmlns:ses="http://xml.amadeus.com/2010/06/Session_v3" xmlns:fmp="http://xml.amadeus.com/FMPTBQ_14_3_1A">' +
        '<soapenv:Header>' +
            '<add:MessageID xmlns:add="http://www.w3.org/2005/08/addressing">' + messageid + '</add:MessageID>' +
            '<add:Action xmlns:add="http://www.w3.org/2005/08/addressing">http://webservices.amadeus.com/ZZZZZ</add:Action>' +
            '<add:To xmlns:add="http://www.w3.org/2005/08/addressing">https://nodeD1.test.webservices.amadeus.com/XXXXX</add:To>' +
            '<link:TransactionFlowLink xmlns:link="http://wsdl.amadeus.com/2010/06/ws/Link_v1"/>' +
            '<oas:Security xmlns:oas="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">' +
                '<oas:UsernameToken oas1:Id="UsernameToken-1" xmlns:oas1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">' +
                    '<oas:Username>WSE</oas:Username>' +
                    '<oas:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">' + noncemove + '</oas:Nonce>' +
                    '<oas:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">' + hashedPw + '</oas:Password>' +
                    '<oas1:Created>' + timestampama + '</oas1:Created>' +
                '</oas:UsernameToken>' +
            '</oas:Security>' +
            '<AMA_SecurityHostedUser xmlns="http://xml.amadeus.com/2010/06/Security_v1">' +
                '<UserID AgentDutyCode="SU" POS_Type="1" PseudoCityCode="CMBI228AJ" RequestorType="U"/>' +
            '</AMA_SecurityHostedUser>' +
        '</soapenv:Header>' +
        '<soapenv:Body>' +
            '<Fare_MasterPricerTravelBoardSearch>' +
                '<numberOfUnit xmlns="http://xml.amadeus.com/ZZZZZ">' +
                    '<unitNumberDetail>' +
                        '<numberOfUnits>1</numberOfUnits>' +
                        '<typeOfUnit>PX</typeOfUnit>' +
                    '</unitNumberDetail>' +
                    '<unitNumberDetail>' +
                        '<numberOfUnits>250</numberOfUnits>' +
                        '<typeOfUnit>RC</typeOfUnit>' +
                    '</unitNumberDetail>' +
                '</numberOfUnit>' +
                '<paxReference>' +
                    '<ptc>ADT</ptc>' +
                    '<traveller>' +
                        '<ref>1</ref>' +
                    '</traveller>' +
                '</paxReference>' +
                '<fareOptions>' +
                    '<pricingTickInfo>' +
                        '<pricingTicketing>' +
                            '<priceType>ET</priceType>' +
                            '<priceType>TAC</priceType>' +
                            '<priceType>RP</priceType>' +
                        '</pricingTicketing>' +
                    '</pricingTickInfo>' +
                '</fareOptions>' +
                '<itinerary>' +
                    '<requestedSegmentRef>' +
                        '<segRef>1</segRef>' +
                    '</requestedSegmentRef>' +
                    '<departureLocalization>' +
                        '<departurePoint>' +
                            '<locationId>DEL</locationId>' +
                        '</departurePoint>' +
                    '</departureLocalization>' +
                    '<arrivalLocalization>' +
                        '<arrivalPointDetails>' +
                            '<locationId>BOM</locationId>' +
                        '</arrivalPointDetails>' +
                    '</arrivalLocalization>' +
                    '<timeDetails>' +
                        '<firstDateTimeDetail>' +
                            '<date>161018</date>' +
                        '</firstDateTimeDetail>' +
                    '</timeDetails>' +
                    '<flightInfo>' +
                        '<cabinId>' +
                            '<cabin>Y</cabin>' +
                        '</cabinId>' +
                    '</flightInfo>' +
                '</itinerary>' +
            '</Fare_MasterPricerTravelBoardSearch>' +
        '</soapenv:Body>' +
    '</soapenv:Envelope>';

                            //console.log(departureDate);

                            $.ajax({
                                url: 'https://nodeD1.test.webservices.amadeus.com/XXXXX',
                                method: 'POST',
                                contentType:"text/xml; charset=utf-8",
                                data: str,
                                //headers: {"Authorization": 'Bearer ' + bat},
                                beforeSend: function (xhr) {
                                    xhr.setRequestHeader('SOAPAction', 'http://webservices.amadeus.com/ZZZZZ');
                                                            },

                                success: function (data) {

                                    console.log(data);

                                }

                            });

                        });

                    });

                </script>

0 个答案:

没有答案