Bonjour,
je souhaite créer un service WCF "distant" et l'appeler depuis une méthode javascript.
J'ai trouvé l'exemple suivant :
http://www.codeproject.com/KB/aspnet...avascript.aspx
Cependant, dans cet exemple, l'assembly du WCF est référencé dans l'application web... et null part on indique une adresse HTTP pour accéder au service.
Pour l'instant,
=> j'ai crée un service WCF (que j'ai appelé SimpleService). Je n'ai fait aucune modification, c'est le service d'exemple que VS Studio créait.
=> j'ai crée une application web classique
=> J'ai référencé le service WCF (clic droit sur mon projet web, Add Service Référence)
Jusque là, tout va bien.
Dans mon web.config, j'ai ceci :
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 45 46 47 48 49 50 51
|
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="AspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8731/Design_Time_Addresses/SimpleService/Service1/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1"
contract="SimpleService.IService1" name="WSHttpBinding_IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service name="SimpleService.Service1Client">
<endpoint
behaviorConfiguration="AspNetAjaxBehavior"
binding="webHttpBinding"
contract="SimpleService.IService1" />
</service>
</services>
</system.serviceModel> |
J'ai crée un fichier SimpleService.svc, qui comprend ceci :
1 2
|
<%@ ServiceHost Language="C#" Debug="true" Service="SimpleService.Service1Client" %> |
Sur ma page default.aspx, j'ai le code suivant :
1 2 3 4 5 6 7 8 9 10 11
|
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/SimpleService.svc" />
</Services>
</asp:ScriptManager>
<script language="javascript" type="text/javascript">
var toto = new SimpleService.CompositeType();
alert(toto);
</script> |
Et bien évidemment, il me plante le js sur
var toto = new SimpleService.CompositeType();
Et c'est là que j'ai besoin d'aide ...
Qui pourrait m'aider ?
Partager