标签: wcf-binding

逻辑第一,WCF安全性稍后?

我正在开发一个WCF服务,它将通过net.tcp与客户端应用程序的n个实例进行通信(由我办公室的另一个程序员开发).

目前我正在使用net.tcp而没有任何安全性,因为我觉得在这个阶段设置这个并不是必要的,至少在我们接近推出之前是这样.

在开发WCF应用程序期间,在没有安全性的情况下使用标准绑定(在我的情况下是net.tcp)是否有任何损害,那么一旦业务逻辑完成,就实现所有安全要求?是否有任何我需要注意的事项在安全实施后可能无法正常运行?

c# xml security wcf wcf-binding

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

wcf暴露泛型

我有一个客户端和服务器共享类型的应用程序,互操作性不是我们关注的问题之一.我打算为所有支持Web的对象创建一个存储库,我正在考虑为我的公开服务提供通用接口.

像T GetObject(int id)之类的东西

但是wcf不喜欢它,因为它试图暴露它的架构(我真的不关心)

是否有可能用WCF做这样的事情?,我可以使用任何类型的绑定不必是httpbinding或wsbinding ...

generics wcf wcf-binding

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

当多个服务可用时,WCF服务无法启动

我从一个exe内部运行一个WCF服务(用于调试,它将在部署时移动到Windows服务)我有一个服务在其中运行良好但是当我运行第二个服务时我得到异常

