0

I see a couple of similar questions on here but mine has one big difference. I was able to use my login web client web method for about 9 months and then yesterday afternoon I started getting the 405 response.

Below is my code:

class Login extends AsyncTask<String, String, Integer> {
    StringManipulator stringManipulator = new StringManipulator();
    String result = "";
    ParseSessionId parseSessionId = new ParseSessionId();

    @Override
    protected Integer doInBackground(String... args) {
        int statusCode;

        URLSet urlset = new URLSet();
        SoapLogin login = new SoapLogin();

        String username = "";
        String password = "";

        InputStream instream;
        try {
            HttpPost post = new HttpPost(new URI(urlset.getUrl()));

            post.setHeader("SOAPAction", urlset.getAction());
            post.setHeader("Content-Type", urlset.getContentType());

            Log.e("login string entity", login.getSoapLogin(args[0].trim(), args[1].trim()));

            post.setEntity(new StringEntity(login.getSoapLogin(args[0].trim(), args[1].trim())));

            KeyStore trusted = KeyStore.getInstance("BKS");
            trusted.load(null, "".toCharArray());
            SSLSocketFactory sslf = new SSLSocketFactory(trusted);
            sslf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);

            SchemeRegistry schemeRegistry = new SchemeRegistry();
            schemeRegistry.register(new Scheme("https", sslf, 443));
            SingleClientConnManager cm = new SingleClientConnManager(post.getParams(), schemeRegistry);
            CustomHttpClient customHttpClient = new CustomHttpClient();
            HttpClient client = customHttpClient.getNewHttpClient();

            HttpResponse response = client.execute(post);

            Log.e("response.getStatusLine()", "" + response.getStatusLine());
            statusCode = response.getStatusLine().getStatusCode();

            Header[] headers = response.getAllHeaders();
            for (Header h : headers) {
                Log.e("Reponse Header", h.getName() + ": " + h.getValue());
            }

            HttpEntity entity = response.getEntity();

            if (entity != null) {
                instream = entity.getContent();
                result = stringManipulator.convertStreamToString(instream);

                Log.e("result", result);
                sessionID = parseSessionId.parseSessionId(result);

                instream.close();
            }
            return statusCode;

        } catch (Exception e) {
            return null;
        }
    }

    @Override
    protected void onPostExecute(Integer resultCode) {
        if (resultCode == 200) {
        //  Toast.makeText(context, "Response: OK", Toast.LENGTH_LONG).show();

        } else if (resultCode == 400) {
            Toast.makeText(context, "Server Error: 400", Toast.LENGTH_LONG).show();

        } else if (resultCode == 500) {
            Toast.makeText(context, "Server Error: 500", Toast.LENGTH_LONG).show();

        } else {
            Toast.makeText(context, "Server Error: " + resultCode, Toast.LENGTH_LONG).show();
        }
    }
} 

Like I said, this all worked fine until yesterday afternoon. I am using SOAP UI to test on the browser and then building the SOAP message using the StringManipulator class.

The final soap login looks like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
    <soapenv:Header/>
    <soapenv:Body>
        <tem:Login>
            <tem:login>username</tem:login>
            <tem:password>password</tem:password>
        </tem:Login>
    </soapenv:Body>
</soapenv:Envelope>

The response status line is:

HTTP/1.1 405 Method Not Allowed

The response body is:

