Bad request on a new iis server

Asked

Viewed 433 times

0

I have 3 servers in production and homologation everything works ok. But on a new server I just created, install all the tools necessary to run Asp.net and put the source code of a web service in c# as a new site, returns me Bad Request through Soapui. I used Fiddler to capture this information. If you use the test form it works.

I put it in Debug mode on the new server and when making a call before entering the method errors occur

  • A first chance Exception of type 'System.Unauthorizedaccessexception' occurred in mscorlib.dll
  • A first chance Exception of type 'System.xml.Xmlexception' occurred in System.xml.dll
  • A first chance Exception of type 'System.Web.Services.Protocols.Soapexception' occurred in System.Web.Services.dll
  • A first chance Exception of type 'System.Unauthorizedaccessexception' occurred in mscorlib.dll

Is there any way of knowing why Bad Request?

Request:

POST http://localhost:8095/WebService/WebService.asmx HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "http://www.host.com.br/GetMotoristaValidoPeloCPF"
Content-Length: 426
Host: localhost:8095
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ang="http://www.host.com.br/">
   <soapenv:Header/>
   <soapenv:Body>
      <ang:GetMotoristaValidoPeloCPF>
         <ang:usuario>user</ang:usuario>
         <ang:senha>senha</ang:senha>
         <ang:cpf>62710966972</ang:cpf>
      </ang:GetMotoristaValidoPeloCPF>
   </soapenv:Body>
</soapenv:Envelope>

Response:

HTTP/1.1 400 Bad Request
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Thu, 04 Feb 2016 16:43:35 GMT
Content-Length: 0

2 answers

1

The most practical way to get more information about IIS errors is to test it locally. This is because by default the detailed error setting is not displayed for external requests, even for security reasons.

Since this is a new server, which is probably not yet published for access by external users, you can configure the directive <httpErrors> through the attribute "errorMode" for the value "Detailed". This way, any request you make and pop an Exception to the server, it will return you a screen indicating more specifically the error.

This setting can be done through the IIS administrative screen (for IIS 7, see here) or through the Web.config of your application:

<configuration>
    <system.web>
        <customErrors mode="Off"/> <!-- Se você configurar alguma página padrão de erro, não vai estourar a Exception para o servidor -->
        <compilation debug="true"/> <!-- Sem debug ele provavelmente não te mostrará diversas informações -->
    </system.web>
    <system.webServer>
        <httpErrors errorMode="Detailed" /> <!-- a configuração em questão que expliquei -->
    </system.webServer>
</configuration>

To better understand about this setting, I recommend reading of that official article on the subject.

  • I left as requested, but only returns the header. Via test form everything works without errors. My problem occurs when I test via Soapui client, only returns me 400 error, without substatus and details.

  • I even created this new server because the site stopped working, but hence the surprise that the new one also does not work. I copied the web.config from the server to the local machine, but still the error persists. Do I have to add permission somewhere?

0


After much thinking about the System.Unauthorizedaccessexception error happen even before entering the called method, I remembered that the methods have log recording of input and output xml. I went to check the folder in which these logs were being recorded and saw that only local users had write permission, but IIS uses the IIS_USRS to make this recording, so it would never work without permission.

The solution to this error is to go to the folder properties in the Security tab and add IIS_USRS with write permission.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.