【发布时间】:2020-10-03 02:18:13
【问题描述】:
我正在尝试创建一个肥皂网络服务,该服务将有一个网络方法,该方法将名称作为输入,并将通过 HTTPS 返回“hello”+name,并且需要添加一些证书才能被调用。
我在 IIS 中创建了一个自签名证书,并添加了与证书的 HTTPS 绑定。我已经在默认网站下添加了我的应用程序并在其上启用了 SSL。
在 Visual Studio 中,我创建了 WCF 服务应用程序,并在其上启用了 SSL。添加了在类中仅包含一种方法的 asmx 文件。这是代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace POCSoap
{
[WebService(Namespace = "https://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld(string name)
{
return "Hello "+name;
}
}
}
我也在 web.config 中添加了绑定和服务声明。
<services>
<service name="POCSoap.Service1">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="secureHttpBinding"
contract="POCSoap.IService1"/>
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
仍然,通过 http 调用是有效的,通过 https 调用是无效的。这里缺少什么。
【问题讨论】:
-
定义“不工作”。添加您收到的任何错误消息。
-
@Gusman 错误:读取 ECONNRESET