0

I am trying to process WSDL request using SOAP in VB.NET :

    <AvailabilitySearch> 
<Authority> 
<RegionId>or<HotelId>
 <HotelStayDetails>
 <HotelSearchCriteria>(optional) 
<DetailLevel>(optional) 
<CustomDetailLevel>(optional) 
<MaxResultsPerHotel>(optional, ignored) 
<MaxHotels>(optional)
 <SortOrder>(optional, ignored)
 <MaxSearchTime>(optional, ignored) 
</AvailabilitySearch>

and my coding is :

 Protected Sub btnhotelsearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnhotelsearch.Click
    '----------------------Authority---------------------------
    Dim systemauthority As New com.roomsxmldemo.AuthorityElement

    systemauthority.Currency = "USD"
    systemauthority.Org = "xx"
    systemauthority.User = "xx"
    systemauthority.Password = "xx"
    systemauthority.Version = "1.18"
    '----------------------Authority End---------------------------


    Dim hotelsearch As com.roomsxmldemo.AvailabilitySearch
    hotelsearch.Authority = systemauthority
    hotelsearch.RegionId = 18169
    hotelsearch.HotelId = 0
    hotelsearch.HotelStayDetails.Nights = 1
    hotelsearch.HotelStayDetails.Nationality = "IQ"
    hotelsearch.HotelStayDetails.ArrivalDate = "2014-01-14"


    Dim result As com.roomsxmldemo.AvailabilitySearchResult
    txtresult.Text = result.HotelAvailability.Length

End Sub

am getting error in Authority syntex where I passed all login details but got the following error : Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 84: 
Line 85:         Dim hotelsearch As com.roomsxmldemo.AvailabilitySearch
**Line 86:         hotelsearch.Authority = systemauthority**
Line 87:         hotelsearch.RegionId = 18169
Line 88:         hotelsearch.HotelId = 0
John Saunders
  • 160,644
  • 26
  • 247
  • 397
Saif
  • 7
  • 3
  • Almost all cases of `NullReferenceException` are the same. Please see "[What is a NullReferenceException in .NET?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-in-net)" for some hints. – John Saunders Oct 17 '13 at 01:11
  • In particular, this problem has nothing to do with the fact that you're calling a web service. – John Saunders Oct 17 '13 at 01:11

1 Answers1

0

Try this:

Dim hotelsearch As New com.roomsxmldemo.AvailabilitySearch
John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • It worked, thank you Joh, how to read the result ? I used this but couldnt get it : Dim result As New com.roomsxmldemo.AvailabilitySearchResult txtresult.Text = result.HotelAvailability.Length – Saif Oct 17 '13 at 03:55
  • it worked but how to read the result ? I used the above code but didnt work.How to send you the whole code ? – Saif Oct 17 '13 at 06:28
  • You don't send anyone "the whole code". You have to tell us what you mean when you said, "couldn't get it". – John Saunders Oct 17 '13 at 06:29
  • is this the proper way to get the result after sending the request ? Dim result As com.roomsxmldemo.AvailabilitySearchResult txtresult.Text = result.HotelAvailability.Length – Saif Oct 17 '13 at 06:34
  • It is necessary to be precise in programming computers. Please tell me _precisely_ what happens when you try that code? – John Saunders Oct 17 '13 at 06:35
  • I got this error "value of type "1-dimensional array of com.roomsxmldemo.AvailabilitySearchResult can not be converted to string" For this coding : Dim result As New com.roomsxmldemo.AvailabilitySearchResult txtresult.Text = result.HotelAvailability – Saif Oct 17 '13 at 06:53
  • What part of that exception do you not understand? It means that `result.HotelAvailability` is a "value of type "1-dimensional array of `com.roomsxmldemo.AvailabilitySearchResult`". It is not a string. – John Saunders Oct 17 '13 at 06:55
  • Try `txtresult.Text = result.HotelAvailability(0)` – John Saunders Oct 17 '13 at 10:34
  • I tried this John and got the following alert "value of type "com.roomsxmldemo.hotelavailabilityelement" cannot be converted to string". The webservice description can be found here http://roomsxmldemo.com/RXLStagingServices/ASMX/XmlService.asmx and the API is through http://www.filsaan.com/api.pdf – Saif Oct 17 '13 at 13:07
  • Ok, I read their documentation and I understand why you're confused. They show only one brief .NET example and it's incomplete. The rest of their documentation shows XML and no code. Go read [How to consume a web service](http://johnwsaunders3.wordpress.com/2009/05/17/how-to-consume-a-web-service/) and I'll get back to you. – John Saunders Oct 17 '13 at 14:14
  • Very useful link John,appreciate it.Still stuck in reading the array and convert the elements inside the arraylist to string.Any further help is appreciated. – Saif Oct 17 '13 at 14:47
  • You get that the `Hotel` type contains multiple pieces, right? What do you plan to do with the pieces? – John Saunders Oct 17 '13 at 14:49
  • I will retrieve values from database according to each result, like the main image, hotel rooms and prices etc ....I dont know if this answer your inquiry – Saif Oct 17 '13 at 14:56