标签: wshttpbinding

WCF wsHttpBinding通过防火墙的有趣问题

我在互联网托管服务提供商中部署了一个Web应用程序.此Web应用程序使用部署在我公司应用程序服务器的IIS服务器上的WCF服务,以便能够访问公司的数据库,网络人员允许我出于安全原因通过防火墙公开此WCF服务.图表看起来像这样.

[主页] --->(Internet)---> |防火墙<Public IP>:<Port-X >| ---> [带WCF服务的IIS <Comp. Network Ip>:<Port-Y>]

我还想使用wsHttpBinding来利用其安全功能,并加密敏感信息.

尝试后,我收到以下错误:

异常详细信息:System.ServiceModel.EndpointNotFoundException:由于EndpointDispatcher上的AddressFilter不匹配,无法在接收方处理带有To'http://:/service/WCFService.svc'的消息.检查发送方和接收方的EndpointAddresses是否一致.

做一些研究我发现wsHttpBinding使用WS-Addressing标准,并且阅读了这个标准,我了解到SOAP标头已经增强,包括'MessageID','ReplyTo','Action'和'To'等标签.

所以我猜测,因为客户端应用程序端点指定防火墙IP地址和端口,并且服务使用与防火墙IP不同的内部网络地址进行回复,然后WS-Addressing将触发上述消息.我认为这是一个非常好的安全措施,但在我的方案中它并不是很有用.

引用WS-Addressing标准提交(http://www.w3.org/Submission/ws-addressing/)

"由于目前广泛使用的网络技术范围广泛(例如,NAT,DHCP,防火墙),许多部署无法为给定端点分配有意义的全局URI.允许这些"匿名"端点启动消息交换模式和接收回复时,WS-Addressing定义了以下众所周知的URI,供不能具有稳定,可解析的URI的端点使用 .http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous "

我如何配置我的wsHttpBinding端点来解决我的防火墙的IP并忽略或绕过SOAP消息头中"To"WS-Addressing标记中指定的地址?或者我是否必须在服务端点配置中更改某些内容?

非常感谢帮助和指导.

马尔科.

PS:虽然我找到了解决方法,但我当然使用basicHttpBinding完全没问题.

wcf firewall ws-addressing wshttpbinding

5
推荐指数
1
解决办法
7242
查看次数

WCF NetTCPBinding与HttpBinding在线上发送的数据差异

假设我有一个服务暴露两个端点,第一个是NetTCPBinding,第二个是HttpBinding的任何风格.他们都实现完全相同的服务合同.

电线上发送的内容有什么区别?

  • 使用netTcp是我的消息仍然序列化为XML?或者我的对象的二进制表示?
  • 在收到消息的方面有什么区别?http端点是否只能理解http命令(get/post等),因为nettcp端点可以理解不同的东西?
  • 为什么nettcp比http更高效(在这种情况下我不需要互操作性) - 哪里是开销?

我认为在所有情况下,在将消息放到线路上之前它将被转换为二进制文件,因此http在网络术语中也位于tcp之上 - 因此http通信需要额外的空间.

欣赏这个问题有点模糊,但希望有人会知道我想问的是什么:)

wcf basichttpbinding wcf-binding wshttpbinding nettcpbinding

5
推荐指数
1
解决办法
8334
查看次数

带有 wsHttpBinding 的 WCF 服务 - 操作 HTTP 请求标头

我一直在关注教程,以便在我的 WCF 服务中使用传输安全进行用户名身份验证。然而,本教程提到使用basicHttpBinding哪个是不可接受的 - 我需要wsHttpBinding.

这个想法是BasicAuthenticationModule对 WCF 服务进行自定义,该服务将从 HTTP 请求中读取“授权”标头并根据“授权”标头内容执行身份验证过程。问题是缺少“授权”标题!

我已IClientMessageInspector通过自定义行为实现,以便操作传出消息并添加自定义 SOAP 标头。我在BeforeSendRequest函数中添加了以下代码:

    HttpRequestMessageProperty httpRequest = request.Properties.Where(x => x.Key == "httpRequest").Single().Value;
    httpRequest.Headers.Add("CustomHeader", "CustomValue");
Run Code Online (Sandbox Code Playgroud)

这应该有效,并且根据许多网络资源,它适用于basicHttpBinding但不适用于wsHttpBinding. 当我说“有效”时,我的意思是 WCF 服务成功接收到标头。

这是在 WCF 服务端检查接收到的 HTTP 消息的简化函数:

    public void OnAuthenticateRequest(object source, EventArgs eventArgs)
    {
        HttpApplication app = (HttpApplication)source;

        //the Authorization header is checked if present
        string authHeader = app.Request.Headers["Authorization"];
        if (string.IsNullOrEmpty(authHeader))
        {
            app.Response.StatusCode = 401;
            app.Response.End();
        }
    }
Run Code Online (Sandbox Code Playgroud)

2011 …

c# wcf basic-authentication wshttpbinding http-headers

5
推荐指数
1
解决办法
2万
查看次数

如何通过负载均衡器将wsHttpBinding与Message安全性一起使用

我有一个使用Message安全性的负载均衡服务:

