我正在我的机器上创建一个WCF Web服务,这个盒子上有这种类型的第一个服务 我已经拥有一个运行大量SOA SSL服务的.NET 2.0企业应用程序。
我有一个内部SSL服务器权限,它为我的计算机创建了一个SSL x509证书。我还有很多由用于测试的相同证书颁发机构创建的客户端证书。所有这些证书都适用于我当前的应用程序。
我正在编写一个WCF SSL Web服务来接受纯XML消息,现在,为每个请求吐出每个HTTPHeader。
我遇到了一些问题。我让它在没有SSL的情况下工作。
当我使用WCF服务(https)时,它会下载并创建对象并正常修改app.config,它也会提示我有关服务器证书的信息。但是,当我向该WCF服务发送消息时,它会出错。
我机器上的服务网址:
https://8KZVJS1/HeaderIntercept/HeaderIntercept.svc
当我尝试提交消息时,我开始收到错误:
客户端身份验证方案“Anonymous”禁止使用HTTP请求。
我尝试修改我的app.config但是现在我只得到:
提供的URI方案“https”无效;预计'http'。 参数名称:via
更新:我做了一些编辑,现在得到:
https://8kzvjs1/headerintercept/HeaderIntercept.svc
没有可以接受该消息的端点。这通常是由错误的地址或SOAP操作引起的。有关详细信息,请参阅InnerException(如果存在)。
我需要通过一个简单的.NET客户端来实现这一点,然后推送它,以便我们可以使用Apache反向代理将原始SOAP消息传递给它。
有什么想法吗?
Windows 7 - 64位。
SSL - 不是必需的,但已接受
匿名访问 - 已启用。
配置编辑器 - system.webServer / security / access SSl,SSLNegotiateCert,SSL128已检查
WCF Web服务web.config
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpEndpointBinding">
<security>
<message clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="HeaderIntercept">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpEndpointBinding" contract="WCFServiceCertificate.IService1" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="PeerTrust"/>
</clientCertificate>
<serviceCertificate findValue="8KZVJS1" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
客户端app.config
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpEndpointBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="52428800" maxReceivedMessageSize="65536000" >
<security mode="Transport">
<transport clientCredentialType="Certificate" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Certificate" algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://8KZVJS1/HeaderIntercept/HeaderIntercept.svc"
binding="wsHttpBinding" bindingConfiguration="wsHttpEndpointBinding"
contract="HeaderIntercept.IHeaderIntercept" name="wsHttpEndpointBinding">
<identity>
<dns value="8KZVJS1"/>
</identity>
</endpoint>
</client>
</system.serviceModel>
IHeaderIntercept.cs
[ServiceContract]
public interface IHeaderIntercept
{
[OperationContract]
XElement MCCI_IN200100BC(XElement xml);
}
HeaderIntercept.svc
namespace WCF_Header_Intercept
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
// NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
public class HeaderIntercept : IHeaderIntercept
{
public XElement MCCI_IN200100BC(XElement xml)
{
StringBuilder sb = new StringBuilder();
WebHeaderCollection headers = WebOperationContext.Current.IncomingRequest.Headers;
foreach (string key in headers.Keys) {
sb.AppendLine("header " + key + "=" + headers[key]);
}
OperationContext.Current.IncomingMessageHeaders.AsParallel().ForAll(h => sb.AppendFormat("Name={0}, IsReferenceParameter={1}, MustUnderstand={2}, Namespace={3}, Relay={4}, Actor={5}.{6}", h.Name, h.IsReferenceParameter, h.MustUnderstand, h.Namespace, h.Relay, h.Actor, Environment.NewLine));
System.Diagnostics.Debug.Write(sb.ToString());
return XElement.Parse("<data>" + sb.ToString() + "</data>");
}
}
}
答案 0 :(得分:1)
想出来。在匹配我的合同时,我的web.config绑定错误。我删除了名称空间以使事情变得更简单,并使其起作用。
感谢托马斯的洞察力。希望我能够将其标记为答案:\
<强>的web.config:强>
<system.serviceModel>
<services>
<service name="HeaderIntercept" >
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpEndpointBinding" contract="IHeaderIntercept">
<identity>
<dns value="CGI-8KZVJS1"/>
</identity>
</endpoint>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="wsHttpEndpointBinding">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Certificate" algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- Add the following element to your service behavior configuration. -->
<serviceMetadata httpsGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<强>的app.config 强>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IHeaderIntercept" >
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Certificate" algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://cgi-8kzvjs1/HeaderIntercept/HeaderIntercept.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IHeaderIntercept"
contract="HeaderIntercept.IHeaderIntercept" name="WSHttpBinding_IHeaderIntercept">
<identity>
<servicePrincipalName value="host/CGI-8KZVJS1" />
</identity>
</endpoint>
</client>
</system.serviceModel>