从jQuery调用SOAP XML Web服务时出现错误405

时间:2013-09-12 11:49:20

标签: jquery xml ajax web-services soap

我正试图通过jQuery Ajax调用远程SOAP XML Web服务,我得到405错误,我真的不明白为什么。在代码中,一切似乎都是正确的。这是下面的内容。

<script>
        $(document).ready(function () {
            $("#Button1").click(function () {
                var SoapMessage = "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope soapenv:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><soapenv:Body><hb:getHotelValuedAvail xmlns:hb='http://axis.frontend.hydra.hotelbeds.com' xsi:type='xsd:String'><HotelValuedAvailRQ echoToken='DummyEchoToken' sessionId='iuqmxlafic3i0bfbpvrnkdi4' xmlns='http://www.hotelbeds.com/schemas/2005/06/messages' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.hotelbeds.com/schemas/2005/06/messages HotelCategoryListRQ.xsd' showDiscountsList='Y' version='2011/01'><Language>ENG</Language><Credentials><User>SomeUser</User><Password>SomePassword</Password></Credentials><PaginationData pageNumber='1' itemsPerPage='999'/><CheckInDate date='20130913'/><CheckOutDate date='20130914'/><Destination code='BKK' type='SIMPLE'/><OccupancyList><HotelOccupancy><RoomCount>1</RoomCount><Occupancy><AdultCount>2</AdultCount><ChildCount>0</ChildCount></Occupancy></HotelOccupancy></OccupancyList><ExtraParamList><ExtendedData type='EXT_DISPLAYER'><Name>DISPLAYER_DEFAULT</Name><Value>PROMOTION:Y</Value></ExtendedData></ExtraParamList></HotelValuedAvailRQ></hb:getHotelValuedAvail></soapenv:Body></soapenv:Envelope>";
                $.ajax({
                    url: "http://testapi.interface-xml.com/appservices/http/FrontendService",
                    data: SoapMessage,
                    dataType: "xml",
                    type: "POST",
                    processData: true,
                    contentType: "application/xml",
                    success: function (data, status, req) {
                        alert(req.responseText + " " + status);
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert("fu");
                    }
                });
            });
        });
    </script>

这是服务器的回答:

HTTP/1.1 405 OPTIONS not supported
Date: Thu, 12 Sep 2013 11:43:52 GMT
Server: Resin/2.1.17
Cache-Control: no-cache
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Content-Type: text/html; charset=ISO-8859-1
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 136

1 个答案:

答案 0 :(得分:2)

这是一个跨域请求,因此浏览器首先检查服务器是否允许通过检查OPTIONS请求中的标头来发出此类请求 您的服务器甚至不支持OPTIONS命令,因此我认为它不支持CORS