c# - There was no channel that could accept the message with action 'http://schemas.xmlsoap.org/ws/2004/09/transfer/Get -


below service code

using system; using system.collections.generic; using system.linq; using system.runtime.serialization; using system.servicemodel; using system.servicemodel.web; using system.text; using system.servicemodel.channels; using system.xml;  namespace wcfserviceraw {     // note: can use "rename" command on "refactor" menu change class name "service1" in code, svc , config file together.     public class service1 : iservice1     {          public message getdata()         {             // create body             string body = ("<test>data</test>");              // create messatge             messageversion ver = operationcontext.current.incomingmessageversion;             message msg = message.createmessage(ver, "responsetogetdatarequest", body);              //debug.writeline(msg.tostring());             return msg;          }      }      class testdatawriter : bodywriter     {         string _data;          public testdatawriter(string data)             : base(false)         {             _data = data;         }          protected override void onwritebodycontents(xmldictionarywriter writer)         {             writer.writeraw(_data);         }     }  } 

and here contract

using system; using system.collections.generic; using system.linq; using system.runtime.serialization; using system.servicemodel; using system.servicemodel.web; using system.text; using system.servicemodel.channels;  namespace wcfserviceraw {      [servicecontract]     public interface iservice1     {          [operationcontract(replyaction = "responsetogetdatarequest")]         message getdata();         //[operationcontract(replyaction = "responsetogetdatarequest")]         //message getdata1();     }  } 

and meention config code

<?xml version="1.0"?> <configuration>   <system.diagnostics>     <trace autoflush="true"></trace>     <sources>       <source name="system.servicemodel" switchvalue="information, activitytracing" propagateactivity="true" >         <listeners>           <add name="xml"/>         </listeners>       </source>       <source name="system.servicemodel.messagelogging">         <listeners>           <add name="xml"/>         </listeners>       </source>       <source name="myusertracesource" switchvalue="information, activitytracing">         <listeners>           <add name="xml"/>         </listeners>       </source>     </sources>     <sharedlisteners>       <add name="xml" type="system.diagnostics.xmlwritertracelistener"                  initializedata="c:\logs\tracesbinding.svclog" />     </sharedlisteners>   </system.diagnostics>    <system.web>     <compilation debug="true" targetframework="4.0" />   </system.web>  <!-- <system.servicemodel>     <behaviors>       <servicebehaviors>         <behavior>            <servicemetadata httpgetenabled="true"/>            <servicedebug includeexceptiondetailinfaults="true"/>         </behavior>       </servicebehaviors>     </behaviors>     <servicehostingenvironment multiplesitebindingsenabled="true" />   </system.servicemodel>-->   <system.servicemodel>         <services>       <service name="wcfserviceraw.service1" behaviorconfiguration="myservicetypebehaviors" >         <!-- service endpoints -->         <endpoint           address="http://localhost:49389/service1.svc" binding="wshttpbinding" contract="wcfserviceraw.iservice1">         </endpoint>         <endpoint address="mex"  binding="mexhttpbinding" contract="imetadataexchange"/>       </service>     </services>     <behaviors>       <servicebehaviors>         <behavior name="myservicetypebehaviors" >           <servicemetadata httpgetenabled="false" />         </behavior>       </servicebehaviors>     </behaviors>   </system.servicemodel>  <system.webserver>     <modules runallmanagedmodulesforallrequests="true"/>   </system.webserver>  </configuration> 

the client code follows

using system; using system.collections.generic; using system.linq; using system.text; using system.servicemodel.channels; using system.xml;  namespace wcfclientraw {     class program     {         static void main(string[] args)         {             //imycontract proxy = channelfactory<imycontract>.createchannel(new basichttpbinding(), new endpointaddress(address));             wcfserviceraw.service1client proxy = new wcfserviceraw.service1client();             using (proxy idisposable)             {                 message msg = proxy.getdata();                 console.writeline(msg.tostring());                 console.writeline();                  xmldictionaryreader xdr = msg.getreaderatbodycontents();                 //string exp = "<test>data</test>";                 string act = xdr.readouterxml();                 //debug.assert(exp == act);                 console.writeline(act);                 console.readline();             }         }     } } 

and app config

<?xml version="1.0" encoding="utf-8" ?> <configuration>    <!-- <system.servicemodel>         <bindings>             <basichttpbinding>                 <binding name="basichttpbinding_iservice1" />             </basichttpbinding>         </bindings>         <client>             <endpoint address="http://localhost:49389/service1.svc" binding="basichttpbinding"                 bindingconfiguration="basichttpbinding_iservice1" contract="wcfserviceraw.iservice1"                 name="basichttpbinding_iservice1" />         </client>     </system.servicemodel>-->      <system.servicemodel>         <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" />                     </security>                 </binding>             </wshttpbinding>         </bindings>         <client>             <endpoint address="http://localhost:49389/service1.svc" binding="wshttpbinding"                 bindingconfiguration="wshttpbinding_iservice1" contract="wcfserviceraw.iservice1"                 name="wshttpbinding_iservice1">                 <identity>                     <userprincipalname value="sheraz.akbar@curemd.com" />                 </identity>             </endpoint>         </client>     </system.servicemodel> </configuration> 

now got above exception can me out , trace log shows no message communication.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -