Created
November 18, 2015 23:28
-
-
Save jpsingleton/38b8588e9904b69c03f2 to your computer and use it in GitHub Desktop.
SilverRail SilverCore SOAP API Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<configuration> | |
<startup> | |
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> | |
</startup> | |
<system.serviceModel> | |
<bindings> | |
<basicHttpsBinding> | |
<binding name="ShoppingServicesEndpointImplServiceSoapBinding" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000"> | |
<security mode="Transport"> | |
<transport clientCredentialType="Certificate" /> | |
</security> | |
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000" /> | |
</binding> | |
<binding name="BookingServicesEndpointImplServiceSoapBinding" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000"> | |
<security mode="Transport"> | |
<transport clientCredentialType="Certificate" /> | |
</security> | |
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000" /> | |
</binding> | |
</basicHttpsBinding> | |
</bindings> | |
<client> | |
<endpoint address="https://hacktrain.railgds.net/booking-ws/services/Booking/v2" | |
binding="basicHttpsBinding" bindingConfiguration="BookingServicesEndpointImplServiceSoapBinding" | |
contract="SilverCore.Booking" name="BookingPort" /> | |
<endpoint address="https://hacktrain.railgds.net/shopping-ws/services/Shopping/v2" | |
binding="basicHttpsBinding" bindingConfiguration="ShoppingServicesEndpointImplServiceSoapBinding" | |
contract="Shop.Shopping" name="ShoppingPort" /> | |
</client> | |
</system.serviceModel> | |
</configuration> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Security.Cryptography.X509Certificates; | |
using SilverTest.Shop; | |
namespace SilverTest { | |
class Program { | |
static void Main() { | |
// Add a service reference to https://hacktrain.railgds.net/shopping-ws/services/Shopping/v2?wsdl for shopping | |
// Add a service reference to https://hacktrain.railgds.net/booking-ws/services/Booking/v2?wsdl for booking | |
// You may need to install the client cert in a browser and download the WSDLs manually | |
var client = new ShoppingClient(); | |
if (client.ClientCredentials != null) { | |
// Make sure the cert is copied to the build output folder | |
client.ClientCredentials.ClientCertificate.Certificate = new X509Certificate2("hacktrain.pfx", "PUT PASSWORD FOR PFX FILE HERE"); | |
} | |
client.Open(); | |
var request = new PointToPointShoppingRequestType { | |
context = new ContextType { | |
distributorCode = "HACKTRAIN", | |
pointOfSaleCode = "GB", | |
Item = "CH1", | |
ItemElementName = ItemChoiceType.channelCode | |
}, | |
pointToPointShoppingQuery = new PointToPointShoppingQuery { | |
travelPointPairs = new[] { | |
new QueryTravelPointPairType { | |
originTravelPoint = | |
new TravelPointType {Value = "GBQQU", type = TravelPointTypeEnumeration.STATION}, | |
destinationTravelPoint = | |
new TravelPointType {Value = "GBQQM", type = TravelPointTypeEnumeration.STATION}, | |
departureDateTimeWindow = | |
new DateTimeWindowType { | |
date = DateTime.Now.AddDays(1), | |
time = new DateTimeWindowTypeTime {Value = DateTime.Now} | |
}, | |
} | |
}, | |
passengerSpecs = new[] { new PointToPointShoppingQueryPassengerSpec { Item = 30 } }, | |
fareFilter = PointToPointShoppingQueryFareFilter.CHEAPEST, | |
} | |
}; | |
var response = client.PointToPointShop(request); | |
foreach (var price in response.results.fareInformation.prices) { | |
Console.WriteLine(price.totalPrice.Value + " " + price.totalPrice.currency); | |
Console.WriteLine(); | |
Console.WriteLine("********************"); | |
Console.WriteLine(); | |
} | |
client.Close(); | |
Console.WriteLine("Press any key to exit..."); // which key is the any key? | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment