我有一个网络服务。
这是我的web配置的一部分:
<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‘的端点配置部分,因为找到了该契约的多个端点配置。请按名称指定首选端点配置部分。
这是我的堆栈错误:
在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:
<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>发布于 2014-07-28 21:08:35
在创建代理对象时,尝试传递端点的名称,并查看是否修复了它。
如果您打算使用basicHttpBinding,它将是:
wsSyncFastest.Sync2Client client = new wsSyncFastest.Sync2Client("BasicHttpBinding_ISync2");如果您打算使用netTcpBinding,它将是:
wsSyncFastest.Sync2Client client = new wsSyncFastest.Sync2Client("NetTcpBinding_ISync2");https://stackoverflow.com/questions/25001634
复制相似问题