2012-07-15 28 views
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); 

此代碼投擲以下錯誤:客戶找到「應用程序/ WSDL + XML」的響應內容類型,但預計「文本/ XML」

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

什麼是'objsoap'?爲什麼你創建'getres = new getAvailableHotelResponse();'?因爲你不用它 – 2012-07-15 17:46:30

+0

@ L.B我編輯了。我正在使用HotelsPro.com的api作爲酒店 – rahularyansharma 2012-07-15 17:50:33

回答

1

如果您在文本編輯器中打開WSDL,你會發現你想撥打的網絡服務的地址

<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找出類來生成,但實際調用到Web服務,這是上面的.PHP地址。

+0

它現在正在工作,但問題是當我使用json時,它顯示了我正確數量的酒店列表,但在使用肥皂的情況下它不返回任何內容 – rahularyansharma 2012-07-15 20:14:15

+0

爲此開啓一個新問題 - 您的下一個問題似乎是關於實際調用Web服務而不是這個問題的主題。 – Mendhak 2012-07-15 21:13:46

+0

http://stackoverflow.com/questions/11495650/from-json-get-response-but-soap-zero-records – rahularyansharma 2012-07-15 21:15:32

相關問題