07-16 10:38:01.113: E/result(6877): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
07-16 10:38:01.113: E/result(6877): <html xmlns="http://www.w3.org/1999/xhtml"> 
07-16 10:38:01.113: E/result(6877): <head> 
07-16 10:38:01.113: E/result(6877): <title>IIS 8.5 Detailed Error - 405.0 - Method Not Allowed</title> 
07-16 10:38:01.113: E/result(6877): <style type="text/css"> 
07-16 10:38:01.113: E/result(6877): <!-- 
07-16 10:38:01.113: E/result(6877): body{margin:0;font-size:.7em;font-family:Verdana,Arial,Helvetica,sans-serif;} 
07-16 10:38:01.113: E/result(6877): code{margin:0;color:#006600;font-size:1.1em;font-weight:bold;} 
07-16 10:38:01.113: E/result(6877): .config_source code{font-size:.8em;color:#000000;} 
07-16 10:38:01.113: E/result(6877): pre{margin:0;font-size:1.4em;word-wrap:break-word;} 
07-16 10:38:01.113: E/result(6877): ul,ol{margin:10px 0 10px 5px;} 
07-16 10:38:01.113: E/result(6877): ul.first,ol.first{margin-top:5px;} 
07-16 10:38:01.113: E/result(6877): fieldset{padding:0 15px 10px 15px;word-break:break-all;} 
07-16 10:38:01.113: E/result(6877): .summary-container fieldset{padding-bottom:5px;margin-top:4px;} 
07-16 10:38:01.113: E/result(6877): legend.no-expand-all{padding:2px 15px 4px 10px;margin:0 0 0 -12px;} 
07-16 10:38:01.113: E/result(6877): legend{color:#333333;;margin:4px 0 8px -12px;_margin-top:0px; 
07-16 10:38:01.113: E/result(6877): font-weight:bold;font-size:1em;} 
07-16 10:38:01.113: E/result(6877): a:link,a:visited{color:#007EFF;font-weight:bold;} 
07-16 10:38:01.113: E/result(6877): a:hover{text-decoration:none;} 
07-16 10:38:01.113: E/result(6877): h1{font-size:2.4em;margin:0;color:#FFF;} 
07-16 10:38:01.113: E/result(6877): h2{font-size:1.7em;margin:0;color:#CC0000;} 
07-16 10:38:01.113: E/result(6877): h3{font-size:1.4em;margin:10px 0 0 0;color:#CC0000;} 
07-16 10:38:01.113: E/result(6877): h4{font-size:1.2em;margin:10px 0 5px 0; 
07-16 10:38:01.113: E/result(6877): }#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS",Verdana,sans-serif; 
07-16 10:38:01.113: E/result(6877):  color:#FFF;background-color:#5C87B2; 
07-16 10:38:01.113: E/result(6877): }#content{margin:0 0 0 2%;position:relative;} 
07-16 10:38:01.113: E/result(6877): .summary-container,.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;} 
07-16 10:38:01.113: E/result(6877): .content-container p{margin:0 0 10px 0; 
07-16 10:38:01.113: E/result(6877): }#details-left{width:35%;float:left;margin-right:2%; 
07-16 10:38:01.113: E/result(6877): }#details-right{width:63%;float:left;overflow:hidden; 
07-16 10:38:01.113: E/result(6877): }#server_version{width:96%;_height:1px;min-height:1px;margin:0 0 5px 0;padding:11px 2% 8px 2%;color:#FFFFFF; 
07-16 10:38:01.113: E/result(6877):  background-color:#5A7FA5;border-bottom:1px solid #C1CFDD;border-top:1px solid #4A6C8E;font-weight:normal; 
07-16 10:38:01.113: E/result(6877):  font-size:1em;color:#FFF;text-align:right; 
07-16 10:38:01.113: E/result(6877): }#server_version p{margin:5px 0;} 
07-16 10:38:01.113: E/result(6877): table{margin:4px 0 4px 0;width:100%;border:none;} 
07-16 10:38:01.113: E/result(6877): td,th{vertical-align:top;padding:3px 0;text-align:left;font-weight:normal;border:none;} 
07-16 10:38:01.113: E/result(6877): th{width:30%;text-align:right;padding-right:2%;font-weight:bold;} 
07-16 10:38:01.113: E/result(6877): thead th{background-color:#ebebeb;width:25%; 
07-16 10:38:01.113: E/result(6877): }#details-right th{width:20%;} 
07-16 10:38:01.113: E/result(6877): table tr.alt td,table tr.alt th{} 
07-16 10:38:01.113: E/result(6877): .highlight-code{color:#CC0000;font-weight:bold;font-style:italic;} 
07-16 10:38:01.113: E/result(6877): .clear{clear:both;} 
07-16 10:38:01.113: E/result(6877): .preferred{padding:0 5px 2px 5px;font-weight:normal;background:#006633;color:#FFF;font-size:.8em;} 
07-16 10:38:01.113: E/result(6877): --> 
07-16 10:38:01.113: E/result(6877): </style> 
07-16 10:38:01.113: E/result(6877):  
07-16 10:38:01.113: E/result(6877): </head> 
07-16 10:38:01.113: E/result(6877): <body> 
07-16 10:38:01.113: E/result(6877): <div id="content"> 
07-16 10:38:01.113: E/result(6877): <div class="content-container"> 
07-16 10:38:01.113: E/result(6877):   <h3>HTTP Error 405.0 - Method Not Allowed</h3> 
07-16 10:38:01.113: E/result(6877):   <h4>The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.</h4> 
07-16 10:38:01.113: E/result(6877): </div> 
07-16 10:38:01.113: E/result(6877): <div class="content-container"> 
07-16 10:38:01.113: E/result(6877):  <fieldset><h4>Most likely causes:</h4> 
07-16 10:38:01.113: E/result(6877):   <ul>  <li>The request sent to the Web server used an HTTP verb that is not allowed by the module configured to handle the request.</li>   <li>A request was sent to the server that contained an invalid HTTP verb.</li>  <li>The request is for static content and contains an HTTP verb other than GET or HEAD.</li>    <li>A request was sent to a virtual directory using the HTTP verb POST and the default document is a static file that does not support HTTP verbs other than GET or HEAD.</li> </ul> 
07-16 10:38:01.113: E/result(6877):  </fieldset> 
07-16 10:38:01.113: E/result(6877): </div> 
07-16 10:38:01.113: E/result(6877): <div class="content-container"> 
07-16 10:38:01.113: E/result(6877):  <fieldset><h4>Things you can try:</h4> 
07-16 10:38:01.113: E/result(6877):   <ul>  <li>Verify the list of verbs enabled for the module handler this request was sent to, and ensure that this verb should be allowed for the Web site.</li>    <li>Check the IIS log file to see which verb is not allowed for the request.</li>   <li>Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click <a href="http://go.microsoft.com/fwlink/?LinkID=66439">here</a>. </li> </ul> 
07-16 10:38:01.113: E/result(6877):  </fieldset> 
07-16 10:38:01.113: E/result(6877): </div> 
07-16 10:38:01.113: E/result(6877):  
07-16 10:38:01.113: E/result(6877): <div class="content-container"> 
07-16 10:38:01.113: E/result(6877):  <fieldset><h4>Detailed Error Information:</h4> 
07-16 10:38:01.113: E/result(6877):   <div id="details-left"> 
07-16 10:38:01.113: E/result(6877):    <table border="0" cellpadding="0" cellspacing="0"> 
07-16 10:38:01.113: E/result(6877):     <tr class="alt"><th>Module</th><td>&nbsp;&nbsp;&nbsp;StaticFileModule</td></tr>

Like I said, this is strange because between yesterday before lunch and yesterday after lunch, I changed nothing... so why would I be getting a new response from the server?

I am at a loss for things to try.

Bogdan
  • 20,624
  • 2
  • 64
  • 57
Elaine McGovern
  • 259
  • 4
  • 24

1 Answers1

0

If it worked, you went to lunch, came back and it no longer works (and you really didn't change anything, as you say) then somebody else changed something.

You are doing a POST but for some reason IIS does not allow POST for whatever resource you are accessing (maybe a WCF .svc extension?). Seems the "StaticFileModule" is the one complaining based on the error page you get back.

Maybe someone reconfigured the server and now your request is handled by another handler? I suggest you contact your network administrators or site admins and ask them if something was reconfigured, new software installed, updates applied, etc in the time frame when you noticed your method call is no longer functional.

Bogdan
  • 20,624
  • 2
  • 64
  • 57
  • Thanks for the reply. I was really stuck. I thought maybe the HTC1 I was using had updated and that the key I was using was no longer valid? But, you were right it was a server side change. – Elaine McGovern Jul 17 '14 at 10:52