• C# 调用 Sap Byd Soap (用户密码/证书)


    C#调用 Sap Byd Soap 接口文件 WSDL

    一.Web 引用模式

    1.添加服务引用

    image

    image

    image

    image

    2.调用方法

    static void Main(string[] args)
    {
         Pii.service client =new Pii.service();
         client.Credentials = new NetworkCredential("_BYDTOECC", "Welcome1");//身份验证 用户名 密码
         //Do 调用方法
         client.QueryByElements(new ProductInformationIntegrationpiiQueryByElementsSimpleByRequestMessage_sync());

        Console.ReadKey();
    }

     

    二.服务引用模式

    1.添加引用

    image

    image

    image

    image

    image

     

     

     

    2.调用函数

     static void Main(string[] args)
            {
                // binding 名称保存在app.Config 
                MPO.ManagePurchaseOrderInClient client = new ManagePurchaseOrderInClient("binding");
                //设置访问用户密码
                Debug.Assert(client.ClientCredentials != null, "client.ClientCredentials != null");
                client.ClientCredentials.UserName.UserName = "_TEST";
                client.ClientCredentials.UserName.Password = "Welcome00";
    
                var a = client.ManagePurchaseOrderInRead(new PurchaseOrderByIDQueryMessage_sync
                {
                    PurchaseOrder = new PurchaseOrderByIDQuery
                    {
                        ID = new[]
                            {
                                new BusinessTransactionDocumentID
                                {
                                    Value="1"
                                }
                            }
                    }
                });
                Console.WriteLine(a.ToString());
            }

    另外一种方式

      static void Main(string[] args)
         {
    
            ManageRS.Y5FWZ6LAY_ManageRSClient client=new Y5FWZ6LAY_ManageRSClient(
                 Y5FWZ6LAY_ManageRSClient.EndpointConfiguration.binding//选择 binding模式
                 );
    
            //设置身份认证模式为 基本身份认证模式
             ((BasicHttpBinding) client.Endpoint.Binding).Security.Mode = BasicHttpSecurityMode.Transport;
             ((BasicHttpBinding)client.Endpoint.Binding).Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; 
      
             //设置访问用户密码
             client.ClientCredentials.UserName.UserName = "_BYDTOECC";
             client.ClientCredentials.UserName.Password = "Welcome1";
    
    
             var a= client.QueryByElementsAsync(new RepairSummaryQueryByElementsOverviewQRYSimpleByRequestMessage_sync())
                 .Result;
             Console.WriteLine(JsonConvert.SerializeObject(a));
           
         }
    }
    

     3.使用证书调用

     static void Main(string[] args)
            {
                var basicHttpBinding = new BasicHttpsBinding
                {
                    Security =
                    {
                        Mode = BasicHttpsSecurityMode.Transport,
                        Transport = {ClientCredentialType = HttpClientCredentialType.Certificate}
                    }
                };
                Y5FWZ6LAY_ManageRSClient client = new Y5FWZ6LAY_ManageRSClient(basicHttpBinding, new EndpointAddress("https://my600232.sapbyd.cn/sap/bc/srt/scs/sap/yy5fwz6lay_managers"));
                client.ClientCredentials.ClientCertificate.Certificate = new X509Certificate2(@"c:zs.p12", "密码", X509KeyStorageFlags.UserKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
    
                Console.WriteLine(JsonConvert.SerializeObject(client
                    .QueryByElementsAsync(new RepairSummaryQueryByElementsOverviewQRYSimpleByRequestMessage_sync())
                    .Result));
            }
    

      

  • 相关阅读:
    O(big oh) (big omega) (big theta)
    Ex 7_21 在一个流网络中,一条边被称为是临界的...第十三次作业
    Ex 7_17 考虑如下的网络(其中数字为对应边的容量)...第十三次作业
    Expm 10_2 实现Ford-Fulkerson算法,求出给定图中从源点s到汇点t的最大流,并输出最小割。
    pat1009
    pat1008
    pat1007
    pat1006
    pat1005
    pat1004
  • 原文地址:https://www.cnblogs.com/hongshao/p/10532555.html
Copyright © 2020-2023  润新知