<wsHttpBinding>
  <binding>
    <security mode="Message">
      <message clientCredentialType="Windows" establishSecurityContext="false" />
    </security>
  </binding>
</wsHttpBinding>
Run Code Online (Sandbox Code Playgroud)

我对此服务的所有调用都会打开和关闭自己的通道,因此建立安全上下文没有任何好处.

我正在使用WSHttpBinding与服务配置匹配的服务来调用服务:

ws.Security.Mode = SecurityMode.Message;
ws.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
ws.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
ws.Security.Message.EstablishSecurityContext = false;
Run Code Online (Sandbox Code Playgroud)

这有时会起作用,但有时我会遇到诸如此类的错误

安全上下文令牌已过期或无效.邮件未处理.

要么

安全令牌请求包含无效或格式错误的元素.

我终于发现将EstablishSecurityContext设置为false实际上并不会阻止使用安全上下文令牌.我们的负载均衡器目前不使用粘性会话,我试图避免走这条路.

我确实发现我应该能够在客户端上将NegotiateServiceCredential设置为false,以允许没有粘性会话的负载均衡器.我的服务已在AD帐户下运行,我可以在WSDL中看到它:

<Upn>User@Domain</Upn>
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试将服务标识添加到我的客户端时

EndpointIDentity.CreateUpnIdentity("User@Domain")
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

不支持对在需要Kerberos多重标记的用户帐户下运行的服务进行身份验证.

如何通过负载均衡器调用我的服务?

wcf load-balancing wshttpbinding

5
推荐指数
1
解决办法
563
查看次数

通过wsHttpBinding在PHP中调用WCF WebService

我有一个WCF web服务,我可以通过basicHttp连接到它,但不是wsHttp.我尝试通过以下方式通过wshttp连接到它:

$service = new SoapClient
("http://service.companyname.local:6666/Service/?wsdl",
 array(
         "location" => "http://service.companyname.local:6666/Service/WCF",

    "trace" => true,
    'soap_version' => SOAP_1_2
     )
);
Run Code Online (Sandbox Code Playgroud)

对SoapClient构造函数的调用返回正常.当我尝试使用$ client-> FunctionName调用一个时,页面只是在那里加载了很长一段时间,并最终返回错误"Error Fetching http headers".究竟是什么意思,我该如何解决?(从.Net客户端使用该服务非常有效.)

.net php wcf wshttpbinding

4
推荐指数
1
解决办法
4095
查看次数

WCF:无法满足安全令牌请求,因为身份验证失败

我在同一台机器上有两个WCF服务.一个是出版商,一个是听众.

发布者基于和端点动态创建代理.我在这样的代码中配置代理:

            WSHttpBinding binding = new WSHttpBinding(SecurityMode.Message, true);
            binding.Security.Message.NegotiateServiceCredential = true;
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
            binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
            binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
            binding.Security.Message.EstablishSecurityContext = true;
            binding.ReliableSession.Enabled = true;
            binding.TransactionFlow = true;
            return binding;
Run Code Online (Sandbox Code Playgroud)

然后...

            Binding binding = GetBindingFromAddress(address);

            ChannelFactory<T> factory = new ChannelFactory<T>(binding);
            factory.Credentials.UserName.UserName = "an account on the machine";
            factory.Credentials.UserName.Password = "a password for that account";

            T proxy = factory.CreateChannel(new EndpointAddress(address));
Run Code Online (Sandbox Code Playgroud)

当我去打电话时,我收到上述错误.这是我的监听器配置文件:

   <service behaviorConfiguration="MEX Enabled" name="InvoiceSubscriber">
<endpoint binding="wsHttpBinding"
          bindingConfiguration="ReliableTransactionalHTTP"
          contract="AtlanticBT.SubscriptionService.Contracts.v1.IAtlanticEvents">
 <identity>
  <dns value="localhost" />
 </identity>
</endpoint>
Run Code Online (Sandbox Code Playgroud)

        <bindings>
        <wsHttpBinding>
            <binding name="ReliableTransactionalHTTP" transactionFlow="true"> …
Run Code Online (Sandbox Code Playgroud)

c# wcf wshttpbinding channelfactory .net-3.5

3
推荐指数
1
解决办法
2万
查看次数

WSHttp绑定和ReliableSession/MaxRetryCount

WSHttpBinding启用了reliableSessions的WCF中使用时,我的服务引用会将自身更新为:

<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="true">
</reliableSession>
Run Code Online (Sandbox Code Playgroud)

maxRetryCount只要将绑定配置为WSHttpBinding,我就无法将该属性添加到reliableSession.

现在我的问题是:maxRetryCount使用WSHttpBinding时的价值是什么,有没有办法在配置中改变它; 不使用CustomBinding?

wcf ws-reliablemessaging wshttpbinding

3
推荐指数
1
解决办法
6042
查看次数

WCF中超出了最大请求长度

我目前正在使用Wcf应用程序并在跟踪日志中获得上面的mentiooned错误.

下面是Wcf服务的Web.Config.

