C#濡備綍瑙f瀽WSDL鏂囦欢
瑕佽В鏋怶SDL鏂囦欢锛屾偍鍙互浣跨敤.NET Framework涓殑宸ュ叿鍜岀被鏉ュ疄鐜般€備竴绉嶅父鐢ㄧ殑鏂规硶鏄娇鐢⊿ystem.Web.Services.Description鍛藉悕绌洪棿涓殑绫绘潵瑙f瀽WSDL鏂囦欢銆?/p>
浠ヤ笅鏄竴涓ず渚嬩唬鐮侊紝婕旂ず濡備綍瑙f瀽WSDL鏂囦欢锛?/p>
using System;
using System.Web.Services.Description;
using System.Xml;
class Program
{
static void Main()
{
// 鍔犺浇WSDL鏂囦欢
string wsdlUrl = "http://example.com/service?wsdl";
XmlTextReader reader = new XmlTextReader(wsdlUrl);
ServiceDescription sd = ServiceDescription.Read(reader);
// 鑾峰彇鏈嶅姟鎻忚堪
Console.WriteLine("Service name: " + sd.Services[0].Name);
Console.WriteLine("Port name: " + sd.Services[0].Ports[0].Name);
Console.WriteLine("Binding name: " + sd.Bindings[0].Name);
// 閬嶅巻鎿嶄綔
foreach (Operation operation in sd.PortTypes[0].Operations)
{
Console.WriteLine("Operation: " + operation.Name);
Console.WriteLine("Input message: " + operation.Messages.Input.Message.Name);
Console.WriteLine("Output message: " + operation.Messages.Output.Message.Name);
}
}
}
鍦ㄨ繖涓ず渚嬩腑锛屾垜浠鍏堝姞杞戒竴涓猈SDL鏂囦欢锛屽苟浣跨敤ServiceDescription绫绘潵瑙f瀽瀹冦€傜劧鍚庢垜浠緭鍑轰簡涓€浜涘熀鏈殑鏈嶅姟淇℃伅锛屽鏈嶅姟鍚嶇О銆佺鍙e悕绉板拰缁戝畾鍚嶇О銆傛渶鍚庯紝鎴戜滑閬嶅巻浜嗘瘡涓搷浣滐紝骞惰緭鍑轰簡鎿嶄綔鐨勫悕绉般€佽緭鍏ユ秷鎭拰杈撳嚭娑堟伅銆?/p>
璇锋敞鎰忥紝鎮ㄥ彲鑳介渶瑕佹牴鎹壒瀹氱殑WSDL鏂囦欢缁撴瀯鍜岄渶瑕佽繘琛岄€傚綋鐨勮皟鏁村拰澶勭悊銆?/p>
相关问答