修改 如果我尝试在没有https的情况下访问/ dowork的Web服务端点,我仍然会收到错误,但它会识别出有效的端点。如何启用HTTPS?
我有一个WCF服务,最终将主要接收AJAX调用以根据用户行为管理状态。
我无法取回任何东西,目前,你能看到我哪里出错吗? (site / core.svc / dowork在浏览器和ajax中均失败)
[ServiceContract]
public interface Icore
{
[OperationContract]
[WebInvoke(UriTemplate = "/dowork",
BodyStyle = WebMessageBodyStyle.Wrapped,
ResponseFormat = WebMessageFormat.Xml)]
string DoWork();
}
[System.Web.Script.Services.ScriptService]
public class core : Icore
{
public string DoWork()
{
return "hullo";
}
}
<system.web>
<compilation debug="true" targetFramework="4.5"/>
<customErrors mode="Off"/>
<pages controlRenderingCompatibilityVersion="4.0"/>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<webHttpBinding></webHttpBinding>
</bindings>
<services>
<service name="Fusion.core" behaviorConfiguration="Fusion.CoreBehavior" >
<endpoint contract="Fusion.Icore" binding="webHttpBinding" behaviorConfiguration="webBehavior" address="" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Fusion.CoreBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
答案 0 :(得分:0)
您说“网站/ core.svc / dowork在浏览器中失败”,这意味着您正在使用HTTP GET来访问该服务。但是,您的合同使用[WebInvoke],它启用HTTP POST。尝试将[WebInvoke]更改为[WebGet],看看它是否在浏览器中发生了任何变化。