WebService Code Example (C#)

Framework 2.0
Framework 4.0


Framework 2.0
string FileContent = @"StockNumber,Shape,Weight,Color,Clarity" +
Environment.NewLine + "1234,Round,1.0,E,VVS1"; //CSV format

DiamondManager webServiceManager = new DiamondManager();

//This must be done in HTTPS protocol
webServiceManager.Login("myUser", "myPassword");

//After log in you will receive a encrypted ticket with your credentials. This will be used to authenticate your session.
//Now you can choose to change the protocol to HTTP so it works faster.
webServiceManager.Url = "http" + webServiceManager.Url.Substring(5);

UploadLotsParameters uploadManager = new UploadLotsParameters();

//indicates if the first row in the file contains headers
uploadManager.FirstRowHeaders = true;
uploadManager.LotList = FileContent;

//indicates the format file
uploadManager.LotListFormat = LotListFormatTypes.Rapnet;

//indicates if to replace the this upload or to add it to the existing inventory
uploadManager.ReplaceAll = true;

webServiceManager.UploadLots(uploadManager);

//get your entire inventory in RapNet
GetLotsResult lots = webServiceManager.GetLots();




Framework 4.0

//in your binding setting increacse the timeout and buffer sizes
closeTimeout="00:05:00" openTimeout="00:05:00"
receiveTimeout="00:10:00" sendTimeout="00:05:00"
maxBufferSize="65536" maxBufferPoolSize="5242880" maxReceivedMessageSize="655360"

<system.web>
  <compilation debug="false"/>
  <httpRuntime executionTimeout="2000000"/>
</system.web>


DiamondManagerSoapClient webServiceManager = new DiamondManagerSoapClient();

//This must be done in HTTPS protocol
AuthenticationTicketHeader ticket = webServiceManager.Login("myUser", "myPassword");

//After log in you will receive a encrypted ticket with your credentials. This will be used to authenticate your session.
//Now you can choose to change the protocol to HTTP so it works faster.
string oldAddress = webServiceManager.Endpoint.Address.ToString();
string newAddress = "http" + webServiceManager.Endpoint.Address.ToString().Substring(5);
System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(newAddress);
webServiceManager.Endpoint.Address = address;

UploadLotsParameters uploadManager = new UploadLotsParameters();

uploadManager.FirstRowHeaders = true;

string
fileContent = File.ReadAllText(@"FilePath\File.csv");

//indicates if the first row in the file contains headers

uploadManager.LotList = fileContent;

//indicates if to replace the this upload or to add it to the existing inventory
uploadManager.ReplaceAll = true;

UploadLotsResult ressult = webServiceManager.UploadLots(ticket,uploadManager);

//get your entire inventory in RapNet
GetLotsResult lots = webServiceManager.GetLots(ticket);