Search code examples
asp.netiispostasmx

ASMX-service returns "500 error" while using POST-method


I have a problem with ASMX-service. If I use a POST-method, it returns error "500 - Internal server error". But if I use a GET-method, it works very fine. I viewed IIS logs and saw this situation:

2013-01-16 00:00:06 212.158.165.217 GET /service.asmx/GetStopSalesAndQuotes2 Login=xxxxx&Password=xxxxx=&checkPoint=2013-01-08T14:22:56Z 80 -
85.12.229.170 Mozilla/4.0+(compatible;+Windows+NT+5.1;+SV1);+ross-tur.ru;+8-800-100-99-30+(ext.+501); 500 0 0 140

2013-01-16 00:00:06 212.158.165.217 POST /service.asmx - 80 -
62.80.175.194 Mozilla/4.0+(compatible;+MSIE+6.0;+MS+Web+Services+Client+Protocol+4.0.30319.296) 500 0 0 31

I've looked for this problem and tried to resolve it.

Firstly I inspected a web.config, but the necessary tags have been founded:

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

Secondary I've tried to turn on the debug mode by adding some tags in web.config:

<system.diagnostics>
    <trace autoflush="true" />
    <sources>
        <source name="System.Web.Services.Asmx">
            <listeners>
                <add name="AsmxTraceFile" type="System.Diagnostics.TextWriterTraceListener" initializeData="local.log" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId" />
            </listeners>
        </source>
    </sources>
    <switches>
        <add name="System.Web.Services.Asmx" value="Verbose"  />
    </switches>
</system.diagnostics>

But the log has not been created. I've thought, that the application have not rights.

I've tried to give admin rights by specifying an admin's login/pass for my site, but it has not resolved the problem and log still not created.

The other ways I've tried to debug this error:

  1. Turned off custom errors mode and switched trace enabled on "true" state:
<system.web>
<customErrors mode="Off"/>
<trace enabled="true" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="false"/>
</system.web>
  1. Also tried to enable trace and policyTrace options:
<microsoft.web.services2>
    <diagnostics>
      <trace enabled="true"/>
      <policyTrace enabled="true"/>
    </diagnostics>
    <security>
      <timeToleranceInSeconds>86400</timeToleranceInSeconds>
      <securityTokenManager 
              type="Megatec.MasterService.TourMLLogic.PasswordProvider, ServiceComponents, Version=1.0.0.0, Culture=neutral" 
              qname="wsse:UsernameToken" 
              xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"/>
    </security>
  </microsoft.web.services2>

But I've got no any result. I think, that there's an IIS configuration problems. Please, help me.

P.S. Excuse my bad English =)


Solution

  • I think you are using the different urls.

    GET /service.asmx/GetStopSalesAndQuotes2 
    POST /service.asmx
    

    See my example below:

    Webservice:

     public class Test : System.Web.Services.WebService {
    
        public Test () {}
    
        [WebMethod]
        public string HelloWorld(string name) { return "Hello " + name; }
     }
    

    html test: Both work

        <form action="Test.asmx/HelloWorld" method="get">
            <input type="text" name="name"/>
            <input type="submit" value="Submit"/>
        </form>
    
    
        <form action="Test.asmx/HelloWorld" method="post">
            <input type="text" name="name"/>
            <input type="submit" value="Submit"/>
        </form>