简体   繁体   English

在C#中创建SOAP Webservice(wsdl)客户端

[英]Create SOAP webservice(wsdl) client in c#

I have a soap based web service which has wsdl. 我有一个基于肥皂的Web服务,其中包含wsdl。 and I have to create a windows form application client. 并且我必须创建一个Windows窗体应用程序客户端。 can someone give me a small basic client? 有人可以给我一个小的基本客户吗?

Tips: that small web service has only a method named " 提示:小型Web服务只有一种名为“

CALL(id,name,address) 通话(ID,名称,地址)

Having Drew's method in mind, 考虑到德鲁的方法,

  1. Right click on the project and select "add a service reference' and click "Advanced.." in add service reference dialog box. Then click "Add web reference" in add service reference dialog box. Input your webservice address in the address bar and click go. then rename your web reference name and click add reference. 右键单击该项目,然后选择“添加服务引用”,然后在“添加服务引用”对话框中单击“高级..”。然后在“添加服务引用”对话框中单击“添加Web引用”。在地址栏中输入您的Web服务地址,然后单击开始,然后重命名您的Web参考名称,然后单击添加参考。

(for ws security) 2.Go to the Reference.cs and change System.Web.Services.Protocols.SoapHttpClientProtocol to Microsoft.Web.Services2.WebServicesClientProtocol (You might have to add service2 by nuget) (出于ws的安全性考虑)2.转到Reference.cs,并将System.Web.Services.Protocols.SoapHttpClientProtocol更改为Microsoft.Web.Services2.WebServicesClientProtocol (您可能必须通过nuget添加service2)

  1. Before calling your webservice, add this. 在调用您的Web服务之前,添加它。

UsernameToken token = new UsernameToken("", "", PasswordOption.SendPlainText); UsernameToken令牌=新的UsernameToken(“”,“”,PasswordOption.SendPlainText); yourProxy.RequestSoapContext.Security.Tokens.Add(token); yourProxy.RequestSoapContext.Security.Tokens.Add(token);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM