1

I've get this the message below when surfing in to my webservice. I've read at many places that I should add HttpGet and HttpPost in my webconfig, but it's already there. I have tried using two methods that looks the same, returns the same type, but have one less input parameter and then one works good, and one get "The test form is only available for requests from the local machine".

I know it has nothing to do with number of parameters, because I have one more method with even more parameters but it works fine..

Why is it different behaviors?

The test form is only available for requests from the local machine

<webServices>
  <protocols>
    <add name="HttpGet"/>
    <add name="HttpPost"/>
  </protocols>
</webServices>

    //This gets "The test form is only available for requests from the local machine"
    [WebMethod]
    public int DoSomething(string param1, string param2, string param3, string param4, bool param5, DateTime param6, DateTime param7,
        double param8, double param9, string param10, string param11, int param12, int param13,
        string param14, int param15,DateTime? param16)
    {

        return 0;
    }

    //This method works fine
    [WebMethod]
    public int DoSomething2(string param1, string param2, string param3, string param4, bool param5, DateTime param6, DateTime param7,
        double param8, double param9, string param10, string param11, int param12, int param13,
        string param14, int param15)
    {

        return 0;
    }

EDIT: The cause of the problem seems to be nullable parameter

MrProgram
  • 5,044
  • 13
  • 58
  • 98
  • can you provide your code – Neha Thakur Oct 13 '15 at 12:01
  • hope this will help you . please follow these this link http://stackoverflow.com/questions/13234819/the-test-form-is-only-available-for-requests-from-the-local-machine – Neha Thakur Oct 13 '15 at 12:04
  • I'm guessing because the extra parameter is nullable. – Lorek Oct 13 '15 at 12:04
  • @Lorek That seems like a correct answer...Why is that? Is it possible to work around? – MrProgram Oct 13 '15 at 12:09
  • I did a quick search but could not find a good answer to this question: Are nullable types serializable? I suspect not. There are several topics on ignoring them for serialization if they are null. – Lorek Oct 13 '15 at 12:16
  • @Lorek hmm ok. Well, I'm satisfied with the answer. Could you wright an answer so I can mark it? – MrProgram Oct 13 '15 at 12:20

1 Answers1

1

Your web method that is generating the error has a nullable DateTime (DateTime?) parameter. It seems like nullable types are not inherently serializable. Maybe you could use a string parameter instead and just validate it on the back end. Just a suggestion.

Lorek
  • 855
  • 5
  • 11