我有一个网络服务。
这是我的网络配置的一部分:
<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.ISyncc2”的终结点配置部分,因为找到了该协定的多个终结点配置。请按名称指示首选端点配置部分。
这是我的堆栈错误:
位于System.ServiceModel.Description.ConfigLoader.LookupChannel(ContextInformation configurationContext,String configurationName,ContractDescription协定,EndpointAddress地址,布尔通配符,布尔useChannelElementKind,ServiceEndpoint&ServiceEndpoint)
位于System.ServiceModel.Description.ConfigLoader.LookupEndpoint(字符串配置名称,端点地址地址,ContractDescription约定,上下文信息配置上下文)
位于System.ServiceModel.Description.ConfigLoader.LookupEndpoint(字符串配置名称,端点地址地址,ContractDescription合约)
位于System.ServiceModel.ChannelFactory.InitializeEndpoint(字符串配置名称,端点地址)
位于System.ServiceModel.ChannelFactory
1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
at System.ServiceModel.ChannelFactory
1..ctor(字符串端点配置名称)
位于System.ServiceModel.ConfigurationEndpointTrait
1.CreateSimplexFactory()
at System.ServiceModel.ConfigurationEndpointTrait
1.创建通道因子()
位于System.ServiceModel.ClientBase
1.CreateChannelFactoryRef(EndpointTrait
1个端点特性)
位于System.ServiceModel.ClientBase
1.InitializeChannelFactoryRef()
at System.ServiceModel.ClientBase
1..ctor()
在LiteEdition.wsSyncFastest.Sync2Client.ctor()中,g:\dev20140604\LiteEdition\LiteEdition \Service References\wsSyncFastest \References.cs:line 51
在LiteEdition.StartUp.button1_Click(Object sender,EventArgs e)中:\dev20140604\LiteEdition\LiteEdition \StartUp.cs:line 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>