method not allowed wcf rest with Type post

i create an application with wcf and rest ihave a problem with my operation with Type Post he retourn Method not allowed , this is my operation

[WebInvoke(Method = "POST", UriTemplate = "newContact", ResponseFormat = WebMessageFormat.Json)]
        [AuthorizedMethod]
        bool CreateContact(string jsonstring);

and in this page i conevert the type string to json

public bool CreateContact(string jsonstring)
        {
            Dictionary<string, string> values = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonstring);

            log();
            return dispatcher.CreateContact(values);

and this is my service

<system.serviceModel>
    <services>
      <service behaviorConfiguration="Default" name="Mobility.SolutionService.AppService">
        <host>
          <baseAddresses>          
            <add baseAddress="https://localhost:443/B2M/"/>
          </baseAddresses>
        </host>
        <endpoint address="" binding="webHttpBinding" bindingConfiguration="crossDomain" 
                  contract="Mobility.SolutionService.IAppService" behaviorConfiguration="Web"/>
      </service>
    </services>
    <bindings>
      <webHttpBinding>
      <binding name="crossDomain">

          <security mode="Transport">
            <transport clientCredentialType="Basic" >
            </transport>
          </security>
        </binding> 
      </webHttpBinding>
      </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Default">
         <serviceDebug includeExceptionDetailInFaults="true"/>
          <serviceMetadata httpsGetEnabled="true" />
         <serviceCredentials>

           <userNameAuthentication userNamePasswordValidationMode="Custom"
                                    customUserNamePasswordValidatorType="Mobility.SolutionService.CustomUserNamePasswordValidator, Mobility.SolutionService"/>
           <serviceCertificate findValue="CN=AuthorityName"/>
          </serviceCredentials>

          <serviceAuthorization principalPermissionMode="Custom">
             <authorizationPolicies>
              <add policyType="Mobility.SolutionService.CustomAuthorizationPolicy, Mobility.SolutionService"/>
            </authorizationPolicies> 
          </serviceAuthorization>

        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="Web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

and then i send the data with js

function CreateClient(button){
var strN = document.getElementById('nom').value;
        var str1 = document.getElementById('Phone').value;
        var str2 = document.getElementById('Address').value;
        var str10 = document.getElementById('Credit_Limit_LCY').value;
        var dict = []; 
dict.push(
{
       key:"nom",
       value: strN
},
{
        key:"Phone",
        value:str1
},
{
        key: "Address",
        value:str2
},
{
key:"Credit_Limit_LCY",
value:str10
}
);
var Mydata=JSON.stringify(dict);
$.mobile.showPageLoadingMsg();
var geturl;

  geturl =$.ajax({  
 url:"https://10.0.2.2:443/B2M/newContact/",
  data:Mydata,
  contentType:"application/json; charset=utf-8",
   dataType:"json",
   timeout:10000000,  
   cache:false,
   type:'POST',
  beforeSend : function(req) {
             req.setRequestHeader('Authorization', 
                   make_base_auth (val1,val2));
        },
   error:function(XMLHttpRequest,textStatus, errorThrown) { 
   $.mobile.hidePageLoadingMsg();   

    alert("Error status :"+textStatus);  
     alert("Error type :"+errorThrown);  
     alert("Error message :"+XMLHttpRequest.responseXML);  

   },   
success:function(data) {
   alert("success");
   $.mobile.hidePageLoadingMsg();
    $.mobile.changePage("contact.html", "fade");
   }
});
   }

Can you please help me thanks

Answers


I would take a look at the following url REST guide

There are several REST attributes missing and you should use an object in stead of a stringified string representing your json object. On the server the framework takes care of that.


Need Your Help

IE prints blank pages from CSS Boilerplate

css printing internet-explorer-8 internet-explorer-9 media-queries

My company is using a print.css for printing. Also, we have another style.css that overrides any other .css files including print.css. For some reason, IE8 and IE9 are printing blank pages when the @

PHPexcel with Phpmailer

php phpmailer phpexcel

Is use the following code to generate a excel file, attach it and sent it as email. But when I opening the Excel file in my inbox Excel says that the file could be damaged or it unsafe. I can open ...