1

My page must get a response from a web service with the following calls:

GetModBook.InvService.InventoryServiceClient isc = new GetModBook.InvService.InventoryServiceClient();

GetModBook.InvService.GetModBookingsOperationRequest gmoreq = new GetModBook.InvService.GetModBookingsOperationRequest();

GetModBook.InvService.GetModBookingsOperationResponse gmores = new GetModBook.InvService.GetModBookingsOperationResponse();

GetModBookingsOperationResponse has a field called Bookings with an array of Booking as such

public GetModBookingsOperationResponse 
{
  public Booking Bookings;
}

I have used the request portion of a web service

example:

gmoreq.RatePackages = new GetModBook.InvService.GetModBookingsOperationRequest[NoofRatePackages]

Editted:

Calling a web service

but I do not know how to call the response portion

Any advise would be greatly appreciated.

Editted:

GetModBookingsResponse GetModBookings(GetModBookingsRequest request)
Community
  • 1
  • 1
user1270384
  • 711
  • 7
  • 24
  • 53

2 Answers2

4

Here is how you can get response

GetModBook.InvService.InventoryServiceClient isc = new GetModBook.InvService.InventoryServiceClient();

GetModBook.InvService.GetModBookingsOperationRequest gmoreq = new GetModBook.InvService.GetModBookingsOperationRequest();
//set the request parameters if there any

GetModBook.InvService.GetModBookingsOperationResponse gmores =isc.GetModBookings(gmoreq);
ZafarYousafi
  • 8,640
  • 5
  • 33
  • 39
  • gmores is the response you get after calling method. Check if it is not null and have Booking array – ZafarYousafi Jul 17 '12 at 04:57
  • Yes thats the part I'm looking for help with. Getting the booking array. – user1270384 Jul 17 '12 at 20:49
  • 1
    This is how a service method is called. If your booking array is null or has no booking then it is specific to your service and the request parameters you are sending. You need to consult the service provider or documentation to better look into the issue. – ZafarYousafi Jul 18 '12 at 05:30
1

Without seeing your complete class implementation I can't say how to call it but here is an example on how to call web service method.

The following example will show how to get server using web service.

Web service cs file

[WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class SampleWebService : System.Web.Services.WebService
    {
[WebMethod]
        public DateTime GetServerDate()
        {
            return DateTime.Now;
        }
    }

Webservice consumer page

SampleWebServiceWS.SampleWebServiceClient ws = new SampleWebServiceWS.SampleWebServiceClient();
          DateTime dt=  ws.GetServerDate();

Similar way you can call your method and assign it to a variable.

I didn't tested the code but hope this will give an idea on how to implement this.

Matt
  • 1,953
  • 1
  • 19
  • 42
  • Thank you for this @user970349 but the webservice is already made on my client end. I must connect to it and call the above mentioned method to get booking details – user1270384 Jul 16 '12 at 20:29
  • 1
    Ok. You just need to add reference of web service and just need to call your method using Web Service Client object as mentioned above. Hope that is what you are looking for :D – Matt Jul 17 '12 at 04:21