Cannot create proxy object in WCF
I am using WCF service from this link:
http://www.paymentsgateway.com/developerDocumentation/Integration/webservices/merchantservice.aspx#authentication
Now here if you scroll down this link they have given an eg of how to create a client:
private void CreateClient(int mid)
{
ClientRecord client = new ClientRecord();
client.MerchantID = MerchantID;
client.FirstName = "Bob";
client.LastName = "Smith";
//other code describing client omitted
try
{
using (ClientServiceClient proxy = new ClientServiceClient())
{
int id = proxy.createClient(Authenticate.GetClientAuthTicket(txtID.Text.Trim(), txtKey.Text.Trim()), client);
Response.Write("Created Client ID = " + id.ToString());
}
}
catch (Exception e)
{
Response.Write(e.Message);
}
}
Now I dont understand what is this: ClientServiceClient??? I created the implementation like this:
public static PaymentsGatewayTest.Authentication GetClientAuthTicket (string APILogin, string key)
{
PaymentsGatewayTest.Authentication ticket = new PaymentsGatewayTest.Authentication();
ticket.APILoginID = APILogin;
ticket.UTCTime = DateTime.UtcNow.Ticks.ToString();
ticket.TSHash = GenerateTSHash(ticket.APILoginID + "|" + ticket.UTCTime,开发者_运维技巧 key.Trim());
return ticket;
}
private void CreateClient(int mid)
{
ClientRecord client = new ClientRecord();
client.MerchantID = 11245;
client.FirstName = "Bob";
client.LastName = "Smith";
//other code describing client omitted
try
{
using (PaymentsAuthClient proxy = new PaymentsAuthClient())
{
int id = proxy.createClient(Authenticate.GetClientAuthTicket("", "", client));
//Response.Write("Created Client ID = " + id.ToString());
}
}
catch (Exception e)
{
//Response.Write(e.Message);
}
}
I have create a Singleton class called PaymentsAuthClient, but this does not seems to work. What I am doing wrong here???
Thank you for your help in adv :)
If you follow the links to the sample source:
http://www.paymentsgateway.com/community/codeSamples/singlepostpage/10-05-05/C_Web_Service_Code_Sample.aspx
You'll see that they have a Service Reference to the client web service, and the ClientServiceClient is autogenerated by Visual studio from the reference.
Their example is a service reference to :
https://sandbox.paymentsgateway.net/WS/Client.svc
If you look in the reference.cs file in the ServiceTestClient\Service References\ClientService
folder, you'll see that that the client is called:
.....yournamespace.....ClientService.ClientServiceClient
the service name is the namespace so I think you probably need:
.....yournamespace.....PaymentsAuthClient.ClientServiceClient
精彩评论