重复EndPoint但我看不到它

时间:2014-07-28 18:15:29

标签: wcf wcf-binding

我有一个网络服务。

这是(我的一部分)我的网络配置:

<system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="LicensedBehaviour">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
        <behavior name="NetTCPBehaviour">
          <serviceTimeouts transactionTimeout="0.00:00:30" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <dataContractSerializer maxItemsInObjectGraph="65536" />
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="License" behaviorConfiguration="LicensedBehaviour">
        <endpoint address="License.svc" binding="basicHttpBinding" bindingConfiguration="NormalHttpBindingEndPoint" contract="ILicense" name="wsLicense" />
      </service>
      <service name="testme" behaviorConfiguration="NetTCPBehaviour">
        <endpoint  address="net.tcp://localhost:808/Sync2.svc" binding="netTcpBinding" contract="ISync2" name="wsMotionUploader" bindingConfiguration="NetTCPBindingEndPoint"/>
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="NormalHttpBindingEndPoint" closeTimeout="00:02:00" openTimeout="00:02:00">
          <readerQuotas maxArrayLength="32768" maxStringContentLength="2147483647" />
        </binding>
      </basicHttpBinding>
      <netTcpBinding>
        <binding  name="NetTCPBindingEndPoint" receiveTimeout="00:15:00" sendTimeout="00:15:00" transferMode="Streamed" closeTimeout="00:02:00" openTimeout="00:02:00" 
            maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
          <readerQuotas maxArrayLength="32768" />
          <security mode="None">
            <transport clientCredentialType="None" protectionLevel="None" />
            <message clientCredentialType="None" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

这是我的服务:

public void DoWork(Stream image)
{
    var img = System.Drawing.Bitmap.FromStream(image);
}

这是我的界面:

[OperationContract(IsOneWay = true)]
void DoWork(Stream image);

这是我的客户:

wsSyncFastest.Sync2Client client = new wsSyncFastest.Sync2Client();
using (Bitmap bmp = new Bitmap("d:\\bf.jpg"))
{
    using (MemoryStream ms = new MemoryStream())
    {
         bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
         client.DoWork(ms);
         ms.Close();
    }
}

这是我的错误讯息: 合同的端点配置部分&wsSyncFastest.ISync2&#39;无法加载,因为找到了该合同的多个端点配置。请按名称指明首选端点配置部分。

这是我的堆栈错误:

at System.ServiceModel.Description.ConfigLoader.LookupChannel(ContextInformation configurationContext,String configurationName,ContractDescription contract,EndpointAddress address,Boolean wildcard,Boolean useChannelElementKind,ServiceEndpoint&amp; serviceEndpoint)    at System.ServiceModel.Description.ConfigLoader.LookupEndpoint(String configurationName,EndpointAddress address,ContractDescription contract,ContextInformation configurationContext)    at System.ServiceModel.Description.ConfigLoader.LookupEndpoint(String configurationName,EndpointAddress address,ContractDescription contract)    at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName,EndpointAddress address)    在System.ServiceModel.ChannelFactory 1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress) at System.ServiceModel.ChannelFactory 1..ctor(String endpointConfigurationName)    在System.ServiceModel.ConfigurationEndpointTrait 1.CreateSimplexFactory() at System.ServiceModel.ConfigurationEndpointTrait 1.CreateChannelFactory()    在System.ServiceModel.ClientBase 1.CreateChannelFactoryRef(EndpointTrait 1 endpointTrait)    在System.ServiceModel.ClientBase 1.InitializeChannelFactoryRef() at System.ServiceModel.ClientBase 1..ctor()    at LiteEdition.wsSyncFastest.Sync2Client..ctor()in g:\ dev20140604 \ LiteEdition \ LiteEdition \ Service References \ wsSyncFastest \ Reference.cs:第51行    at LiteEdition.StartUp.button1_Click(Object sender,EventArgs e)在g:\ dev20140604 \ LiteEdition \ LiteEdition \ StartUp.cs:第2646行

我看不到任何问题,但显然有。

有人可以帮忙吗?

附加:

我的客户端app.config:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="wsLicense" />
            <binding name="BasicHttpBinding_ISync2" />
        </basicHttpBinding>
        <netTcpBinding>
            <binding name="NetTcpBinding_ISync2" />
        </netTcpBinding>
    </bindings>
    <client>
        <endpoint address="http://aurl/License.svc/License.svc"
            binding="basicHttpBinding" bindingConfiguration="wsLicense"
            contract="wsLicense.ILicense" name="wsLicense" />
        <endpoint address="http://www.informedmotion.co.uk/Sync2.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISync2"
            contract="wsSyncFastest.ISync2" name="BasicHttpBinding_ISync2" />
        <endpoint address="net.tcp://dsvr019492/Sync2.svc" binding="netTcpBinding"
            bindingConfiguration="NetTcpBinding_ISync2" contract="wsSyncFastest.ISync2"
            name="NetTcpBinding_ISync2">
            <identity>
                <servicePrincipalName value="host/DSVR019492" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

1 个答案:

答案 0 :(得分:1)

尝试在创建代理对象时传递端点名称,看看是否修复了它。

如果您打算使用basicHttpBinding,它将是:

wsSyncFastest.Sync2Client client = new wsSyncFastest.Sync2Client("BasicHttpBinding_ISync2");

如果您打算使用netTcpBinding,它将是:

wsSyncFastest.Sync2Client client = new wsSyncFastest.Sync2Client("NetTcpBinding_ISync2");