System.InvalidOperationException was unhandled
  Message=The ChannelDispatcher at 'http://backupsvr:8082/' with contract(s) '"IHttpGetHelpPageAndMetadataContract"' is unable to open its IChannelListener.
  Source=System.ServiceModel
  StackTrace:
       at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open()
       at Service.Program.Main() in E:\Visual Studio 2010\Projects\Contract Flow Suite\Service\Program.cs:line 30
  InnerException: System.InvalidOperationException
       Message=A registration already exists for URI 'http://backupsvr:8082/'.
       Source=System.ServiceModel
       StackTrace:
            at System.ServiceModel.Channels.UriPrefixTable`1.RegisterUri(Uri uri, HostNameComparisonMode hostNameComparisonMode, TItem item)
            at System.ServiceModel.Channels.HttpTransportManager.Register(TransportChannelListener channelListener)
            at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
            at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
            at System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout)
            at System.ServiceModel.Channels.HttpChannelListener.OnOpen(TimeSpan timeout)
            at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
            at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan …
Run Code Online (Sandbox Code Playgroud)

c# wcf app-config exception wcf-binding

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

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
查看次数

使用 WCF 将服务器的传输和消息签名证书作为客户端分离

我目前正在将 WCF 客户端集成到 Java Web 服务中。服务器要求客户端使用 SSL 和要签名的消息通过证书进行身份验证。

我已成功通过 SSL、Signed 等将消息发送到服务器。但是,服务器响应消息也已签名,但使用的证书与用于验证服务器的证书不同。

WCF 客户端不喜欢这种行为。它失败并显示以下消息:“传入的消息使用的令牌与用于加密正文的令牌不同。这是意料之外的。” 这里详细描述这个问题。

在 Google 上环顾四周,我发现通过实现 ClientCredentials 和其他安全相关类并添加新扩展,可以将客户端传输证书与唱歌证书分离。您可以在此处阅读有关它的所有详细信息。但是,我在弄清楚我必须在何处扩展才能在客户端模式下为服务器证书提供相同的行为时遇到了一些麻烦。

任何有关该主题或参考的帮助将不胜感激。

提前致谢。

wcf wcf-binding wcf-client wcf-security

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

使用TransportWithMessageCredential时,CredentialCache.DefaultNetworkCredentials为空

我目前正在尝试在我的wcf项目中使用TransportWithMessageCredentials和https.我已经设置了客户端和服务器安全模式="TransportWithMessageCredential"和clientCredentialType ="Windows".

当我从CredentialCache.DefaultNetworkCredentials获取凭据时,用户名,密码和域都是空的.

这些都是空的任何理由?如果它们总是空的,我会在哪里获得凭证?

如何在不提示登录的情况下将登录的用户凭据传递给服务?

客户端绑定

<basicHttpBinding>
    <binding name="ClientHttpEndpoint" closeTimeout="00:01:00"
    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:02:00"
    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
    maxBufferSize="4194304" maxBufferPoolSize="524288" maxReceivedMessageSize="4194304"
    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
    useDefaultWebProxy="true">
        <security mode="TransportWithMessageCredential">
            <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
        </security>
    </binding>
</basicHttpBinding>
Run Code Online (Sandbox Code Playgroud)

服务器绑定

<basicHttpBinding>
    <binding name="WindowsTransportCredentialBinding" maxBufferSize="524288"maxReceivedMessageSize="524288">
        <readerQuotas maxDepth="128" maxStringContentLength="1048576" />
        <security mode="TransportWithMessageCredential">
            <transport clientCredentialType="Windows" />
        </security>
    </binding>
</basicHttpBinding>

...

<service name="Test.DiagnosticService">
    <endpoint binding="basicHttpBinding" bindingConfiguration="WindowsTransportCredentialBinding" name="ClientDiagnosticEndpoint" contract="Test.IDiagnostic" />
</service>
Run Code Online (Sandbox Code Playgroud)

用于设置用户名和密码的代码

ChannelFactory<IDiagnostic> test = new ChannelFactory<IDiagnostic>(DIAGNOSTIC_ENDPOINT_NAME);
test.Credentials.UserName.UserName = "TestUser";
test.Credentials.UserName.Password = "User";
return test.CreateChannel();
Run Code Online (Sandbox Code Playgroud)

wcf wcf-binding wcf-security

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

为什么在WCF中使用LocalChannel时执行序列化?

Microsoft提供了一个名为LocalChannel的WCF示例,用于说明如何在同一ApplicationDomain中调用服务时实现自定义绑定以绕过不必要的开销.它的样本描述表明:

这对于客户端和服务在同一应用程序域中运行并且必须避免典型WCF通道堆栈(消息的序列化和反序列化)的开销的情况非常有用.

我在我的项目中使用了这个代码,但是尽管声称在调用服务时似乎发生了序列化.

为了更清楚,我已将代码更改为以下内容以使用数据协定,因此可以轻松确定是否正在执行序列化.

# region Service Contract

[ServiceContract]
public interface IGetPrice
{
    [OperationContract]
    ProductDTO GetPriceForProduct(int productCode);
}


[DataContract]
public class ProductDTO
{
    private string _price;

    public ProductDTO(string price)
    {
        _price = price;
    }

    #region Overrides of Object

    public override string ToString()
    {
        return string.Format("Price = '{0}'", _price);
    }

    #endregion

    [DataMember]
    public string Price
    {
        get { return _price; }
        set { _price = value; }
    }
}

public class GetPrice : IGetPrice
{
    #region IGetPrice Members

    public …
Run Code Online (Sandbox Code Playgroud)

.net c# wcf wcf-binding

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

如何在iis中托管net命名管道绑定启用wcf应用程序?

我的wcf服务中有以下配置

    <endpoint address="" binding="netNamedPipeBinding" 
          contract="WcfWithNamedPipe.IService1" 
          bindingConfiguration="WcfWithNamedPipe.netNamedPipeBinding">
    </endpoint>
Run Code Online (Sandbox Code Playgroud)

任何人都可以建议我如何使用netNamedPipe绑定在iis中托管这个wcf服务?

.net wcf named-pipes netnamedpipebinding wcf-binding

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

basicHttpBinding和webHttpBinding在一起

我正在使用C#和.NET Framework 4.0开发WCF服务.

我正在使用webHttpBinding这个:

[OperationContract]
[WebInvoke(Method = "POST",
    ResponseFormat = WebMessageFormat.Json,
    BodyStyle = WebMessageBodyStyle.Bare,
    UriTemplate = "filteredOrders/")]
OrderContract[] GetOrders(IdsMessage msg);

[OperationContract]
[WebInvoke(Method = "POST",
    ResponseFormat = WebMessageFormat.Json,
    BodyStyle = WebMessageBodyStyle.Bare,
    UriTemplate = "completeFilteredOrders/")]
OrderContract[] LoadCompleteFilteredOrders(IdsMessage msg);
Run Code Online (Sandbox Code Playgroud)

但现在我需要使用流式处理将图像发送到该Web服务,我需要添加basicHttpBinding它来执行此操作.

我该怎么做[OperationContract]这个使用的WCF Web服务的新手basicHttpBinding

对不起,我是WCF开发的新手.

顺便说一句,这是我的Web.config:

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="EReportService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour">
        <endpoint address="" binding="webHttpBinding" contract="EReportService.IRestServiceImpl" behaviorConfiguration="web">
        </endpoint>
      </service>
    </services>
    <bindings>
      <webHttpBinding>
        <binding maxReceivedMessageSize="2097152" maxBufferSize="2097152" transferMode="Streamed"/>
      </webHttpBinding>
    </bindings>
    <behaviors> …
Run Code Online (Sandbox Code Playgroud)

c# rest wcf soap wcf-binding

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

WCF 中的 MaxReceivedMessageSize 错误

由于我是 WCF 的新手,请帮助我。我收到此错误。我在互联网上搜索过这个问题,我有很多解决方案,但是当我应用这些解决方案时。我面临的一些新问题。所以请给我一个有效的解决方案。

已超出传入邮件的最大邮件大小配额 (65536)。要增加配额,请在适当的绑定元素上使用 MaxReceivedMessageSize 属性。

服务 Web.config 文件。

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="WSHttpBinding_IService1" maxBufferSize="2147483647"
      maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
  </basicHttpBinding>
</bindings>
<services>
  <service name="WcfServiceZone_Store.Service1" behaviorConfiguration="metadataBehavior">
    <!-- Service Endpoints -->
    <endpoint address="" binding="wsHttpBinding" contract="WcfServiceZone_Store.IService1">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="metadataBehavior">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- …
Run Code Online (Sandbox Code Playgroud)

wcf wcf-binding wcf-security wcf-data-services

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