请帮助...我要疯了....我有一个wcf服务存在于几个不同的服务器上。我需要根据其中的环境动态更改我的Silverlight客户端上的端点地址。当我尝试通过代码更改地址或手动更新客户端配置文件时,我目前正在获取非常详细的404错误(讽刺)。Silverlight 3 WCF多服务器
但是,当我右键单击服务引用并转到在我的客户端上配置服务时,我可以更改地址并且它可以工作。
我有以下服务。
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="DrawingServiceBasicHttp">
<readerQuotas maxStringContentLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<service behaviorConfiguration="md" name="My.DrawingService">
<endpoint address="Services"
binding="basicHttpBinding"
bindingConfiguration="DrawingServiceBasicHttp"
name="DrawingServiceEndPoint"
contract="MyServices.IDrawingService" />
<endpoint address="mex"
binding="mexHttpBinding"
bindingConfiguration=""
name="DrawingMex"
contract="IMetadataExchange" />
<behaviors>
<serviceBehaviors>
<behavior name="md">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
我的客户端配置
<bindings>
<basicHttpBinding>
<binding name="DrawingServiceEndPoint" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security>
<transport>
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://MyHostName/Services/DrawingService.svc/Services"
binding="basicHttpBinding" bindingConfiguration="DrawingServiceEndPoint"
contract="EvalDrawingService.IDrawingService" name="DrawingServiceEndPoint" />
</client>
在代码中尝试设置地址:
EvalDrawingService.DrawingServiceClient client = new EvalDrawingService.DrawingServiceClient("DrawingServiceEndPoint", GetServiceAddress());
我已经验证通过GetServiceAddress()
被吐出的地址是存在的,我可以使用浏览器来验证它是否存在(更不用说我可以连接t了它使用wcftestclient)。
例外:
{System.ServiceModel.CommunicationException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.BrowserHttpWebRequest.<>c_DisplayClass5.b_4(Object sendState) at System.Net.Browser.AsyncHelper.<>c_DisplayClass4.b_1(Object sendState) --- End of inner exception stack trace --- at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result) --- End of inner exception stack trace --- at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result) at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result) at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result) at System.ServiceModel.ClientBase
1.ChannelBase
1.EndInvoke(String methodName, Object[] args, IAsyncResult result) at EvaluaionAncillaryControl.EvalDrawingService.DrawingServiceClient.DrawingServiceClientChannel.EndGetEvalAreaDrawing(IAsyncResult result) at EvaluaionAncillaryControl.EvalDrawingService.DrawingServiceClient.EvaluaionAncillaryControl.EvalDrawingService.IDrawingService.EndGetEvalAreaDrawing(IAsyncResult result) at EvaluaionAncillaryControl.EvalDrawingService.DrawingServiceClient.OnEndGetEvalAreaDrawing(IAsyncResult result) at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)}
当您在config中更改了端点地址时发生了什么?这应该工作,我相信 – Richard 2011-03-30 20:08:38
@理查德 - 看到我的编辑,谢谢。 – AGoodDisplayName 2011-03-30 20:17:29
两个建议 - 请发布确切的错误消息,你可能想使用提琴手来查看失败的请求。 – rboarman 2011-04-11 19:52:47