调用的目标抛出了异常

时间:2013-05-29 13:05:06

标签: c# asp.net wcf wcf-binding

我希望使用ChannelFactory在VS-2010中创建动态WCF服务通道,如下所示。

我有一个WCF服务,它使用ChannelFactory调用另一个WCF服务,如下所示,

BasicHttpBinding myBinding = new BasicHttpBinding();
EndpointAddress myEndpoint = new EndpointAddress(_endpointConfigurationName);
using (ChannelFactory<IService> factory = new ChannelFactory< IService >(myBinding))
{
factory.Open();
       object[] parameters = new object[1];
       parameters[0] = _documentId;
       IService proxy = factory.CreateChannel(myEndpoint);
       if (proxy == null)
        return;
       MethodInfo mi = proxy.GetType().GetMethod("DoExecute");
       if (mi == null)
        return;
       var serviceResult = mi.Invoke(proxy, parameters); 
       factory.Close();
}

调用服务的“Web.config”文件如下,

<services>
      <service name="IService.Service">
        <endpoint address="ws" binding="wsHttpBinding" name="wsHttpBinding_IFTPUploaderService" contract="Service.IService ">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
       <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
       <host>
            <baseAddresses>
                    <add baseAddress="http://localhost:8752/Service/" />
            </baseAddresses>
       </host>
</service>
</services>

工厂和代理工作正常但是当执行“调用”方法时,它会产生如下错误

http://localhost:81/IService.Service.svc?wsdl没有可以接受该消息的端点。这通常是由错误的地址或SOAP操作引起的。有关更多详细信息,请参阅InnerException(如果存在)

服务器堆栈跟踪

at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

在[0] 处重新抛出异常:

at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at SchedulerService.Service.IService.DoExecute(String id)

0 个答案:

没有答案