WCF AspNetCompatibilityRequirements et appel ajax sur 2 appli distinctes
Bonjour, En mettant une WCF dans une appli et son appel en ajax dans une autre , je n'arrive pas à appeler le service, j'ai
Erreur d'exécution Microsoft JScript: « WcfService » est indéfini
à la ligne où se trouve son appel:
WcfService.Service1.getDateDirectAjax(OnWSRequestComplete, OnWSRequestFailed);
sauriez vous ce qui se passe svp ?
Merci
voici le descriptif de ce que j'ai fait:
j'ai une page .aspx sur une appli 1 hébergé sur IIS 7.5 sur le port 80 sur DefaultAppPool mode pipeline intégré
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WS.aspx.cs" Inherits="AjaxPageMethode.WS" %>
<!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 id="Head1" runat="server">
<script language="javascript" type="text/javascript">
function OnWSRequestComplete(results)
{
alert(results + " ! direct via ws ! ");
}
function OnWSRequestFailed(error) {
alert("Stack Trace: " + error.get_stackTrace() + "/r/n" +
"Error: " + error.get_message() + "/r/n" +
"Status Code: " + error.get_statusCode() + "/r/n" +
"Exception Type: " + error.get_exceptionType() + "/r/n" +
"Timed Out: " + error.get_timedOut());
}
function GetDateDirectByWCF() {
WcfService.Service1.getDateDirectAjax(OnWSRequestComplete, OnWSRequestFailed);
}
</script>
</head>
<body>
<form id="frmDefault" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="http://localhost/WcfService/Service1.svc" />
</Services>
</asp:ScriptManager>
<h2>
<asp:Label ID="Label1" runat="server" Text="MAJ Date directement par WS" onclick = "return GetDateDirectByWCF();" ></asp:Label>
</h2>
</form>
</body>
</html> |
j'ai un WCF sur une appli 2 hébergé sur IIS 7.5 sur le port 80 sur DefaultAppPool mode pipeline intégré
IService1.cs
1 2 3 4 5 6 7 8 9 10 11 12
|
namespace WcfService
{
[ScriptService]
[ServiceContract(Namespace = "WcfService")]
public interface IService1
{
[OperationContract]
[WebMethod]
string getDateDirectAjax();
}
} |
Service1.svc.cs
1 2 3 4 5 6 7 8 9 10 11 12
|
namespace WcfService
{
//[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service1 : IService1
{
public string getDateDirectAjax()
{
return DateTime.Now.ToString();
}
} |
Service1.svc
1 2
|
<%@ ServiceHost Language="C#" Debug="true" Service="WcfService.Service1" CodeBehind="Service1.svc.cs" %> |
je n'ai pas touché au Web.config
infos sur :
http://msdn.microsoft.com/fr-fr/libr...=vs.90%29.aspx
http://msdn.microsoft.com/fr-FR/library/aa702682.aspx
Partager