Note that there are some explanatory texts on larger screens.

plurals
  1. POBad request 400 on sending xml request in wcf rest
    primarykey
    data
    text
    <p>I am writing a sample application using wcf rest for authentication. Here is the snapshot of the code:</p> <p><strong>service Interface:</strong></p> <pre><code>[ServiceContract] public interface IAuthenticate { [OperationContract] [WebInvoke(BodyStyle=WebMessageBodyStyle.Bare, Method = "POST", UriTemplate = "/VUser",RequestFormat= WebMessageFormat.Xml ), ] string CreateUser(VUser user); } </code></pre> <p>Datacontract class:</p> <pre><code>[DataContract] public class VUser { public VUser() { } [DataMember] public string NickName { get; set; } [DataMember] public string lName { get; set; } [DataMember] public string fName { get; set; } [DataMember] public string Email { get; set; } [DataMember] public string PhoneNumber { get; set; } [DataMember] public string Password { get; set; } [DataMember] public string Gender { get; set; } [DataMember] public int CountryCode { get; set; } } </code></pre> <p><strong>Service class:</strong></p> <pre><code>public class Authenticate : IAuthenticate { #region IAuthenticate members public string CreateUser(Vuser user) { //processing xml for response } #endregion IAuthenticate } </code></pre> <p><strong>client code:</strong></p> <pre><code> Uri baseAddress = new Uri("http://localhost:8000"); using (WebServiceHost host = new WebServiceHost(typeof(Authenticate), baseAddress)) { host.Open(); Console.WriteLine("Press any key to terminate"); Console.ReadLine(); host.Close(); } </code></pre> <p>Now I am using fiddler to send the request after host.open() and send the the request has shown:</p> <p>post <a href="http://localhost:8000/Vuser/" rel="nofollow noreferrer">http://localhost:8000/Vuser/</a></p> <p>User-Agent: Fiddler Host: localhost:8000 content-length: 233 content-type: text/xml</p> <p>and in request body :</p> <p> sandy r sunil sunil.r 919900101948 winter male 01 </p> <p>but it is returning me HTTP/1.1 400 Bad Request. My question is am I passing the vuser class correctly to the create user method or is there any other way to send the vuser. </p> <p>Please help me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload