【发布时间】:2020-04-21 18:18:45
【问题描述】:
当调用服务 url https://example.com/TestService.svc 时,我得到以下 2 个 URL,但是当我尝试点击 WSDL 时,它不起作用。
WSDL 网址
http://example.com/TestService.svc?wsdl -- 不工作
http://example.com/TestService.svc?singleWsdl -- 不工作
手动将http改为https
https://example.com/TestService.svc?wsdl -- 工作中
https://example.com/TestService.svc?singleWsdl -- 工作中
客户端配置
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</client>
<behaviors>
<serviceBehaviors>
<clear/>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="0" />
主要服务配置
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<clear />
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="0">
<serviceActivations>
<clear />
<add factory="DataServicesHost.UnityServiceHostFactory" relativeAddress="TestService.svc" service="TestService.Service" />
</serviceActivations>
</serviceHostingEnvironment>
服务消费
var customHeader = new MessageHeader<Security>(security);
var tempHeader = customHeader.GetUntypedHeader("Security", "http://tempuri.org/");
var client = new ServiceClient();
using (var scope = new OperationContextScope(client.InnerChannel))
{
OperationContext.Current.OutgoingMessageHeaders.Add(tempHeader);
objDataRequest = client.DataRequest("test");
}
【问题讨论】: