Bad request on a new iis server

0

I have 3 servers iis in production and homologation everything works ok. But in a new server I just created, installing all the necessary tools to run ASP.NET and putting the source code of a webservice in C # as a new site, returns me a 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 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

Do you have any way to know the reason for the 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
    
asked by anonymous 04.02.2016 / 17:12

2 answers

0

After much thought of the System.UnauthorizedAccessException error occurring before even entering the called method, I remembered that the methods have write logging of the input and output xml. I went to check the folder where these logs were being written and I saw that only local users were writable, but IIS uses IIS_USRS to do this, so it would never work without permission.

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

    
05.02.2016 / 13:24
1

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

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

This configuration can be done through the IIS administrative screen (for IIS 7, see here ) or through your Web.config 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 this setting, I recommend reading of this official article on the subject .

    
05.02.2016 / 01:37