简体   繁体   中英

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)

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM