0

My service model looks as follows.

<system.serviceModel>
  <services>
    <service name="Web.General" behaviorConfiguration="common">
      <endpoint address="basic" 
        binding="basicHttpBinding" 
        contract="Web.IGeneral" />
      <endpoint
      ...
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="common">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment
  aspNetCompatibilityEnabled="true"
  multipleSiteBindingsEnabled="true" />

When I hit .../general.svc/ping/1 I get error 400 Bad Request, which I can't explain. What is that and how can I kill it?

My service has interface as follows.

[ServiceContract]
public interface IGeneral
{
  //[OperationContract(Name = "Ping")]
  [WebInvoke(
    Method = "GET",
    BodyStyle = WebMessageBodyStyle.WrappedRequest,
    //RequestFormat = WebMessageFormat.Json,
    ResponseFormat = WebMessageFormat.Json,
    UriTemplate = "Ping/{input}")]
  String Ping(String input);
}
Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438

1 Answers1

1

Mate, I'v e been in to this situation and the best approach to solve this out is through Fiddler. 404 can be due to anything at server level. How about running a fiddler and see the RAW request - response

http://www.telerik.com/download/fiddler

Otherwise, enable WCF logging.

http://www.codeproject.com/Articles/383162/Logging-and-Tracing-WCF-Soap-Messages

And then use trace viewer:

http://msdn.microsoft.com/en-us/library/ms732023(v=vs.110).aspx

If you want us to give a concrete answer then you probably need to provide us more details.

codebased
  • 6,945
  • 9
  • 50
  • 84
  • Thanks mate. Please note that it's not 404 I'm getting. It's 404. And only when accessing from URL line. The usual call from the client in C# code works perfectly. I'm running it in Azure so logging is a bit limited. – Konrad Viltersten May 28 '14 at 00:04
  • I don't know the difference with Invoke but I have used [WebGet (.. ) tried with that ? – codebased May 28 '14 at 00:16
  • I've tried that too. Same result. I've done that last summer and it worked so I'm really frustrated now. I wonder if I shouldn't set the type of returned junk explicitly somehow... Where can I put *ContentType* in the interface?! Telling the receiver that it's *text* or something... – Konrad Viltersten May 28 '14 at 00:18
  • You mean RequestFormat = WebMessageFormat.Json? – codebased May 28 '14 at 00:22
  • 1
    http://stackoverflow.com/questions/802518/invoking-wcf-service-method-through-a-browser – codebased May 28 '14 at 00:28
  • Apparently, I needed to go with endpoint with binding *webHttpBinding* and then define the **endpoint's** behavior as *webHttp*. Now it works! – Konrad Viltersten May 28 '14 at 07:18
  • umm - thank you for sharing and accepting my answer. – codebased May 28 '14 at 07:19
  • Sure thing, bro. You might want to paste in the link to the other discussion as well as my solution (reformulated like your own reply) to make life easier for the next soul doing the same stupid mistake. – Konrad Viltersten May 28 '14 at 07:42