c# - Service Only Works While Debugging -


i have created wcf service , having trouble testing once has been deployed. here powershell using test it:

$service = new-webserviceproxy -uri http://localhost:16651/service.svc $service.getlist() 

when debugging service visual studio f5, can call script without issue. getlist() returns long list of telephone numbers.

however, when host site on iis , run above script, empty return value.


service factory

so following this question, added attribute service.svc:

factory="system.servicemodel.activation.webscriptservicehostfactory" 

however, resulted in script returning error on first line:

new-webserviceproxy : object reference not set instance of object.

which not make sense me, not referencing empty objects... (this error appears when debugging , when hosting on iis).


web.config

next, tried updated web.config per linked question:

<services>   <service name="lyncwebservice.service">     <endpoint binding="webhttpbinding" contract="lyncwebservice.iservice" behaviorconfiguration="web"/>   </service> </services>  <behaviors>        <servicebehaviors>     </servicebehaviors>     <endpointbehaviors>       <behavior name="web">         <webhttp/>       </behavior>     </endpointbehaviors> </behaviors> 

however, when try run powershell script error both during debugging , when hosting on iis (again on first line):

the html document not contain web service discovery information.


i totally lost here , have no idea going wrong. suspect config file, did seem work when debugging vs before messed configuration.

any or guidance appreciated - , please let me know if can provide other information or test anything.

here code makes service currently:

service.svc.cs

namespace lyncwebservice {     [servicecontract]     public interface iservice     {         [operationcontract]         [webinvoke]         list<string> getlist();     }     public class service : iservice     {         public list<string> getlist()         {             return ps.getassignednumbers(@"                 set-executionpolicy remotesigned                 import-module lync                 $(get-csuser).lineuri"             );         }     } } 

web.config

<?xml version="1.0"?> <configuration>   <appsettings/>   <system.web>     <compilation debug="true" targetframework="4.0"/>     <httpruntime/>   </system.web>   <system.servicemodel>      <services>         <service name="lyncwebservice.service">         <endpoint binding="webhttpbinding" contract="lyncwebservice.iservice" behaviorconfiguration="web"/>         </service>     </services>      <behaviors>            <servicebehaviors>         </servicebehaviors>          <endpointbehaviors>           <behavior name="web">             <webhttp/>           </behavior>         </endpointbehaviors>     </behaviors>      <protocolmapping>       <!--<add binding="basichttpsbinding" scheme="https"/>-->       <add binding="webhttpsbinding" scheme="https"/>     </protocolmapping>     <servicehostingenvironment aspnetcompatibilityenabled="false" multiplesitebindingsenabled="true"/>   </system.servicemodel>   <system.webserver>     <modules runallmanagedmodulesforallrequests="true"/>     <!--         browse web app root directory during debugging, set value below true.         set false before deployment avoid disclosing web app folder information.       -->     <directorybrowse enabled="true"/>   </system.webserver> </configuration> 

thanks jonathan coffey, realised service being run localsystem account.

after changing own user account , hosting original web.config on iis, able retrieve full list using powershell script.

  1. open iis
  2. application pools
  3. right-click application pool
  4. advanced settings...
  5. process model -> identity
  6. custom account (don't forget include domain user name!)

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -