Академический Документы
Профессиональный Документы
Культура Документы
Copyright
Copyright 2011 SAP AG. All rights reserved.
SAP Library document classification: PUBLIC
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission
of SAP AG. The information contained herein may be changed without prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software components of other
software vendors.
Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.
IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System
z9, z10, z9, iSeries, pSeries, xSeries, zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390
Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER,
OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF,
Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are
trademarks or registered trademarks of IBM Corporation.
Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.
Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems
Incorporated in the United States and/or other countries.
Oracle is a registered trademark of Oracle Corporation.
UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.
Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered
trademarks of Citrix Systems, Inc.
HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium,
Massachusetts Institute of Technology.
Java is a registered trademark of Sun Microsystems, Inc.
JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and
implemented by Netscape.
SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP BusinessObjects Explorer, StreamWork, and other SAP
products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP
AG in Germany and other countries.
Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence,
Xcelsius, and other Business Objects products and services mentioned herein as well as their respective logos are
trademarks or registered trademarks of Business Objects Software Ltd. Business Objects is an SAP company.
Sybase and Adaptive Server, iAnywhere, Sybase 365, SQL Anywhere, and other Sybase products and services mentioned
herein as well as their respective logos are trademarks or registered trademarks of Sybase, Inc. Sybase is an SAP
company.
All other product and service names mentioned are the trademarks of their respective companies. Data contained in this
document serves informational purposes only. National product specifications may vary.
These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies
("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be
liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are
those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing
herein should be construed as constituting an additional warranty.
Copyright/Trademark
Table of Contents
Consuming SAP NetWeaver Gateway Services on .Net Applications .......................................................... 4
Prerequisites ................................................................................................................................................................. 5
Building a .NET Application ........................................................................................................................................ 6
Function Import Example ....................................................................................................................................... 6
Read Example ......................................................................................................................................................... 9
Create Example ....................................................................................................................................................... 9
Creation of Request Body for Create Method:.................................................................................................. 11
Authentication Using X.509 Certificate ................................................................................................................... 12
Prerequisites .......................................................................................................................................................... 12
Obtaining the Client Certificate from the X509 Store ....................................................................................... 12
Read Example using X.509 ................................................................................................................................. 13
Appendix 1 - RMTSAMPLEFLIGHT Service Metadata Description ...............................................................14
Appendix 2 Code Snippets ...............................................................................................................................20
Read - Get Carrier by Carrier ID.............................................................................................................................. 20
Function Import .......................................................................................................................................................... 21
Create - Booking a Flight .......................................................................................................................................... 22
Copyright/Trademark
http://<Gateway_host>:<Gateway_port>/sap/opu/sdata/iwfnd/RMTSAMPLEFLIGHT/
http://<Gateway_host>:<Gateway_port>/sap/opu/sdata/iwfnd/RMTSAMPLEFLIGHT/
$metadata?$format=xml
To obtain information on the selected service (its properties, function imports, associations, etc.), refer to
Appendix 1, were we show the Metadata description of the RMTSAMPLEFLIGHT service.
To view the code snippets in a format that can be copied into new code, refer to Appendix 2.
Copyright/Trademark
URL
http://<Gateway_host>:<Gateway_port>/sap/opu/
sdata/iwfnd/RMTSAMPLEFLIGHT/FlightCollection
http://<Gateway_host>:<Gateway_port>/sap/opu/
sdata/iwfnd/RMTSAMPLEFLIGHT/CarrierCollection
http://<Gateway_host>:<Gateway_port>/sap/opu/
sdata/iwfnd/RMTSAMPLEFLIGHT/BookingCollection
The operation GetAvailableFlights on FlightCollection is used to get a list of flights. The following is the URL
for the same:
http://<Gateway_host>:<Gateway_port>/sap/opu/sdata/iwfnd/RMTSAMPLEFLIGHT/GetAvailableFlights?
Each collection supports some or all of the operations listed below. The table below provides the list of
operations supported and the methods that each of this operations map to respectively:
Operation
Method
Create
HTTP POST
Read
GET
Update
PUT
Delete
DELETE
Prerequisites
The following tools are required for developing a .NET application:
Software
Version
2.0
.NET
Operating System
Runtime environment
.NET 4.0
Contact your system administrator for landscape details to connect to the SAP NetWeaver Gateway system.
Copyright/Trademark
using RMTSAMPLEFLIGHT;
using System.Net;
using System.Web;
using System.Collections.Specialized;
b) Set the values for all Function Import parameters in the NameValueCollection object.
NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(String.Empty);
nameValueCollection["cityfrom"] = "NEW YORK";
nameValueCollection["cityto"] = "SAN FRANCISCO";
Copyright/Trademark
nameValueCollection["fromdate"] = "20110727";
nameValueCollection["todate"] = "20110728";
string relativeUri = functionImportName + "?" + string.Join("&",
Array.ConvertAll(nameValueCollection.AllKeys, key => string.Format("{0}={1}",
HttpUtility.UrlEncode(key), HttpUtility.UrlEncode(nameValueCollection[key]))));
Uri uri = new Uri(relativeUri, UriKind.Relative);
c) Execute the call to the Function Import and save the result.
var result = service.Execute<Flight>(uri);
Response
<?xml version="1.0" encoding="utf-8" ?>
- <atom:feed xml:base="<Gateway_Host>:<Gateway_Port>/sap/opu/sdata/iwfnd/RMTSAMPLEFLIGHT/"
xmlns:atom="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns:sap="http://www.sap.com/Protocols/SAPData">
<atom:id>http://<host name>:<port>/sap/opu/sdata/iwfnd/RMTSAMPLEFLIGHT/FlightCollection</atom:id>
<atom:link href="FlightCollection" rel="self" type="application/atom+xml;type=feed" title="FlightCollection"
/>
<atom:title>FlightCollection</atom:title>
<atom:updated>2011-09-27T06:32:42Z</atom:updated>
- <atom:entry>
<atom:author />
- <atom:content type="application/xml">
- <m:properties>
<d:carrid>AA</d:carrid>
<d:connid>0017</d:connid>
<d:fldate m:Type="Edm.DateTime">2011-01-05T00:00:00</d:fldate>
<d:PRICE m:Type="Edm.Decimal">889.00</d:PRICE>
<d:CURRENCY>USD</d:CURRENCY>
<d:PLANETYPE>747-400</d:PLANETYPE>
<d:SEATSMAX>385</d:SEATSMAX>
<d:SEATSOCC>367</d:SEATSOCC>
<d:PAYMENTSUM m:Type="Edm.Decimal">185742.73</d:PAYMENTSUM>
<d:SEATSMAX_B>31</d:SEATSMAX_B>
<d:SEATSOCC_B>22</d:SEATSOCC_B>
<d:SEATSMAX_F>21</d:SEATSMAX_F>
<d:SEATSOCC_F>21</d:SEATSOCC_F>
- <d:flightDetails>
<d:countryFrom>US</d:countryFrom>
<d:cityFrom>new york</d:cityFrom>
<d:airportFrom>JFK</d:airportFrom>
<d:countryTo>US</d:countryTo>
<d:cityTo>SAN FRANCISCO</d:cityTo>
<d:airportTo>SFO</d:airportTo>
<d:flightTime>361</d:flightTime>
<d:departureTime m:Type="Edm.Time">PT11H00M00S</d:departureTime>
<d:arrivalTime m:Type="Edm.Time">PT14H01M00S</d:arrivalTime>
<d:distance m:Type="Edm.Decimal">2574.0000</d:distance>
<d:distanceUnit>SMI</d:distanceUnit>
<d:flightType />
Copyright/Trademark
<d:period m:Type="Edm.Byte">0</d:period>
</d:flightDetails>
</m:properties>
</atom:content>
<atom:id>http://<Gateway_Host>:<Gateway_Port>/sap/opu/sdata/iwfnd/RMTSAMPLEFLIGHT/FlightCollection(carrid='AA',conn
id='0017',fldate='20110105')</atom:id>
<atom:link href="FlightCollection(carrid='AA',connid='0017',fldate='20110105')" rel="edit"
type="application/atom+xml;type=entry" />
<atom:link href="FlightCollection(carrid='AA',connid='0017',fldate='20110105')/flightbooking"
rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/flightbooking"
type="application/atom+xml;type=entry" title="RMTSAMPLEFLIGHT.BookingFlight" />
<atom:link href="FlightCollection(carrid='AA',connid='0017',fldate='20110105')/flightBookings"
rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/flightBookings"
type="application/atom+xml;type=feed" title="RMTSAMPLEFLIGHT.FlightBookings" />
<atom:link href="FlightCollection(carrid='AA',connid='0017',fldate='20110105')/FlightCarrier"
rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FlightCarrier"
type="application/atom+xml;type=entry" title="RMTSAMPLEFLIGHT.CarrierToFlight" />
<atom:title>Flight</atom:title>
<atom:updated>2011-09-27T06:32:42Z</atom:updated>
</atom:entry>
- <atom:entry>
<atom:author />
- <atom:content type="application/xml">
- <m:properties>
<d:carrid>AA</d:carrid>
<d:connid>0017</d:connid>
<d:fldate m:Type="Edm.DateTime">2011-03-16T00:00:00</d:fldate>
<d:PRICE m:Type="Edm.Decimal">422.94</d:PRICE>
<d:CURRENCY>USD</d:CURRENCY>
<d:PLANETYPE>747-400</d:PLANETYPE>
<d:SEATSMAX>385</d:SEATSMAX>
<d:SEATSOCC>371</d:SEATSOCC>
<d:PAYMENTSUM m:Type="Edm.Decimal">192129.22</d:PAYMENTSUM>
<d:SEATSMAX_B>31</d:SEATSMAX_B>
<d:SEATSOCC_B>30</d:SEATSOCC_B>
<d:SEATSMAX_F>21</d:SEATSMAX_F>
<d:SEATSOCC_F>20</d:SEATSOCC_F>
- <d:flightDetails>
<d:countryFrom>US</d:countryFrom>
<d:cityFrom>new york</d:cityFrom>
<d:airportFrom>JFK</d:airportFrom>
<d:countryTo>US</d:countryTo>
<d:cityTo>SAN FRANCISCO</d:cityTo>
<d:airportTo>SFO</d:airportTo>
<d:flightTime>361</d:flightTime>
<d:departureTime m:Type="Edm.Time">PT11H00M00S</d:departureTime>
<d:arrivalTime m:Type="Edm.Time">PT14H01M00S</d:arrivalTime>
<d:distance m:Type="Edm.Decimal">2574.0000</d:distance>
<d:distanceUnit>SMI</d:distanceUnit>
<d:flightType />
<d:period m:Type="Edm.Byte">0</d:period>
</d:flightDetails>
</m:properties>
</atom:content>
<atom:id>http://<Gateway_Host>:<Gateway_Port>/sap/opu/sdata/iwfnd/RMTSAMPLEFLIGHT/FlightCollection(carrid='AA',conn
id='0017',fldate='20110316')</atom:id>
<atom:link href="FlightCollection(carrid='AA',connid='0017',fldate='20110316')" rel="edit"
type="application/atom+xml;type=entry" />
<atom:link href="FlightCollection(carrid='AA',connid='0017',fldate='20110316')/flightbooking"
rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/flightbooking"
type="application/atom+xml;type=entry" title="RMTSAMPLEFLIGHT.BookingFlight" />
<atom:link href="FlightCollection(carrid='AA',connid='0017',fldate='20110316')/flightBookings"
rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/flightBookings"
type="application/atom+xml;type=feed" title="RMTSAMPLEFLIGHT.FlightBookings" />
<atom:link href="FlightCollection(carrid='AA',connid='0017',fldate='20110316')/FlightCarrier"
rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FlightCarrier"
type="application/atom+xml;type=entry" title="RMTSAMPLEFLIGHT.CarrierToFlight" />
<atom:title>Flight</atom:title>
<atom:updated>2011-09-27T06:32:42Z</atom:updated>
</atom:entry>
Copyright/Trademark
Read Example
To read the carrier details, you must call the CarrierCollection using the Carrier ID parameter.
Refer to the code snippet below for details on how to do it from a .Net application:
1. Use the following method for getting Carrier information from the carrierId parameter.
private static void GetCarrierByID()
{
5. Execute the query below to the service to retrieve the carrier and save the result.
var carrier = (from Carrier c in service.CarrierCollection
where c.carrid == carrierId
select c).FirstOrDefault();
ID = {0}",carrier.carrid));
Name = {0}",carrier.CARRNAME));
Code = {0}",carrier.CURRCODE));
URL = {0}",carrier.URL));
Response
<?xml version="1.0" encoding="utf-8" ?>
- <atom:entry xml:base="<Gateway_Host>:<Gateway_Port>/sap/opu/sdata/iwfnd/RMTSAMPLEFLIGHT/"
xmlns:atom="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns:sap="http://www.sap.com/Protocols/SAPData">
<atom:author />
<atom:content src="http://www.aa.com" />
- <m:properties>
<d:carrid>AA</d:carrid>
<d:CARRNAME>American Airlines</d:CARRNAME>
<d:CURRCODE>USD</d:CURRCODE>
<d:URL>http://www.aa.com</d:URL>
<d:mimeType />
</m:properties>
<atom:id><Gateway_Host>:<Gateway_Port>/sap/opu/sdata/iwfnd/RMTSAMPLEFLIGHT/CarrierCollection(carrid='AA')</atom:i
d>
<atom:link href="CarrierCollection(carrid='AA')" rel="self" type="application/atom+xml;type=entry" />
<atom:link href="CarrierCollection(carrid='AA')/carrierFlights"
rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/carrierFlights"
type="application/atom+xml;type=feed" title="RMTSAMPLEFLIGHT.CarrierToFlight" />
<atom:title>Carrier</atom:title>
<atom:updated>2011-09-27T10:00:38Z</atom:updated>
</atom:entry>
Copyright/Trademark
Create Example
To book a Flight, trigger HTTP POST method on the Booking Collection (with the Booking details in the
request body). Check for the HTTP response code. If the response code is 201, then the HTTP-POST is
successful. The response contains the newly created Booking ID in the bookid field, as well as the entire
information that was part of the request body.
Refer to the code snippet below for details on how to invoke a create request from a .NET application:
1. Use the following method for booking a flight.
private static void CreateFlightBooking()
{
Copyright/Trademark
Copyright/Trademark
Store the X.509 Client Certificate in the X509 Store under the Current User section.
The X509 Store can be accessed in Windows using the Certificates snap-in available in the Microsoft
Management Console (MMC). For further information, refer to http://msdn.microsoft.com/enus/library/ms788967.aspx
2. Select My Certificate Store and the Current User section in the store.
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
Copyright/Trademark
4. Add a delegate that will execute right before the request is sent to the service. In this delegate, add the
Client certificate to the outgoing request.
service.SendingRequest += (s, e) =>
{
string certificateSubject = "<User Certificate Subject>";
X509Certificate2 certificate =
GetCertificateFromX509Store(certificateSubject);
// Attach the client certificate to the request
((HttpWebRequest)e.Request).ClientCertificates.Add(certificate);
};
5. Execute the query below to the service to retrieve the carrier and save the result.
var carrier = (from Carrier c in service.CarrierCollection
where c.carrid == carrierId
select c).FirstOrDefault();
ID = {0}",carrier.carrid));
Name = {0}",carrier.CARRNAME));
Code = {0}",carrier.CURRCODE));
URL = {0}",carrier.URL));
Copyright/Trademark
Copyright/Trademark
Copyright/Trademark
Copyright/Trademark
Copyright/Trademark
<PropertyRef Name="connid"/>
<PropertyRef Name="fldate"/>
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="CarrierToFlight" sap:content-version="1">
<End Type="RMTSAMPLEFLIGHT.Carrier" Multiplicity="1" Role="FromRole_Carrier_Flight"/>
<End Type="RMTSAMPLEFLIGHT.Flight" Multiplicity="*" Role="ToRole_Flight_Carrier"/>
</Association>
<EntityContainer Name="RMTSAMPLEFLIGHT" m:IsDefaultEntityContainer="true">
<EntitySet Name="SubscriptionCollection" EntityType="RMTSAMPLEFLIGHT.Subscription"
sap:content-version="1"/>
<EntitySet Name="NotificationCollection" EntityType="RMTSAMPLEFLIGHT.Notification"
sap:content-version="1"/>
<EntitySet Name="FlightCollection" EntityType="RMTSAMPLEFLIGHT.Flight" sap:contentversion="1"/>
<EntitySet Name="BookingCollection" EntityType="RMTSAMPLEFLIGHT.Booking" sap:contentversion="1" sap:semantics="FLIGHT_BOOKING"/>
<EntitySet Name="CarrierCollection" EntityType="RMTSAMPLEFLIGHT.Carrier" sap:contentversion="1" sap:creatable="false" sap:updatable="false" sap:deletable="false"/>
<EntitySet Name="TravelagencyCollection" EntityType="RMTSAMPLEFLIGHT.Travelagency"
sap:content-version="1" sap:searchable="true"/>
<EntitySet Name="TravelAgencies" EntityType="RMTSAMPLEFLIGHT.Travelagency" sap:contentversion="1" sap:searchable="true"/>
<AssociationSet Name="AssocSet_FlightBookings"
Association="RMTSAMPLEFLIGHT.FlightBookings" sap:content-version="1">
<End EntitySet="FlightCollection" Role="FromRole_Flight_Booking"/>
<End EntitySet="BookingCollection" Role="ToRole_Booking_Flight"/>
</AssociationSet>
<AssociationSet Name="AssocSet_BookingFlight" Association="RMTSAMPLEFLIGHT.BookingFlight"
sap:content-version="1">
<End EntitySet="FlightCollection" Role="FromRole_Flight_Booking"/>
<End EntitySet="BookingCollection" Role="ToRole_Booking_Flight"/>
</AssociationSet>
<AssociationSet Name="AssocSet_CarrierToFlight"
Association="RMTSAMPLEFLIGHT.CarrierToFlight" sap:content-version="1"
sap:creatable="false" sap:updatable="false" sap:deletable="false">
<End EntitySet="CarrierCollection" Role="FromRole_Carrier_Flight"/>
<End EntitySet="FlightCollection" Role="ToRole_Flight_Carrier"/>
</AssociationSet>
<FunctionImport Name="CheckFlightAvailability"
ReturnType="RMTSAMPLEFLIGHT.FlightAvailability" m:HttpMethod="GET" sap:actionfor="RMTSAMPLEFLIGHT.Flight">
<Parameter Name="airlineid" Type="Edm.String" Mode="In">
<Documentation>
<Summary/>
<LongDescription>Airline</LongDescription>
</Documentation>
</Parameter>
<Parameter Name="connectionid" Type="Edm.String" Mode="In">
<Documentation>
<Summary/>
<LongDescription>Flight Number</LongDescription>
</Documentation>
</Parameter>
<Parameter Name="flightdate" Type="Edm.DateTime" Mode="In">
<Documentation>
<Summary/>
<LongDescription>Date</LongDescription>
</Documentation>
</Parameter>
</FunctionImport>
Copyright/Trademark
<FunctionImport Name="GetAvailableFlights"
ReturnType="Collection(RMTSAMPLEFLIGHT.Flight)" EntitySet="FlightCollection"
m:HttpMethod="POST">
<Parameter Name="fromdate" Type="Edm.DateTime" Mode="In">
<Documentation>
<Summary/>
<LongDescription>Date</LongDescription>
</Documentation>
</Parameter>
<Parameter Name="todate" Type="Edm.DateTime" Mode="In">
<Documentation>
<Summary/>
<LongDescription>Date</LongDescription>
</Documentation>
</Parameter>
<Parameter Name="cityfrom" Type="Edm.String" Mode="In">
<Documentation>
<Summary/>
<LongDescription>Depart.city</LongDescription>
</Documentation>
</Parameter>
<Parameter Name="cityto" Type="Edm.String" Mode="In">
<Documentation>
<Summary/>
<LongDescription>Arrival city</LongDescription>
</Documentation>
</Parameter>
</FunctionImport>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Copyright/Trademark
/******************************************************************************
*
Execute the Query to the service to retrieve the carrier
******************************************************************************/
var carrier = (from Carrier c in service.CarrierCollection
where c.carrid == carrierId
select c).FirstOrDefault();
/******************************************************************************
*
Using the returned value
******************************************************************************/
Console.WriteLine(String.Format("Carrier ID = {0}",carrier.carrid));
Console.WriteLine(String.Format("Carrier Name = {0}",carrier.CARRNAME));
Console.WriteLine(String.Format("Carrier Code = {0}",carrier.CURRCODE));
Console.WriteLine(String.Format("Carrier URL = {0}",carrier.URL));
}
Copyright/Trademark
Function Import
/// <summary>
/// Method for executing a Function Import that returns a collection of
/// flights.
/// provide source city, destination city and date as input -> gets available /// flights
/// </summary>
private static void GetAvailableFlights()
{
/******************************************************************************
*
Connection to the service
******************************************************************************/
string serviceUrl =
"http://<Gateway_Host>:<Gateway_Port>/sap/opu/sdata/iwfnd/RMTSAMPLEFLIGHT/";
RMTSAMPLEFLIGHT.RMTSAMPLEFLIGHT service = new RMTSAMPLEFLIGHT.RMTSAMPLEFLIGHT(new
Uri(serviceUrl));
service.Credentials = new NetworkCredential(username, password);
/******************************************************************************
*
Function Import Construction
******************************************************************************/
// name of the function import we would like to call
string functionImportName = "GetAvailableFlights";
// set the values of all parameters that the function import receives in a
NameValueCollection
NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(String.Empty);
nameValueCollection["cityfrom"] = "NEW YORK";
nameValueCollection["cityto"] = "SAN FRANCISCO";
nameValueCollection["fromdate"] = "20110727";
nameValueCollection["todate"] = "20110728";
string relativeUri = functionImportName + "?" + string.Join("&",
Array.ConvertAll(nameValueCollection.AllKeys, key => string.Format("{0}={1}",
HttpUtility.UrlEncode(key), HttpUtility.UrlEncode(nameValueCollection[key]))));
Uri uri = new Uri(relativeUri, UriKind.Relative);
/******************************************************************************
*
Executing the call to the Function Import
******************************************************************************
var result = service.Execute<Flight>(uri);
/******************************************************************************
*
Using the returned collection
******************************************************************************/
foreach (Flight flight in result)
{
Console.WriteLine("---------------------------------------");
Console.WriteLine("Flight carrier = " + flight.carrid);
Console.WriteLine("Flight price = " + flight.PRICE);
Console.WriteLine("Flight seatmax = " + flight.SEATSMAX);
}
}
Copyright/Trademark
Copyright/Trademark