首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >复制EndPoint,但我看不见

复制EndPoint,但我看不见
EN

Stack Overflow用户
提问于 2014-07-28 18:15:29
回答 1查看 313关注 0票数 0

我有一个网络服务。

这是我的web配置的一部分:

代码语言:javascript
复制
<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>

这是我的服务:

代码语言:javascript
复制
public void DoWork(Stream image)
{
    var img = System.Drawing.Bitmap.FromStream(image);
}

这是我的界面:

代码语言:javascript
复制
[OperationContract(IsOneWay = true)]
void DoWork(Stream image);

这是我的客户:

代码语言:javascript
复制
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‘的端点配置部分,因为找到了该契约的多个端点配置。请按名称指定首选端点配置部分。

这是我的堆栈错误:

在System.ServiceModel.Description.ConfigLoader.LookupChannel(ContextInformation configurationContext,String configurationName,ContractDescription契约,EndpointAddress地址,布尔通配符,布尔值useChannelElementKind,ServiceEndpoint& 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,configurationName契约) at System.ServiceModel.ChannelFactory.InitializeEndpoint(String,System.ServiceModel.ConfigurationEndpointTrait1.CreateSimplexFactory() at System.ServiceModel.ConfigurationEndpointTrait1.CreateChannelFactory() at System.ServiceModel.ClientBase1.CreateChannelFactoryRef(EndpointTrait1 endpointTrait) System.ServiceModel.ClientBase1.InitializeChannelFactoryRef() at System.ServiceModel.ClientBase1..ctor() at LiteEdition.wsSyncFastest.Sync2Client..ctor() in g:\dev20140604\LiteEdition\LiteEdition\Service References\wsSyncFastest\Reference.cs:line 51 at LiteEdition.StartUp.button1_Click(对象发送者,EventArgs e) ( g:\dev20140604\LiteEdition\LiteEdition\StartUp.cs:line 2646 )

我看不到任何问题,但很明显是有问题的。

有人能帮忙吗?

补充:

我的客户app.config:

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-28 21:08:35

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

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

代码语言:javascript
复制
wsSyncFastest.Sync2Client client = new wsSyncFastest.Sync2Client("BasicHttpBinding_ISync2");

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

代码语言:javascript
复制
wsSyncFastest.Sync2Client client = new wsSyncFastest.Sync2Client("NetTcpBinding_ISync2");
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25001634

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档