4

我在尝试通过 Fiddler 路由我的 WCF 客户端请求时遇到问题。我在网上到处搜索,发现只有两个提到 Fiddler 在 WCF 服务配置为侦听 IPv4 时出现问题,但启用了 IPv6。但是,虽然我的问题很相似,但这似乎不是我的问题。

我在连接到托管在 IPv4 端口上的服务时遇到问题。当我的绑定配置为使用提琴手代理时,我的 WCF 客户端会引发以下异常。我在 Fiddler 的选项中禁用了 IPv6 支持,并确保我的绑定已正确配置为使用代理。

异常报告:

System.ServiceModel.EndpointNotFoundException:无法连接到 http://campus.services.ecollege-labs.com/Entity/Foundation/v1.0/EducationalPartnerSvc. TCP错误代码10061:无法建立连接,因为目标机器主动拒绝它10.181.3.23:8888。---> System.Net.WebException:无法连接到远程服务器 ---> System.Net.Sockets.SocketException:无法建立连接,因为目标机器在 System.Net 上主动拒绝了 10.181.3.23:8888 .Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) - -- 内部异常堆栈跟踪结束 --- 在 System.Net.HttpWebRequest 的 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) 处。

服务器堆栈跟踪:在 System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout) 在 System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream() 在 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan 超时)在 System.ServiceModel.Channels.RequestChannel.Request(消息消息,TimeSpan 超时)在 System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息消息,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannel.Call(字符串操作, 单向布尔值, ProxyOperationRuntime 操作, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 消息)

在 [0] 处重新引发异常:在 IMS.EnterpriseServices 的 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 处的 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)。 Facades.Campus.EducationalPartner.EducationalPartnerSvc.FindByClientString(String clientString) at IMS.EnterpriseServices.Facades.Campus.EducationalPartner.EducationalPartnerSvcClient.FindByClientString(String clientString) in C:\P4\HEDI\AS2-dev-dotnext-campus-dev\AS \HEI\Src\CAS\IMS.EnterpriseServices.Facades.Campus\Service References\EducationalPartner\Reference.cs: IMS.EnterpriseServices.Facades.Campus.CampusEntityFacade.GetEPID(String clientString) 在 C:\P4\HEDI\ 的第 428 行AS2-dev-dotnext-campus-dev\AS\HEI\Src\CAS\IMS.EnterpriseServices.Facades。Campus\CampusEntityFacade.cs:IMS.EnterpriseServices.Transformation.Domain.TransformationSvc.TransformCreateGroupRequest(createGroupRequestMessage message) 的第 37 行,位于 C:\P4\HEDI\AS2-dev-dotnext-campus-dev\AS\HEI\Src\CAS\ IMS.EnterpriseServices.Transformation.Domain\TransformationSvc.cs: IMS.EnterpriseServices.Facades.IMSFacade.TransformCreateGroupRequest(createGroupRequestMessage imsMessage) 的第 106 行在 C:\P4\HEDI\AS2-dev-dotnext-campus-dev\AS\HEI\ Src\CAS\IMS.EnterpriseServices.Facades\IMSFacade.cs: IMS.EnterpriseServices.Domain.TransformationAndEnrichmentCoordinator.ProcessCreateGroupRequestMessage(createGroupRequestMessage message) 的第 113 行在 C:\P4\HEDI\AS2-dev-dotnext-campus-dev\AS\ HEI\Src\CAS\IMS.EnterpriseServices.Domain\TransformationAndEnrichmentCoordinator.cs:IMS.EnterpriseServices 的第 140 行。Facades.IMSFacade.<>c__DisplayClass1.b__0(Object o) 在 C:\P4\HEDI\AS2-dev-dotnext-campus-dev\AS\HEI\Src\CAS\IMS.EnterpriseServices.Facades\IMSFacade.cs:line 135

绑定配置:

<customBinding>
  <!-- Secured, WS-Security message signing and encryption, custom binding for IMS endpoints -->
  <binding name="customHttpSecuredNoWSA">
    <security
      defaultAlgorithmSuite="Basic128Rsa15"
      authenticationMode="MutualCertificate"
      securityHeaderLayout="Lax"
      includeTimestamp="false"
      keyEntropyMode="CombinedEntropy"
      messageProtectionOrder="SignBeforeEncrypt"
      messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"
      requireSignatureConfirmation="false"
      requireSecurityContextCancellation="false"
      allowSerializedSigningTokenOnReply="true">
      <localServiceSettings detectReplays="false" />
    </security>
    <textMessageEncoding
      messageVersion="Soap11"
      writeEncoding="utf-8">
      <readerQuotas
        maxArrayLength="1048576"
        maxStringContentLength="4194304"
        maxBytesPerRead="4194304"
        maxNameTableCharCount="4194304"
      />
    </textMessageEncoding>
    <httpTransport
      maxBufferPoolSize="4194304"
      maxBufferSize="1048576"
      maxReceivedMessageSize="1048576"
      proxyAddress="http://my.host.name:8888"
      useDefaultWebProxy="false"
    />
  </binding>
</customBinding>
4

1 回答 1

3

感谢 Jon Skeet 和 Paolo 的评论,我能够解决这个问题。似乎某些东西(可能是防火墙)正在干扰与我的主机名/IP 的连接。使用 127.0.0.1 有效,但是必须在 WCF 配置中指定如下:

proxyAddress="http://127.0.0.1.:8888"

请注意 127.0.0.1 环回地址末尾的额外句点。如果没有句点,WCF 会进行某种硬编码检查,以防止在本地环回中使用代理服务器。(为什么微软会明确地在代理服务器使用中建立硬编码排除本地环回的功能,这超出了我的理解,但至少这个技巧有效。)

于 2010-06-28T19:03:11.523 回答