user1270384
user1270384

Reputation: 721

Working with Web services response

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)

Upvotes: 1

Views: 5006

Answers (2)

ZafarYousafi
ZafarYousafi

Reputation: 10840

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);

Upvotes: 4

Matt
Matt

Reputation: 1973

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.

Upvotes: 1

Related Questions