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:
答案 0 :(得分:1)
如果您在文本编辑器中打开WSDL,您将找到要调用的Web服务的地址
<soap:address location="http://api.hotelspro.com/4.1_test/hotel/b2bHotelSOAP.php"/>
因此,您需要更改正在调用的网址。
objsoap.Url = "http://api.hotelspro.com/4.1_test/hotel/b2bHotelSOAP.php";
你正在调用的.WSDL地址是让.NET找出要生成的类的地址,但实际的调用是上面的.PHP地址的web服务。