Having trouble getting visual studio to get a reference to the web service

Discussion in 'General troubleshooting' started by FishLazyWaters, Oct 19, 2009.

  1. I having trouble getting visual studio to get a reference to the web service that I just published:

    If you put this into your browsers address you see the problem I'm having.

    Any ideas?
     
  2. Ray

    Ray

    Check your roots web.config file and make sure that the name "ScriptHandlerFactory" is not being called.
     
  3. For future reference here's the whole process that worked for me:

    1) Using Visual Studio 2008
    2) Create a new "Web Service Application" not a web service library
    3) Copy everything in Note 1 below into Service1.svc.cs (into the
    namespace not into the class but in the same file).
    4) In vs 2008 right click "Service1.svc" and select view markup
    5) Copy [[ Factory="WcfService1.CustomHostFactory" ]] into the
    Service Host tag (change the name of WcfService1 if necessary).
    6) Build and publish for the first pass.
    7) Type http://www.myWebsite.com/webservice1/Service1.svc into your
    browser. You'll see some error about ScriptHandlerFactory. This is related to Windows server 2008 or a newer version of IIS (this error doesn't occur in older versions).
    8) If you get this error: then save a copy of your web.config file,
    maybe calling it webold.config.
    9) Open web.config and search for: ScriptHandlerFactory and delete
    every tag that contains it.
    10) Build and publish again.
    11) Type http://www.myWebsite.com/webservice1/Service1.svc into your
    browser. You'll see that you get some error about ScriptResource.
    Comment out everything in Note 2 below:
    12) Build and publish again.
    13) Type http://www.myWebsite.com/webservice1/Service1.svc into your
    browser. You'll see some error about needing to use BasicHttpBinding.
    14) Find wsHttpBinding in web.config and replace it with
    basicHttpBinding. Notice the case of basicHttpBinding.
    15) Copy eveything in Note3 into the <system.serviceModel> tag.
    16) Type http://www.myWebsite.com/webservice1/Service1.svc into your
    browser. It should now work.

    Note 1
    [[
    public class CustomHostFactory : ServiceHostFactory
    {
    protected override ServiceHost CreateServiceHost(Type

    serviceType, Uri[] baseAddresses)
    {
    return _CreateServiceHost (

    serviceType, baseAddresses );
    }

    private ServiceHost _CreateServiceHost ( Type

    serviceType, Uri[] baseAddresses )
    {
    int index = 1;

    if ( baseAddresses.Length == 1 )
    index = 0;

    CustomHost customServiceHost = new CustomHost(

    serviceType, baseAddresses[ index ] );

    return customServiceHost;
    }
    }

    public class CustomHost : ServiceHost
    {
    public CustomHost ( Type serviceType, params Uri[]

    baseAddresses ) : base( serviceType, baseAddresses )
    { }

    protected override void ApplyConfiguration()
    {
    base.ApplyConfiguration();
    }
    }

    ]]

    Note 2
    [[
    <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules>
    <add name="ScriptModule" preCondition="integratedMode"

    type="System.Web.Handlers.ScriptModule, System.Web.Extensions,

    Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </modules>
    <handlers>
    <remove name="WebServiceHandlerFactory-Integrated"/>
    <add name="ScriptResource" preCondition="integratedMode"

    verb="GET,HEAD" path="ScriptResource.axd"

    type="System.Web.Handlers.ScriptResourceHandler,

    System.Web.Extensions, Version=3.5.0.0, Culture=neutral,

    PublicKeyToken=31BF3856AD364E35" />
    </handlers>
    </system.webServer>


    ]]

    Note3
    [[
    <system.serviceModel>
    <bindings>
    <basicHttpBinding>
    <binding name="HttpStreaming1"

    maxReceivedMessageSize="1200000"
    transferMode="StreamedResponse"

    messageEncoding="Text" >
    <security mode="None" />
    </binding>
    </basicHttpBinding>
    </bindings>

    ]]
     
  4. Thanks for posting your fix.
     

Share This Page