无法从jquery调用wcf post

时间:2014-12-14 15:41:53

标签: jquery json wcf post wcf-rest

当我尝试从jquery发布到wcf服务方法时,我收到这样的错误。 "网络错误0x80070005,访问被拒绝"。我从小提琴手那里试了一下它的确有效,无法弄明白。已经尝试了将近一天,但无法确定。任何帮助将非常感谢我的朋友们。提前致谢

这是我的jquery代码

function testUlsService()
{
    debugger;
    var myurl = "http://azcrmcritdevwb1.red.com:84/ULSService.svc/ulsrest/PostToUls";


    var result;
    jQuery.support.cors = true;
    $.ajax({
        async: false,
        type: "POST",                                                                                //GET or POST or PUT or DELETE verb
        url: myurl,   //Location of the service
        data: JSON.stringify({ "GameID" : "Created from emulator" }),                    //Data sent to server
        contentType: "application/json; charset=utf-8",                                               //content type sent to server
        dataType: "json",                                                                             //Expected data format from server
        processdata: true,                                                                           //True or False
        crossDomain: true,
        success: function (msg) { result = msg; },
        error: ServiceFailed
    });

    return result;

}

这是我的wcf配置

  <system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="servicebehavior">
      <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="true" />
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>

    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
  <behavior name="restbehavior">
    <webHttp helpEnabled="true" />        
  </behavior>

 </endpointBehaviors>    
</behaviors>

<services>  
   <service name="Microsoft.IT.CCRM.CRTISIT.ULSWebService.ULSService" behaviorConfiguration="servicebehavior">

    <endpoint name="soapendpoint" contract="Microsoft.IT.CCRM.CRTISIT.ULSWebService.IUlSService"
              binding="basicHttpBinding" address="soap"  />

    <endpoint name="restendpoint"
              contract="Microsoft.IT.CCRM.CRTISIT.ULSWebService.IUlSService"
              binding="webHttpBinding"
              address="ulsrest"
              behaviorConfiguration="restbehavior"

      />
     <endpoint name="mexendpoint" address="mex" contract="IMetadataExchange" binding="mexHttpBinding"/>
  </service>
</services>  

<protocolMapping>
    <!--<add binding="basicHttpBinding" scheme="https" />-->      
</protocolMapping>    
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"  />  

0 个答案:

没有答案