Web Service එකට Request එකක් යවල , Response එක ගන්නේ කොහමද ??

Seven Net

Active member
  • Jan 13, 2014
    290
    62
    28
    30
    Earth
    Web Service එකට Request එකක් යවල , Response එක ගන්නේ කොහමද ??

    Web Service එකට Request එකක් යවල , Response එක ගන්නේ කොහමද ??

    Amadeus කියන අය හදපු Web Service එකක් තියේනව. එයාලම දුන්නා WSDL ෆයිල් එක හා XSD ෆයිල්ස් ටික හා මම ඒවා ටික Host කරා. මම Request එකක් යවල , Response එකක් ගන්න , මේ පහල විධියට JavaScript , Ajax වලින් ස්ක්‍රිප්ට් එකක් ලිව්වා. එත් , මම Request එකක් යැවුවට , Response එකක් එන්නේ නැ. මම මෙහිදි Ajax වල URL එක විධියට දෙන්නේ Amadeus Web Service එකේ Endpoint එක. මිට අමතරව WSDL ෆයිල් එකේ හා XSD ෆයිල්ස් ටිකේ ලින්ක් එකත් දෙන්න ඕනද ??

    නැත්නම් WSDL ෆයිල් එක හා XSD ෆයිල් ටිකත් භාවිතා කරන් , Request එකක් යවල , Response එකක් ගන්නේ කොහමද ??

    මේක තමයි ලිව්ව JavaScript , Ajax එක.


    Code:
    <html>
    <head>
        <title></title>
        <meta charset="utf-8"/>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.12.0/moment.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
    	<script src="http://www.timestampgenerator.com/js/common.js"></script>
    	
    </head>
    <body>
    
    <div class="container"> <!-- Start Of The Container Class -->
    
        <div class="row text-center"> <!-- Start Of The Row Class -->
    
            <div class="col-md-12 col-sm-12 hero-feature"> <!-- Start Of The Col Class -->
    
                <h3>Tasks of the Developers</h3> <br>
    
    			<form class="form-horizontal" method="POST" action="#" enctype="multipart/form-data" id="signupForm">
                    
    				<div class="col-md-4 col-sm-12 hero-feature"> <!-- Start Of The Col Class -->
                        Message Id : <input class="form-control" id="messageid" type="text" placeholder="Results will be placed here..." readonly size="40"/> <br>
                    </div>
    				
    				<div class="col-md-4 col-sm-12 hero-feature"> <!-- Start Of The Col Class -->
                        Nonce : <input class="form-control" id="nonceshow" type="text"/> <br>
                    </div>
    				
    				<div class="col-md-4 col-sm-12 hero-feature"> <!-- Start Of The Col Class -->
                        Timestamp : <input class="form-control" type="text" name="timestampama" id="timestampama"/> <br>
                    </div>
    				
    				<div class="col-md-4 col-sm-12 hero-feature"> <!-- Start Of The Col Class -->
                        Text : <input type="text" class="form-control" name="strex" id="strex" size="20" />  <br>
                    </div>
    				
    				<div class="col-md-4 col-sm-12 hero-feature"> <!-- Start Of The Col Class -->
                        SHA-1 : <input type="text" class="form-control" name="strcrypt" id="strcrypt" size="33" /> <br>
                    </div>
    
                    <a href="#" id="ghsubmitbtn" class="btn btn-success">Search</a>
    
                    <p id="errorModal"></p> <br>
    
                    <div id="ghapidata" class="clearfix"></div>
    
                </form>
    
    			<p id="body"></p>
    
                <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 nonce = nonceid();
    						//var nonceremove = nonce.slice(0, -4); //Remove last 4 characters
    						//var n = nonceremove.length; //Length
                            var pw = 'SSSSSS';
    
    						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/XXXXXX</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>WSEOLMTT</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/FMPTBQ_14_3_1A">' +
                    '<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/XXXXXX',
                                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>
    
            </div> <!-- End Of The Col Class -->
    
        </div> <!-- End Of The Row Class -->
    
    </div> <!-- End Of The Container Class -->
    
    </body>
    </html>