C#调用 Sap Byd Soap 接口文件 WSDL
一.Web 引用模式
1.添加服务引用
2.调用方法
static void Main(string[] args)
Console.ReadKey();
{
Pii.service client =new Pii.service();
client.Credentials = new NetworkCredential("_BYDTOECC", "Welcome1");//身份验证 用户名 密码
//Do 调用方法
client.QueryByElements(new ProductInformationIntegrationpiiQueryByElementsSimpleByRequestMessage_sync());
}
二.服务引用模式
1.添加引用
2.调用函数
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));}