WCF support

Discussion in 'Site Programming, Development and Design' started by japinthebox, Jan 8, 2010.

  1. Is WCF supported on Winhost? I haven't seen anyone talking about it, and I keep running into exceptions. The one I'm wrestling with now is:

    [ServiceActivationException: The requested service, '(Service.svc)' could not be activated. See the server's diagnostic trace logs for more information.]

    I think this is the most progress I've made, but I really can't tell because I keep getting cryptic exceptions.

    Any ideas?

    Thanks in advance,

    Rei
     
    Last edited by a moderator: Oct 14, 2015
  2. Ray

    Ray

    Can you give us the full error message, specifically the stack trace?
     
  3. I... can't, no. At least, not that particular exception. I'm getting a different one now.

    [WebException: The remote name could not be resolved: 'www.japinthebox.com']
    System.Net.HttpWebRequest.GetRequestStream() +5322142
    System.ServiceModel.Channels.WebRequestHttpOutput.GetOutputStream() +58

    [EndpointNotFoundException: There was no endpoint listening at (Service.svc) that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.]
    System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +7596735
    System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +275
    ServiceReference1.IService.DoWork() +0
    ServiceReference1.ServiceClient.DoWork() +15
    _Default.Page_Load(Object sender, EventArgs e) +40
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
    System.Web.UI.Control.OnLoad(EventArgs e) +99
    System.Web.UI.Control.LoadRecursive() +50
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

    I haven't touched anything since the last try, and clearly I can access www.japinthebox.com from my own computer, so I don't know why the webhost isn't seeing it.
     
  4. Ray

    Ray

    What is the endpoint address in your code for this WCF application? Can you also paste some of the codes?
     
  5. Here's the configuration. The baseAddressPrefixFilters list is needed, apparently, and the client stuff was generated by VS.

    Code:
    	<system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
          <baseAddressPrefixFilters>
            <add prefix="http://www.japinthebox.com"/>
          </baseAddressPrefixFilters>
        </serviceHostingEnvironment>
    		<bindings>
       <basicHttpBinding>
        <binding name="BasicHttpBinding_IService" closeTimeout="00:01:00"
         openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
         allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
         maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
         messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
         useDefaultWebProxy="true">
         <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
          maxBytesPerRead="4096" maxNameTableCharCount="16384" />
         <security mode="None">
          <message clientCredentialType="UserName" algorithmSuite="Default" />
         </security>
        </binding>
       </basicHttpBinding>
      </bindings>
    		<client>
       <endpoint address="http://www.japinthebox.com/test/Service.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
        contract="ServiceReference1.IService" name="BasicHttpBinding_IService" />
      </client>
    		<behaviors>
    			<serviceBehaviors>
    				<behavior name="ServiceBehavior">
    					<serviceMetadata httpGetEnabled="true"/>
    					<serviceDebug includeExceptionDetailInFaults="false"/>
    				</behavior>
    			</serviceBehaviors>
    		</behaviors>
    		<services>
    			<service behaviorConfiguration="ServiceBehavior" name="Service">
            <endpoint binding="basicHttpBinding" contract="IService"/>
    				<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    			</service>
    		</services>
    	</system.serviceModel>
    The service implementation and interface are just the default template stuff, except DoWork returns DateTime.Now.ToString(). I updated the service reference accordingly.

    Default.aspx has an asp:label named label, and it's set just once in the Load event handler:

    Code:
    protected void Page_Load(object sender, EventArgs e)
    {
        ServiceClient c = new ServiceClient();
        label.Text = c.DoWork();
    }
    Edit: By the way, this works just fine when I have the service running on my own computer and everything is pointing at localhost.
     
  6. Ray

    Ray

  7. Hah, I forgot to check that. Turns out I hadn't turned on ASP.NET compatibility.

    This test code works now; let me see if I can figure out the problem with my main project with the same thing in mind.

    Thanks much!
     
  8. Cool deal, glad you got it worked out.
     
  9. Bah, no go.

    I'm suspecting that the problem I'm having is the same as this one: the Linq to SQL objects have references to themselves, so WCF doesn't know how to serialize them without getting into a cyclical dependency problem.

    On the other hand, my development machine runs the code just fine. I'm thinking it could be an improvement in the newest build, since the server's running .NET/ASP.NET version 2.0.50727.3603 and 20.50727.4049 respectively, while mine is running 2.0.50727.4927 of both.

    Is it too much work/risk to upgrade to the latest build? The workaround noted on the site sort of complicates maintenance, since it involves modifying auto generated code.
     
  10. Still struggling with this problem.

    I'm out of troubleshooting ideas. Is there any chance that an upgrade can be done?
     
  11. Ray

    Ray

    Is it still giving the same error or is it a different error? By any chance, can you give us the URL and some instructions on how we can replicate it on our end?
     
  12. I'll see if I can reproduce the problem in a project that doesn't need to access an actual database.

    Oh, and it's a different error from the one that we solved earlier.
     
  13. Ray

    Ray

    Post the error message, I'll try to do some googling on it.
     
  14. ‘An error occurred while receiving the HTTP response to http://localhost:8731/Design_Time_Addresses/CarsLibrary/Service1/. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down).’

    There are numerous reasons for this error, but for me it seems to be happening for the reason that's mentioned in that link in my previous post: WCF apparently doesn't like circular references. The thing is, though, that it works fine on my machine, which I think it should, considering how much it complicates maintenance.
     
  15. I've isolated the problem to a small portion of code tested here: http://www.japinthebox.com/ServiceTest/Default.aspx

    The service is implemented in App_Code/Service.cs. It seems to have nothing at all to do with circular references; it just doesn't want to send any [DataContract] objects generated by Linq to SQL.

    Can you please have a look?
     
  16. Ray

    Ray

    It does sound like the connection string. Bear in mind that your applications can have any number of connection string. As an example if you are doing some forms membership/roles authentication the connection name maybe LocalSQLServer, if you have DotNetNuke you may also have a name of DotNetNuke. I've seen some programmers looking a one specific connection string name and swears that it is correct. It maybe correct but is it the connection string name that specific application is using?
    I can only suggest you create a simple application without all the bells and whistles on it. This way when it doesn't work then you know where it is failing. From there you can deduce what's on the WCF that should work and should not work.
     
  17. I've made a copy of the .aspx page with just the problematic code commented out at http://www.japinthebox.com/ServiceTest/TestWithoutWcfCalls.aspx .

    That URL by the way is possibly misleading; the situation is that the WCF service itself can access the database just fine, and it can return the values as strings. The problem arises when I try to return a Linq to SQL object. I have serialization set to Unidirectional, and this exact code works fine on my own test machine.

    Examining the Linq to SQL object code generated by Visual Studio, I see nothing wrong with it, as it looks identical to what I would have written myself. My suspicion is that the ASP.NET compiler on the server is generating something different.

    Here's the Page_Load method:

    protected void Page_Load(object sender, EventArgs e)
    {
    var wr = new StringWriter();

    var c = new ServiceClient();

    //This works fine
    wr.WriteLine(
    c.GetDataUsingDataContract(new ServiceReference1.CompositeType { StringValue = "test", BoolValue = true }).StringValue);

    //This works fine, even though it's accessing the database
    foreach (var v in c.GetStylistStrings())
    wr.WriteLine(v);

    //This crashes
    //foreach (var v in c.GetStylists())
    //wr.WriteLine(v.ContactID);

    text.Text = wr.ToString().Replace("\n", "<br/>\n");
    }
     
  18. Ray

    Ray

    What's the error you are getting? Is the same to what you posted before?
     
  19. Any ideas?

    If you can't upgrade .NET 2.0/aspx to the latest revision, I think my only other option in trying to find the cause is to switch to another hosting service.
     
  20. Ray

    Ray

  21. Same here.

    Whatever the problem was, I don't think you would have any different results at another host...
     
  22. I'm sorry I don't think you're reading my posts at all.

    This link is to demonstrate that there is nothing wrong with the SQL connection string.

    Also, please read the source code that I pasted above.
     
  23. Ray

    Ray

    I'm still getting hung up on this error you posted...

    ‘An error occurred while receiving the HTTP response to http://localhost:8731/Design_Time_Ad...rary/Service1/. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down).’

    I don't think we are looking at the right piece of code. What do you have in your web.config file?
     
  24. And Web.config:

    <?xml version="1.0"?>
    <configuration>
    <configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
    <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    </sectionGroup>
    </sectionGroup>
    </sectionGroup>
    </configSections>
    <appSettings/>
    <connectionStrings>
    <add name="DB_2872_aoiConnectionString" connectionString="Data Source=s02.Winhost.com;Initial Catalog=DB_2872_aoi;Persist Security Info=True;User ID=DB_2872_aoi_user;Password=(password)"
    providerName="System.Data.SqlClient" />
    </connectionStrings>
    <system.web>
    <!--
    Set compilation debug="true" to insert debugging
    symbols into the compiled page. Because this
    affects performance, set this value to true only
    during development.
    -->
    <compilation debug="false">
    <assemblies>
    <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>
    </compilation>
    <!--
    The <authentication> section enables configuration
    of the security authentication mode used by
    ASP.NET to identify an incoming user.
    -->
    <authentication mode="Windows"/>
    <!--
    The <customErrors> section enables configuration
    of what to do if/when an unhandled error occurs
    during the execution of a request. Specifically,
    it enables developers to configure html error pages
    to be displayed in place of a error stack trace.

    <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
    <error statusCode="403" redirect="NoAccess.htm" />
    <error statusCode="404" redirect="FileNotFound.htm" />
    </customErrors>
    -->
    <pages>
    <controls>
    <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </controls>
    </pages>
    <httpHandlers>
    <remove verb="*" path="*.asmx"/>
    <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
    </httpHandlers>
    <httpModules>
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </httpModules>
    </system.web>
    <system.codedom>
    <compilers>
    <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <providerOption name="CompilerVersion" value="v3.5"/>
    <providerOption name="WarnAsError" value="false"/>
    </compiler>
    <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <providerOption name="CompilerVersion" value="v3.5"/>
    <providerOption name="OptionInfer" value="true"/>
    <providerOption name="WarnAsError" value="false"/>
    </compiler>
    </compilers>
    </system.codedom>
    <!--
    The system.webServer section is required for running ASP.NET AJAX under Internet
    Information Services 7.0. It is not necessary for previous version of IIS.
    -->
    <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules>
    <remove name="ScriptModule"/>
    <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"/>
    <remove name="ScriptHandlerFactory"/>
    <remove name="ScriptHandlerFactoryAppServices"/>
    <remove name="ScriptResource"/>
    <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <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>
    <system.serviceModel>
    <bindings>
    <basicHttpBinding>
    <binding name="BasicHttpBinding_IService" closeTimeout="00:01:00"
    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
    useDefaultWebProxy="true">
    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    <security mode="None">
    <transport clientCredentialType="None" proxyCredentialType="None"
    realm="">
    </transport>
    <message clientCredentialType="UserName" algorithmSuite="Default" />
    </security>
    </binding>
    </basicHttpBinding>
    </bindings>
    <client>
    <endpoint address="http://www.japinthebox.com/servicetest/Service.svc"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
    contract="ServiceReference1.IService" name="BasicHttpBinding_IService" />
    </client>
    <services>
    <service name="Service" behaviorConfiguration="ServiceBehavior">
    <!-- Service Endpoints -->
    <endpoint address="" binding="basicHttpBinding" contract="IService">
    <!--
    Upon deployment, the following identity element should be removed or replaced to reflect the
    identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
    automatically.
    -->
    <identity>
    <dns value="localhost"/>
    </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    </service>
    </services>
    <behaviors>
    <serviceBehaviors>
    <behavior name="ServiceBehavior">
    <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
    <serviceMetadata httpGetEnabled="true"/>
    <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
    <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
    </serviceBehaviors>
    </behaviors>
    </system.serviceModel>
    </configuration>
     
    Last edited by a moderator: Oct 14, 2015
  25. Any luck?
     
  26. Ray

    Ray

    I'm suspecting that your application pool is being recycled. In which case can cause the error message you are seeing when we call on your WCF application. I suggest that you open a ticket to our support department. Outline in detailed steps on how to replicate the error you are seeing on your browser. Request that they monitor the server and verify if the application pool is being recycled. Its important that you out line the steps in detail else the results can be misinterpreted.
     
  27. There's a known stack overflow issue with returning Linq to SQL objects over WCF; when you have mutual references between two tables in the ORM, it'll crash with this same error message. I thought that may have been the case for me, but the same code works fine on my machine, and even when the ORM table has no references to other tables (or to itself, just to be sure), it still crashes.

    The only other difference that I can think of is the .NET/ASPX version.

    Can you think of anything else?
     
    Last edited by a moderator: Oct 14, 2015
  28. Ray

    Ray

    Set the IIS on your machine to recycle the application pool if it utilizes 100 MB of memory and 75% of the CPU's resources. I bet you will start seeing the same thing on your computer like you do on our server.
     

Share This Page