c# - Consume WCF library functions from browser -


i've wcf library functions use powershell , c# clients. use couple of util functions directly browser i'm not sure how do.

first added webhttpbinding endpoint in web.config file, here slice

<services>     <service name="mi_lib.mainservice">         <endpoint name="basic" address="" binding="basichttpbinding" bindingconfiguration="mi_lib_http" contract="mi_lib.interfacemainservice"></endpoint>         <endpoint name="web" address="web" binding="webhttpbinding" bindingconfiguration="mi_lib_web" contract="mi_lib.interfacemainservice"></endpoint>     </service> </services> <bindings>     <basichttpbinding>         <binding name="mi_lib_http" />     </basichttpbinding>     <webhttpbinding>         <binding name="mi_lib_web" crossdomainscriptaccessenabled="true">             <security mode="none"></security>         </binding>     </webhttpbinding> </bindings> 

a simple function define test purposes this

[operationcontract] [webget] string getdata(int value); 

then if connect http://localhost/mi_lib/mi_lib.mainservice.svc/web following fault message

<fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none">     <code>         <value>sender</value>         <subcode>             <value xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:actionnotsupported</value>         </subcode>     </code>     <reason>         <text xml:lang="de-ch">the message action '' cannot processed @ receiver, due contractfilter mismatch @ endpointdispatcher. may because of either contract mismatch (mismatched actions between sender , receiver) or binding/security mismatch between sender , receiver. check sender , receiver have same contract , same binding (including security requirements, e.g. message, transport, none).</text>     </reason> </fault> 

any hint on check or other information provide?

to define web endpoint, need, in addition using webhttpbinding, add web http behavior endpoint, shown below:

<services>     <service name="mi_lib.mainservice">         <endpoint name="basic" address="" binding="basichttpbinding" bindingconfiguration="mi_lib_http" contract="mi_lib.interfacemainservice"></endpoint>         <endpoint name="web"                   address="web"                   binding="webhttpbinding"                   bindingconfiguration="mi_lib_web" contract="mi_lib.interfacemainservice"                   behaviorconfiguration="myweb">         </endpoint>     </service> </services> <bindings>     <basichttpbinding>         <binding name="mi_lib_http" />     </basichttpbinding>     <webhttpbinding>         <binding name="mi_lib_web" crossdomainscriptaccessenabled="true">             <security mode="none"></security>         </binding>     </webhttpbinding> </bindings> <behaviors>     <endpointbehaviors>         <behavior name="myweb">             <webhttp/>         </behavior>     </endpointbehaviors> </behaviors> 

also, url need use includes method name, you'll need connect to

http://localhost/mi_lib/mi_lib.mainservice.svc/web/getdata?value=123 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -