[英]404/405 Errors With Cross Domain Javascript access to WCF Self hosted Service
我有一個運行POST的非常簡單的webHttpBinding WCF服務。 如果我發送GET-響應為
狀態405方法不允許
響應標頭允許:POST內容長度:0服務器:
因此,該服務正在接收GET並作出響應,它僅接受正確的POST。 如果我隨后發送POST,則會得到以下信息:
找不到狀態404
響應頭Content-Length:0服務器:Microsoft-HTTPAPI / 2.0
WCF服務配置在這里:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
</customHeaders>
</httpProtocol>
</system.webServer>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="RaptorHTTPService.RaptorHTTPService">
<endpoint address="RaptorHTTPService" behaviorConfiguration="WebBehaviour" binding="webHttpBinding" bindingConfiguration="crossDomain" contract="RaptorHTTPService.IRaptorHTTPService" name="WebEndpoint">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://ccs-labs.com:8008/RaptorHTTPService/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="crossDomain" crossDomainScriptAccessEnabled="true" allowCookies="true" />
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="WebBehaviour">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
該界面如下所示:
namespace RaptorHTTPService
{
[ServiceContract]
public interface IRaptorHTTPService
{
[OperationContract(IsOneWay = true)]
[WebInvoke(UriTemplate = "SendData/{srcUrl}", Method = "POST", RequestFormat = WebMessageFormat.Xml)]
void GetData(string srcUrl);
}
}
我正在Chrome上使用Advanced Rest Client進行測試,我正在將有效載荷發送到: http://ccs-labs.com:8008/RaptorHTTPService/Service1/SendData/
: http://ccs-labs.com:8008/RaptorHTTPService/Service1/SendData/
: http://ccs-labs.com:8008/RaptorHTTPService/Service1/SendData/
/,有效載荷是http://www.google.co.uk
誰能看到問題出在哪里並向我解釋問題?
似乎沒有通過http://ccs-labs.com:8008/RaptorHTTPService/Service1/SendData/
訪問它,而是使用http://ccs-labs.com:8008/RaptorHTTPService/Service1/mex
確實可以使用。
有什么想法嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.