Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t从浏览器浏览到WCF REST服务_Wcf_Rest_Wcf Rest - Fatal编程技术网

Can';t从浏览器浏览到WCF REST服务

Can';t从浏览器浏览到WCF REST服务,wcf,rest,wcf-rest,Wcf,Rest,Wcf Rest,考虑这一点: [ServiceContract] public interface ICreditCardExtractor { [OperationContract] [WebGet] string CoolAction(); } 我已经在我的IIS中定向了一个新应用程序到工件,并且能够浏览文件。 但是,当我尝试调用CoolAction(通过浏览http://localhost/MySvc/CreditCardExtractor.

考虑这一点:

[ServiceContract]
public interface ICreditCardExtractor
{       
        [OperationContract]
        [WebGet]
        string CoolAction();
}
我已经在我的IIS中定向了一个新应用程序到工件,并且能够浏览文件。 但是,当我尝试调用
CoolAction
(通过浏览
http://localhost/MySvc/CreditCardExtractor.svc/CoolAction

我明白了

由于EndpointDispatcher上的ContractFilter不匹配,无法在接收器上处理具有操作“”的消息。这可能是因为合同不匹配(发送方和接收方之间的操作不匹配)或发送方和接收方之间的绑定/安全不匹配。检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如消息、传输、无)

这是我的
web.config

<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.5"/>
        <httpRuntime targetFramework="4.5"/>
         <!--pages controlRenderingCompatibilityVersion="4.0"/-->
    </system.web>
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior>
                    <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="false"/>
                </behavior>
            </serviceBehaviors>
            <endpointBehaviors>
                <behavior name="web">
                    <webHttp/>
                </behavior>
            </endpointBehaviors>
        </behaviors>
        <protocolMapping>
            <add binding="basicHttpsBinding" scheme="https"/>
        </protocolMapping>
        <!--added service behaviour configuration-->
        <services>
            <service name="WcfService1.CreditCardExtractor">
                <endpoint 
                    address="" 
                    binding="webHttpBinding"  
                    contract="WcfService1.ICreditCardExtractor" />
            </service>
        </services>
        <serviceHostingEnvironment  
                aspNetCompatibilityEnabled="true" 
                multipleSiteBindingsEnabled="true"/>
    </system.serviceModel>
    ....
</configuration>

....
您已经定义了端点行为,但尚未将其应用到服务端点,请尝试将配置更新为:

<services>
    <service name="WcfService1.CreditCardExtractor">
        <endpoint 
            address="" 
            behaviorConfiguration="web"  -- add this line here!!
            binding="webHttpBinding"  
            contract="WcfService1.ICreditCardExtractor" />
    </service>
</services>

您已经定义了端点行为,但尚未将其应用到服务端点,请尝试将配置更新为:

<services>
    <service name="WcfService1.CreditCardExtractor">
        <endpoint 
            address="" 
            behaviorConfiguration="web"  -- add this line here!!
            binding="webHttpBinding"  
            contract="WcfService1.ICreditCardExtractor" />
    </service>
</services>