WCF WPF Web Service Client throwing 404 -
i know there lot of question problem error can not out of .
when wrote adress in navigator it's work when call same method in wpf application have 404 error.
here it's servicemode of wpf application :
<system.servicemodel> <behaviors> <endpointbehaviors> <behavior name="webendpoint"> <webhttp defaultbodystyle="wrapped" defaultoutgoingresponseformat="xml" helpenabled="true"/> </behavior> </endpointbehaviors> </behaviors> <bindings> <webhttpbinding> <binding name="webhttp"> <security mode="none"> <transport clientcredentialtype="none" /> </security> </binding> </webhttpbinding> </bindings> <client> <endpoint binding="webhttpbinding" bindingconfiguration="webhttp" behaviorconfiguration="webendpoint" contract="servicereferencebx.iservicebx" address="http://localhost:9804/servicebx.svc"> </endpoint> </client> </system.servicemodel>`
this web.config of wcf
`<?xml version="1.0" encoding="utf-8"?> <configuration> <appsettings> <add key="aspnet:usetaskfriendlysynchronizationcontext" value="true"/> </appsettings> <system.web> <compilation debug="true" targetframework="4.5.2"/> <httpruntime targetframework="4.5.2"/> <httpmodules> <add name="applicationinsightswebtracking" type="microsoft.applicationinsights.web.applicationinsightshttpmodule, microsoft.ai.web"/> </httpmodules> </system.web> <system.servicemodel> <services> <service name="bxsportwcflib.servicebx" behaviorconfiguration="servicebehaviour"> <!-- service endpoints --> <!-- unless qualified, address relative base address supplied above --> <endpoint address ="" binding="webhttpbinding" contract="bxsportwcflib.iservicebx" behaviorconfiguration="web"> </endpoint> </service> </services> <behaviors> <servicebehaviors> <behavior name="servicebehaviour"> <!-- avoid disclosing metadata information, set value below false , remove metadata endpoint above before deployment --> <servicemetadata httpgetenabled="true"/> <servicedebug includeexceptiondetailinfaults="false"/> </behavior> </servicebehaviors> <endpointbehaviors> <behavior name="web"> <webhttp/> </behavior> </endpointbehaviors> </behaviors> <servicehostingenvironment multiplesitebindingsenabled="true" /> </system.servicemodel> <system.webserver> <modules runallmanagedmodulesforallrequests="true"> <remove name="applicationinsightswebtracking"/> <add name="applicationinsightswebtracking" type="microsoft.applicationinsights.web.applicationinsightshttpmodule, microsoft.ai.web" precondition="managedhandler"/> </modules> <directorybrowse enabled="true"/> <validation validateintegratedmodeconfiguration="false"/> </system.webserver> </configuration>`
here contract
[servicecontract] public interface iservicebx { [operationcontract] [webinvoke(method = "get", responseformat = webmessageformat.json, bodystyle = webmessagebodystyle.wrappedrequest, uritemplate = "listexercices/{guiduser}")] list<exercice> getlistexercices(string guiduser); [operationcontract] [webinvoke(method = "post", responseformat = webmessageformat.json, bodystyle = webmessagebodystyle.wrappedrequest)] exercice addnewexercice(string guiduser,string nom,bool nbrepetition, bool poids, bool distance, bool duree); [operationcontract] [webinvoke(method = "get", responseformat = webmessageformat.json, bodystyle = webmessagebodystyle.wrappedrequest, uritemplate = "listefen/{guiduser}")] list<fenetre> getfenetres(string guiduser); [operationcontract] [webinvoke(method = "get", responseformat = webmessageformat.json, bodystyle = webmessagebodystyle.wrappedrequest, uritemplate = "connect/{login}/{mdpcrypt}")] string userconnect(string login, string mdpcrypt); }
i made test method userconnect.
big in advance.
my app.config
<?xml version="1.0" encoding="utf-8"?> <configuration> <configsections> <sectiongroup name="applicationsettings" type="system.configuration.applicationsettingsgroup, system, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089"> <section name="bxsportcl.properties.settings" type="system.configuration.clientsettingssection, system, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" requirepermission="false" /> </sectiongroup> </configsections> <startup> <supportedruntime version="v4.0" sku=".netframework,version=v4.5.2" /> </startup> <system.servicemodel> <bindings> <basichttpbinding> <binding name="soap" maxreceivedmessagesize="1116553600" maxbufferpoolsize="1116553600" maxbuffersize="1116553600"/> </basichttpbinding> <wshttpbinding> <binding name="mex" maxreceivedmessagesize="1116553600" maxbufferpoolsize="1116553600"> <security mode="none" /> </binding> </wshttpbinding> </bindings> <client> <endpoint address="http://localhost:9804/servicebx.svc/soap" binding="basichttpbinding" bindingconfiguration="soap" contract="servicereferencebx.servicebx" name="soap" /> </client> </system.servicemodel> <applicationsettings> <bxsportcl.properties.settings> <setting name="debugmode" serializeas="string"> <value>true</value> </setting> </bxsportcl.properties.settings> </applicationsettings> </configuration>
here web.config :
<?xml version="1.0" encoding="utf-8"?> <configuration> <configsections> <section name="entityframework" type="system.data.entity.internal.configfile.entityframeworksection, entityframework, version=6.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" requirepermission="false" /> <!-- more information on entity framework configuration, visit http://go.microsoft.com/fwlink/?linkid=237468 --></configsections> <appsettings> <add key="aspnet:usetaskfriendlysynchronizationcontext" value="true" /> </appsettings> <connectionstrings> <add name="modelbxcontainer" connectionstring="metadata=res://*/modelbx.csdl|res://*/modelbx.ssdl|res://*/modelbx.msl;provider=system.data.sqlclient;provider connection string="data source=gobelet-pc\sqlexpress;integrated security=true;multipleactiveresultsets=true;app=entityframework"" providername="system.data.entityclient" /> </connectionstrings> <entityframework> <defaultconnectionfactory type="system.data.entity.infrastructure.sqlconnectionfactory, entityframework" /> <providers> <provider invariantname="system.data.sqlclient" type="system.data.entity.sqlserver.sqlproviderservices, entityframework.sqlserver" /> </providers> </entityframework> <system.web> <compilation debug="true" targetframework="4.5.2" /> <httpruntime targetframework="4.5.2" /> <httpmodules> <add name="applicationinsightswebtracking" type="microsoft.applicationinsights.web.applicationinsightshttpmodule, microsoft.ai.web" /> </httpmodules> </system.web> <system.servicemodel> <services> <service name="bxsportwcflib.servicebx" behaviorconfiguration="myservicebehavior"> <endpoint name="rest" address="" binding="webhttpbinding" contract="bxsportwcflib.servicebx" behaviorconfiguration="restbehavior" /> <endpoint name="mex" address="mex" binding="mexhttpbinding" contract="bxsportwcflib.servicebx" /> <endpoint name="soap" address="soap" binding="basichttpbinding" contract="bxsportwcflib.servicebx" /> </service> </services> <behaviors> <servicebehaviors> <behavior name="myservicebehavior" > <servicemetadata httpgetenabled="true" /> <servicedebug includeexceptiondetailinfaults="true" /> </behavior> </servicebehaviors> <endpointbehaviors> <behavior name="restbehavior"> <webhttp /> </behavior> </endpointbehaviors> </behaviors> </system.servicemodel> <system.webserver> <modules runallmanagedmodulesforallrequests="true"> <remove name="applicationinsightswebtracking" /> <add name="applicationinsightswebtracking" type="microsoft.applicationinsights.web.applicationinsightshttpmodule, microsoft.ai.web" precondition="managedhandler" /> </modules> <directorybrowse enabled="true" /> <validation validateintegratedmodeconfiguration="false" /> </system.webserver> </configuration>
and here contract :
[servicecontract(name = "servicebx", namespace = "http://servicebx/", sessionmode = sessionmode.notallowed)] //[serviceknowntype(typeof (ilist<mydatacontracttypes>))] [servicebehavior(name = "servicebx", namespace = "http://servicebx/")] public class servicebx { [operationcontract(name = "fenetres")] [webget(responseformat = webmessageformat.json, uritemplate = "fenetres/{guiduser}")] public string getfenetres(string guiduser) { jsonserializersettings settings = new jsonserializersettings { typenamehandling = typenamehandling.all }; return jsonconvert.serializeobject(dal.user.getfenetres(guiduser), settings); //return serialjson.writefromobject(dal.user.getfenetres(guiduser),typeof(list<fenetre>)); } }
Comments
Post a Comment