----------clientProxy------------------
class CarRentalPrxoxy:ClientBase<IRental>,IRental
{
public CarRentalPrxoxy()
:base("RentalServiceEndPoint")
{
}
#region IRental 成员
public string RegisterCarRental(RentalRegistraction rentalRegistraction)
{
return Channel.RegisterCarRental(rentalRegistraction);
}
public void RegisterCarRentalAsPaid(string rentalID)
{
Channel.RegisterCarRentalAsPaid(rentalID);
}
public void StartCarRental(string rentalID)
{
Channel.StartCarRental(rentalID);
}
public void StopCarRental(string rentalID)
{
Channel.StopCarRental(rentalID);
}
public RentalRegistraction GetRentalRegsitration(string rentalID)
{
return Channel.GetRentalRegsitration(rentalID);
}
#endregion
}
-------------Client.Config-----------------------
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<client>
<endpoint name="RentalServiceEndPoint" address="http://localhost:9876/RentalService" binding="wsHttpBinding" contract="RentalInterface.IRental" >
</endpoint>
</client>
</system.serviceModel>
</configuration>
--------------client.cs------------------------------------
CarRentalPrxoxy proxy = new CarRentalPrxoxy();
RentalRegistraction registraction = new RentalRegistraction();
registraction.CarID = "JF00000";
registraction.Comments = "备注";
registraction.CustomerID = 1;
registraction.DropOffDateTime = DateTime.Now;
registraction.DropOffLocation = -1;
string result = proxy.RegisterCarRental(registraction);
MessageBox.Show(result);