无法在 WCF 中创建代理对象

发布于 2024-11-07 11:49:13 字数 2199 浏览 1 评论 0原文

我通过以下链接使用 WCF 服务:

http://www. paymentsgateway。 com/developerDocumentation/Integration/webservices/merchantservice.aspx#authentication

现在,如果您向下滚动此链接,他们会给出如何创建的示例客户:

    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:

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 :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陈甜 2024-11-14 11:49:13

如果您点击示例源的链接:

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 文件,您会看到调用了客户端:

.....yournamespace.....ClientService.ClientServiceClient

服务名称是命名空间,所以我认为你可能需要:

 .....yournamespace.....PaymentsAuthClient.ClientServiceClient

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文