0

我已经为此苦苦挣扎了几天。我正在尝试在 IIS 中托管 WCF 服务,以便我们的其他网站可以访问该服务将公开的数据。编写代码相当简单,无论我尝试什么,我都无法正确配置。

我想要达到的目标:

  1. 在 http(s)://service.motors.coop 拥有 http 和 https 后面的服务(我们还没有 SSL 证书)
  2. 能够被 .net、PHP、iOS、Android 等调用(虽然我确信这不是基于配置的)
  3. 通过浏览器访问方法来测试这些方法,例如http://service.motors.coop/motorsservice.svc/ShowClientIp

每当我尝试访问http://service.motors.coop/motorsservice.svc/ShowClientIp时,都会出现以下错误:

由于 EndpointDispatcher 的 AddressFilter 不匹配,接收方无法处理带有 To ' http://service.motors.coop/MotorsService.svc/ShowClientIp '的消息。检查发送方和接收方的 EndpointAddresses 是否一致。

有太多的配置选项我不知道从哪里开始,虽然我读了无数的文章,甚至买了一本书——太复杂了!

任何善良的灵魂会帮助我解决我的配置文件吗?

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <!-- removed -->
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <customErrors mode="Off"/>
    <httpRuntime/>
  </system.web>
  <system.serviceModel>
<services>
  <service behaviorConfiguration="ServiceBehaviour" name="MotorsWcfService.MotorsService">
    <endpoint address="" binding="webHttpBinding" bindingConfiguration="" name="MotorsServiceEndpoint" contract="MotorsWcfService.IMotorsService"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<bindings>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehaviour">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" httpsGetUrl="https://service.motors.coop/MotorsService"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="EndpointBehavior">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false"/>

更新:通过向导创建我的配置后,我现在有了这个文件:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
    <standardEndpoints>
        <webHttpEndpoint>
            <standardEndpoint name="WebHttpEndPoint" defaultOutgoingResponseFormat="Json" />
        </webHttpEndpoint>
    </standardEndpoints>
    <behaviors>
    <serviceBehaviors>
        <behavior name="MyServiceTypeBehaviors" >
            <serviceMetadata httpGetEnabled="true" />
        </behavior>
    </serviceBehaviors>
    </behaviors>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding" />
        </basicHttpBinding>
        <webHttpBinding>
            <binding name="WebHttpBinding" />
        </webHttpBinding>
    </bindings>
    <services>
        <service name="MotorsWcfService.MotorsService" behaviorConfiguration="MyServiceTypeBehaviors" >
            <endpoint address="http://service.motors.coop" binding="webHttpBinding"
                bindingConfiguration="WebHttpBinding" contract="MotorsWcfService.IMotorsService" />
            <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
        </service>
    </services>
</system.serviceModel>

但是,我仍然收到此错误:

由于 EndpointDispatcher 的 AddressFilter 不匹配,接收方无法处理带有 To ' http://service.motors.coop/MotorsService.svc/ShowClientIp '的消息。检查发送方和接收方的 EndpointAddresses 是否一致。

4

1 回答 1

-1

请在 EndpointDispatcher 中检查此链接AddressFilter mismatch - 带有 To和Resolving Configuration Error in WCF AddressFilter Mismatch的 msg和http://social.msdn.microsoft.com/Forums/vstudio/en-US/b5ae495b-f5fb-4eed-ae21 -2b2280d4fec3/address-filter-mismatch-wcf-addressing

我认为这可能会帮助你

于 2013-07-16T13:21:36.327 回答