0
b2bHotelSOAPService objsoap = new b2bHotelSOAPService();
        objsoap.Timeout = 20000;
        objsoap.Url = "http://api.hotelspro.com/4.1_test/hotel/b2bHotelSOAP.wsdl";
        string apiKey = Connection.AppSettings("APIKey");
        string destinationId = "LD6J";
        DateTime checkIn = new DateTime(2012, 7, 20);
        DateTime checkOut = new DateTime(2012, 7, 22);
        string strCurrencyCode = "EUR";



        pax[][]rooms=new pax[3][];
        rooms[0] = new pax[3];
        rooms[0][0] = new pax();
        rooms[0][1] = new pax();
        rooms[0][2] = new pax();


        rooms[0][0].paxType = "Adult";
        rooms[0][1].paxType="Adult";
        rooms[0][2].paxType="Child";
        rooms[0][2].age = "6";


        filter[] f = new filter[1];
        f[0] = new filter();
        f[0].filterType = "hotelStar";
        f[0].filterValue = "3";




        getAvailableHotelResponse getres = new getAvailableHotelResponse();

        getres = objsoap.getAvailableHotel(apiKey, destinationId, checkIn, checkOut, strCurrencyCode, "UK", true, rooms, f);

此代码引发以下错误:

Client found response content type of 'application/wsdl+xml', but expected 'text/xml'.
The request failed with the error message:
4

1 回答 1

1

如果您在文本编辑器中打开 WSDL,您将找到要调用的 Web 服务的地址

<soap:address location="http://api.hotelspro.com/4.1_test/hotel/b2bHotelSOAP.php"/>

因此,您需要更改您正在调用的 URL。

objsoap.Url = "http://api.hotelspro.com/4.1_test/hotel/b2bHotelSOAP.php";

您调用的 .WSDL 地址是让 .NET 确定要生成的类的原因,但实际调用的是 Web 服务,即上面的 .PHP 地址。

于 2012-07-15T18:02:28.913 回答