无法在 WCF 中创建代理对象
我通过以下链接使用 WCF 服务:
现在,如果您向下滚动此链接,他们会给出如何创建的示例客户:
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);
}
}
现在我不明白这是什么:ClientServiceClient???我创建了这样的实现:
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);
}
}
我创建了一个名为 PaymentsAuthClient 的 Singleton 类,但这似乎不起作用。我在这里做错了什么???
感谢您对 adv 的帮助:)
I am using WCF service from this link:
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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您点击示例源的链接:
http:// /www. paymentsgateway.com/community/codeSamples/singlepostpage/10-05-05/C_Web_Service_Code_Sample.aspx
您会看到他们有一个 对客户端 Web 服务的服务引用,并且 ClientServiceClient 由 Visual studio 根据该引用自动生成。
他们的示例是对以下内容的服务引用:
https://sandbox. paymentsgateway.net/WS/Client.svc
如果您查看
ServiceTestClient\Service References\ClientService
文件夹中的 reference.cs 文件,您会看到调用了客户端:服务名称是命名空间,所以我认为你可能需要:
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:the service name is the namespace so I think you probably need: