0

I have a webservice and I am getting the following error only from production server when I am trying to make a post call. It works well on development server!

500 (Internal Server Error)

Here are the headers from web service

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class Getavailability : System.Web.Services.WebService {
 .
 .
}

and here is the client side code

$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: 'WebServices/ServiceName.asmx/Method',
data: "{" +
    "'fromDate': 'data'," +
     "'fromTime': 'data'," +
    "'toDate': 'data'," +
    "'toTime': 'data'," +
    "'flyingFrom': 'data'" +
"}", 
cache: false,
success: function (data) {
//do something
}
});

The server has an iis6 and .net 4

Does anyone know what could cause this?

I'll appreciate any comment

Thanks

EDIT

this is the whole message

    {"Message":"Unable to connect to the remote server","StackTrace":" 

atSystem.Net.HttpWebRequest.GetRequestStream(TransportContext& context)

at System.Net.HttpWebRequest.GetRequestStream()

at BLL.AbstractXML.GetXmlSR(String strURL, String queryStr)

at AvailabilityRQ.Get(DateTime fromDate, DateTime fromTime, DateTime toDate, DateTime toTime, String flyingFrom)

at Web.WebServices.Getavailability.Get(String fromDate, String fromTime, String toDate, String toTime, String flyingFrom)","ExceptionType":"System.Net.WebException"}
Aristos
  • 66,005
  • 16
  • 114
  • 150
profanis
  • 2,741
  • 3
  • 39
  • 49
  • The error on the server have more details ! Can you read them Event Viewer, or can you open the errors so you can read it on page and see whats really not working ? You can not solve this so easy with out the knowing of the real error. – Aristos Feb 03 '12 at 15:13
  • I am getting the error from browser's development tool and isn't so clear. See my edited post – profanis Feb 03 '12 at 15:58
  • Shared hosting? Most hosts don't allow outbound connections of any kind. –  Feb 03 '12 at 16:04

1 Answers1

0

Check your web.config file to ensure you are allowing the POST. This normally isn't required if you are running via Visual Studio, but when you deploy it can often cause this kind of issue.

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

My other suggestions are to make sure the address in the url parameter in your JavaScript is correct - it is a relative URL, so check that this isn't the problem.

More details on URL.

Please can you try putting the fully qualified URL of the web service here:

url: 'WebServices/ServiceName.asmx/Method'

There is a possibility that this is the problem. Also, when you put in the full URL, double check to make sure it is on the same domain as the web page calling it.

Fenton
  • 241,084
  • 71
  • 387
  • 401
  • nothing changed. The same reaction. I thought that something goes wrong with the combination of iis6 and .net 4. I have done earlier something similar but in IIS 7 and .net 3.5 and it worked just fine. – profanis Feb 03 '12 at 17:37
  • @StrouMfios - in that case it's the URL I would look at next. There shouldn't be any problems with .NET 4 on IIS6 - I've used that combination a lot, including asmx services (and WCF services) and have never found it to be a problem. I've added detail to me answer on the URL. – Fenton Feb 06 '12 at 09:00
  • I don't know what the problem was. I migrated my application on a server with iis7 and now it works. Thanks everyone for your help – profanis Feb 09 '12 at 08:37