2012-07-11 63 views
0

我成功添加了一個web參考到我的asp.net vb web項目。在asp.net中包含webservice後的步驟

但我不知道如何做我的第一個搜索原因沒有文檔。

任何人都可以給我一些關於以下webservice的提示嗎?

http://xml.lowcostgroup.com/soap/book.asmx

相應要求

<?xml version="1.0" encoding="utf-8"?> 
<SearchRequest> 
    <LoginDetails> 
    <Login>login</Login> 
    <Password>pass</Password> 
    <AgentReference>IRELAND</AgentReference> 
    </LoginDetails> 
    <SearchDetails> 
    <ArrivalDate>2012-08-11</ArrivalDate> 
    <Duration>7</Duration> 
    <RegionID>64</RegionID> 
    <AirportCode>PMI</AirportCode> 
    <PropertyID>0</PropertyID> 
    <Resorts> 
     <Resort> 
     <ResortID>324</ResortID> 
     </Resort> 
     <Resort> 
     <ResortID>343</ResortID> 
     </Resort> 
     <Resort> 
     <ResortID>347</ResortID> 
     </Resort> 
    </Resorts> 
    <MealBasisID>0</MealBasisID> 
    <MinStarRating>0</MinStarRating> 
    <RoomRequests> 
     <RoomRequest> 
     <Adults>2</Adults> 
     <Children>1</Children> 
     <Infants>0</Infants> 
     <ChildAges> 
      <ChildAge> 
       <Age>5</Age> 
      </ChildAge> 
     </ChildAges> 
     </RoomRequest> 
    </RoomRequests> 
    </SearchDetails> 
</SearchRequest> 
+0

您必須在添加「服務參考」後使用'YourNameSpace..wbBookSoapClient'中的* proxy *類。 – adatapost 2012-07-11 14:51:11

+0

thx您的反饋意見,你能否更精確一點嗎? – user168507 2012-07-11 15:06:03

回答

1

當您添加Web服務,你必須在窗口的底部,進入一個文本框命名空間。在該名稱空間內將是您需要調用服務的服務客戶端。

舉例來說,如果你用「bookService的」爲您的命名空間的代碼會是這個樣子:

BookService.SearchRequest searchRequest = new BookService.SearchRequest(); 
// Fill out the search request 

BookService.wbBookSoapClient client = new BookService.wbBookSoapClient(); 
BookService.SearchResponse response = client.Search(searchRequest); 

根據您在下面的評論發佈的代碼,你應該更新它看起來像如下:

 ServiceReference1.PropertyDetailsRequest searchRequest = new ServiceReference1.PropertyDetailsRequest(); 
     ServiceReference1.LoginDetails loginDetails = new ServiceReference1.LoginDetails(); 

     loginDetails.Login = ""; 
     loginDetails.Password = ""; 
     loginDetails.AgentReference = "german"; 

     searchRequest.LoginDetails = loginDetails; 
     searchRequest.PropertyID = 20; 

     ServiceReference1.wbBookSoapClient client = new ServiceReference1.wbBookSoapClient(); 
     ServiceReference1.PropertyDetailsResponse response = client.PropertyDetails(searchRequest); 
+0

再次感謝。根據你的代碼,這裏有什麼可能是錯的? ServiceReference1.PropertyDetailsRequest searchRequest = new ServiceReference1.PropertyDetailsRequest(); //填寫搜索請求 searchRequest.LoginDetails.Login =「」; searchRequest.LoginDetails.Password =「」; searchRequest.LoginDetails.AgentReference =「german」; searchRequest.PropertyID = 20; ServiceReference1.wbBookSoapClient client = new ServiceReference1.wbBookSoapClient(); ServiceReference1.SearchResponse response = client.Search(searchRequest); – user168507 2012-07-11 15:40:09

+0

您發佈的代碼存在問題的原因是您的搜索請求的類型爲「PropertyDetailsRequest」,而方法「client.Search()」正在等待「SearchRequest」類型的請求。我會更新我的答案,並對您發佈的代碼進行一些更正。 – 2012-07-11 15:48:20

+0

thx,我們正在接近解決方案。仍然有一個錯誤。填寫搜索請求是錯誤的。我已經插入正確的登錄名,通過 – user168507 2012-07-11 16:03:25