Hallo,
bei dem Versuch einen POST an einen Webservice zu schicken erhalte ich diese Fehlermeldung:
Nur Webdienste mit einem [ScriptService]-Attribut in der Klassendefinition können aus einem Skript aufgerufen werden.
Das Problem:
in meiner Klassendefinition steht aber das ScriptService Attribut:
using ....
namespace JSON
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[ScriptService]
public class JSON : System.Web.Services.WebService
{
[WebMethod]
public string testJSON()
{
.......
Was kann ich tun ?
Hallo,
wie sieht denn die Gegenseite / der Aufruf aus?
Gruß, MarsStein
Non quia difficilia sunt, non audemus, sed quia non audemus, difficilia sunt! - Seneca
Ich rufe den Webservice von einer Html Datei und jquery auf.
Das ganze ist unveränderter BeispielCode von Codeproject
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
function testJson() {
$.ajax({
type: "POST",
url: "JSON.asmx/testJSON",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
$("#jsonResponse").html(msg);
var data = eval("(" + msg + ")");
var t = "<table border=1> <tr>" +
"<td> <strong>Name</strong></td> <td> " +
"<strong>Company</strong></td> <td> " +
"<strong>Address</strong></td> <td> " +
"<strong>Phone</strong></td> <td> " +
"<strong>Country</strong></td> </tr> ";
jQuery.each(data, function(rec) {
t = t + " <tr> <td> " + this.Name + "</td> <td> " +
this.Company + "</td> <td> " + this.Address +
"</td> <td> " + this.Phone + "</td> <td> " + this.Country + "</td> </tr> ";
});
t = t + " </table> ";
$("#jsonDiv").html(t);
},
error: function(msg) {
}
});
};
function testXml() {
$.ajax({
type: "POST",
url: "JSON.asmx/TestXML",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "xml",
success: function(msg) {
alert(msg);
}
});
};
</script>
</head>
<body>
<p>
<input id="testjson" type="button" value="Test JSON Call" onclick="testJson()" />
<input id="testxml" type="button" value="Test XML Call" onclick="testXml()" />
</p>
<br />
<strong>Message Response</strong>
<br />
<div id="jsonResponse" style="display:block;"></div>
<br />
<strong>Processed Result</strong>
<br />
<div id="jsonDiv" style="display:block;"></div>
</body>
</html>