有一个我正在尝试为REST添加配置的WCF服务。继续得到AddressFilter不匹配错误。我已经尝试了所有的建议并多次查看地址,但我必须在配置中遗漏一些东西。希望有更多REST经验的人可以看到我在这里缺少的东西。
我的服务配置如下:
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="200" maxConcurrentInstances="200"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="www.parinc.com.PARToolkit">
<endpoint address="" binding="wsHttpBinding" contract="IPARToolkit"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<endpoint address="rest" binding="webHttpBinding" contract="IPARToolkit" behaviorConfiguration="webBehavior" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:86/" />
</baseAddresses>
</host>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<protocolMapping>
<add scheme="http" binding="webHttpBinding" />
</protocolMapping>
合同设置为:
[OperationContract]
[WebInvoke(UriTemplate = "GetApps?authKey1={authKey1}&authKey2={authKey2}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string GetApps(string authKey1, string authKey2);
但是当我尝试按如下方式调用服务时(没有我在http中放入的空格来获取要在此处发布的URL)我得到了AddressFilter不匹配错误:
“http://localhost:86/WebServices/PARToolkit.svc/rest/GetApps?authKey1=12345&authKey2=56789”
答案 0 :(得分:0)
如果您在IIS中托管服务,请删除“休息”&#39;在你的地址。例如 h t t p:// localhost:86 / WebServices / PARToolkit.svc / GetApps?authKey1 = 12345&amp; authKey2 = 56789
并且,在服务配置中,不需要端点中的地址。 e.g。
<endpoint address="" binding="webHttpBinding" contract="IPARToolkit" behaviorConfiguration="webBehavior" />
并删除baseAddresses部分。