<bindings>
          <wsHttpBinding>
              <binding name="NewBinding0" closeTimeout="00:50:00" openTimeout="00:50:00" sendTimeout="00:50:00" receiveTimeout="00:50:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
                  <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                  <reliableSession enabled="true" />
                  <security mode="None">
                      <transport clientCredentialType="None" />
                      <message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="false" />
                  </security>
              </binding>
          </wsHttpBinding>
      </bindings>       

<diagnostics wmiProviderEnabled="true">
  <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<services>
  <service behaviorConfiguration="DBSyncWcfService.Service1Behavior" name="DBSyncWcfService.DBSyncService">
    <endpoint binding="wsHttpBinding" bindingConfiguration="NewBinding0" name="ABC" contract="DBSyncWcfService.IDBSyncContract" address="http://192.168.5.170:9999/" />
    <host>
      <baseAddresses>
Run Code Online (Sandbox Code Playgroud)

以下是客户端配置.

        WSHttpBinding binding = new WSHttpBinding();
        //binding.ReaderQuotas.MaxArrayLength = 10485760;

        //binding.MaxReceivedMessageSize = 10485760;
        binding.Security.Mode = SecurityMode.None;
        binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
        binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
        binding.Security.Message.EstablishSecurityContext …
Run Code Online (Sandbox Code Playgroud)

wcf wcf-binding wshttpbinding

3
推荐指数
1
解决办法
2万
查看次数

system.serviceModel/bindings/wsHttpBinding处的绑定没有配置的绑定

我正在尝试在我的WCF Web服务中创建第二个端点.我可以通过将域URL放在浏览器中来显示新端点的"快乐页面",因此我知道IIS可以正确地使用我的用户帐户找到该服务.

但是,如果我尝试运行调用该服务的网页,我将收到以下错误

The binding at system.serviceModel/bindings/wsHttpBinding does not have a configured 
binding named 'WSHttpBinding_IMonetToDss'. This is an invalid value for 
bindingConfiguration. (D:\webcontent\Monet\web.config line 178).
Run Code Online (Sandbox Code Playgroud)

由于当我创建服务引用时,Visual Studio的这一部分是由Visual Studio自动生成的,因此它的bindingConfiguration值是WSHttpBinding_IMonetToDss......它说它不应该是.

以下是从web.config中提取的两个enpoints.第一个端点/OKeeffe/OKeeffe.svc正常工作.第二个终点/OKeeffe/MonetToDss.svc是问题所在.

<client>
  <endpoint address="http://insidesoap.dev.symetra.com/Escher/EscherService.svc"
    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IEscherService"
    contract="Escher.IEscherService" name="WSHttpBinding_IEscherService" />
  <endpoint address="http://insideapps.dev.symetra.com/OKeeffe/OKeeffe.svc"
    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IAgentPayments"
    contract="AgentPayments.IAgentPayments" name="WSHttpBinding_IAgentPayments">
    <identity>
      <userPrincipalName value="s.AgentData.dev" />
    </identity>
  </endpoint>
  <endpoint address="http://insideapps.dev.symetra.com/OKeeffe/MonetToDss.svc"
    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMonetToDss"
    contract="MonetToDss.IMonetToDss" name="WSHttpBinding_IMonetToDss">
    <identity>
      <userPrincipalName value="s.AgentData.dev" />
    </identity>
  </endpoint>
</client>
Run Code Online (Sandbox Code Playgroud)

编辑

这是system.serviceModelWeb服务配置文件的一部分

  <system.serviceModel>
    <services>
        <service name="OKeeffeDataService.MonetToDss"
            behaviorConfiguration="MonetToDssBehaviors" > …
Run Code Online (Sandbox Code Playgroud)

c# wcf wshttpbinding wcf-wshttpbinding asp.net-mvc-3

3
推荐指数
1
解决办法
1万
查看次数

基于SSL的WCF服务无法使用权​​限"test-service.hostname.com"为SSL/TLS建立安全通道

我有一个问题.我们正在尝试将客户端证书附加到需要SSL的WCF服务上.当我尝试通过浏览器导航到该服务时,它将向我显示"您已经创建了一个服务页面",但只有在我附加证书时,所以我不认为它是一个IIS问题.

我已经经历了大量的堆栈溢出问题,我想每次我都取得一点进展.但是对于我的生活,我无法动摇这个问题.我添加了日志记录,这是我看到的错误:

System.Net Information: 0 : [12444] SecureChannel#15775260 - Certificate 

is of type X509Certificate2 and contains the private key.
System.Net Information: 0 : [12444] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent  = Outbound, scc     = System.Net.SecureCredential)
System.Net Error: 0 : [12444] AcquireCredentialsHandle() failed with error 0X8009030D.
System.Net Information: 0 : [12444] AcquireCredentialsHandle(package =



Microsoft Unified Security Protocol Provider, intent  = Outbound, scc     = System.Net.SecureCredential)
System.Net Error: 0 : [12444] AcquireCredentialsHandle() failed with error 0X8009030D.
System.Net.Sockets Verbose: 0 : [8000] …
Run Code Online (Sandbox Code Playgroud)

c# ssl wcf wshttpbinding wcf-wshttpbinding

2
推荐指数
1
解决办法
2万
查看次数