Link to home
Start Free TrialLog in
Avatar of pzozulka
pzozulka

asked on

WCF Rest Service Timeout Exception

This is my first WCF rest service, so I'm not sure if I'm doing something wrong. I am getting a timeout exception when trying to call the service from the client. See below. Not sure where to start troubleshooting.

See full event log error at the bottom:

Created a new WCF Service:
SPPService.svc
<%@ ServiceHost Language="C#" Service="ProjectName.ExternalServices.WS.SPP.Rest.SPPService" %>

Open in new window


Web.Config
<system.serviceModel>
    <services>
		<service name="ProjectName.ExternalServices.WS.SPP.Rest.SPPService" behaviorConfiguration="defaultBehaviour">
			<endpoint name="webHttpsBinding" address="" binding="webHttpBinding" contract="ProjectName.ExternalServices.WS.SPP.Rest.ISPPService"
				behaviorConfiguration="webHttp" bindingConfiguration="webHttpTransportSecurity">
			</endpoint>
			<endpoint name="mexHttpsBinding" address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"></endpoint>
		</service>
		<bindings>
			<webHttpBinding>
				<binding name="webHttpTransportSecurity">
					<security mode="Transport"></security>
				</binding>
			</webHttpBinding>
		</bindings>
		<behaviors>
			<endpointBehaviors>
				<behavior name="webHttp">
					<webHttp helpEnabled="true" />
				</behavior>
			</endpointBehaviors>
			<serviceBehaviors>
				<behavior name="defaultBehaviour">
					<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
					<serviceDebug includeExceptionDetailInFaults="false" />
				</behavior>
				<behavior name="">
					<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
					<serviceDebug includeExceptionDetailInFaults="false" />
				</behavior>
			</serviceBehaviors>
		</behaviors>

Open in new window

ISPPService.cs
namespace ProjectName.ExternalServices.WS.SPP.REST
{
    [ServiceContract]
    public interface ISPPService
    {
        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "GetProductionDetail")]
        string GetProductionDetail(Stream data);
    }
}

Open in new window

SPPService.cs
namespace ProjectName.ExternalServices.WS.SPP.REST
{
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class SPPService : ISPPService
    {
        public string GetProductionDetail(Stream xmlRequest)
        {
            //string strXml = getXmlString(xmlRequest);
            //return SPPServiceHelper.GetProductionDetail(strXml);
            return "hello";
        }
    }
}

Open in new window



Client:
url: http://localhost:81/ExternalServices/WS/SPP/REST/SPPService.svc
private void processRestService(string url, string requestXml)
        {
            try
            {
                string result = string.Empty;
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
                req.Method = "POST";
                req.ContentType = "application /x-www-form-urlencoded";
                byte[] byteXml = Encoding.Default.GetBytes(requestXml);

                Stream stream = req.GetRequestStream();
                stream.Write(byteXml, 0, byteXml.Length);
                stream.Close();

                using (WebResponse response = req.GetResponse())
                {
                    using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                    {
                        result = reader.ReadToEnd();
                        req = null;
                    }
                }
                txtResponseXml.Text = HttpUtility.HtmlDecode(result);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

Open in new window


Message: The service '/ExternalServices/WS/SPP/REST/SPPService.svc' cannot be activated due to an exception during compilation.  The exception message is: The type 'ProjectName.ExternalServices.WS.SPP.Rest.SPPService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
ASKER CERTIFIED SOLUTION
Avatar of Aaron Jabamani
Aaron Jabamani
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pzozulka
pzozulka

ASKER

This did not provide any additional information regrading the error message posted in the original post.

<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
	<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
		<EventID>131075</EventID>
		<Type>3</Type>
		<SubType Name="Warning">0</SubType>
		<Level>4</Level>
		<TimeCreated SystemTime="2016-05-19T21:25:26.5420864Z" />
		<Source Name="System.ServiceModel" />
		<Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
		<Execution ProcessName="w3wp" ProcessID="7648" ThreadID="518" />
		<Channel/>
		<Computer>I1WHL-IT14-W7</Computer>
	</System>
	<ApplicationData>
		<TraceData>
			<DataItem>
				<TraceRecord Severity="Warning" Channel="Analytic" xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord">
					<TraceIdentifier>http://msdn.microsoft.com//library/System.ServiceModel.Diagnostics.ThrowingException.aspx</TraceIdentifier>
					<Description>Throwing an exception. Source: System.ServiceModel 4.0.0.0. Exception details: System.ServiceModel.ServiceActivationException: The service '/ExternalServices/WS/SPP/REST/SPPService.svc' cannot be activated due to an exception during compilation.  The exception message is: The type 'ABC.WebApp.ExternalServices.WS.SPP.Rest.SPPService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.. ---&gt; System.InvalidOperationException: The type 'ABC.WebApp.ExternalServices.WS.SPP.Rest.SPPService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
   at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
   --- End of inner exception stack trace ---</Description>
					<AppDomain>/LM/W3SVC/2/ROOT-36-131081665645038842</AppDomain>
					<Exception>
						<ExceptionType>System.ServiceModel.ServiceActivationException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
						<Message>The service '/ExternalServices/WS/SPP/REST/SPPService.svc' cannot be activated due to an exception during compilation.  The exception message is: The type 'ABC.WebApp.ExternalServices.WS.SPP.Rest.SPPService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found..</Message>
						<StackTrace>   at System.Runtime.Diagnostics.EtwDiagnosticTrace.WriteExceptionToTraceString(XmlTextWriter xml, Exception exception, Int32 remainingLength, Int32 remainingAllowedRecursionDepth)
   at System.Runtime.Diagnostics.EtwDiagnosticTrace.ExceptionToTraceString(Exception exception, Int32 maxTraceStringLength)
   at System.Runtime.Diagnostics.EtwDiagnosticTrace.GetSerializedPayload(Object source, TraceRecord traceRecord, Exception exception, Boolean getServiceReference)
   at System.Runtime.TraceCore.ThrowingException(EtwDiagnosticTrace trace, String param0, String param1, Exception exception)
   at System.Runtime.ExceptionTrace.TraceException[TException](TException exception, String eventSource)
   at System.Runtime.ExceptionTrace.AsError(Exception exception)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object state)
   at System.ServiceModel.AspNetPartialTrustHelpers.PartialTrustInvoke(ContextCallback callback, Object state)
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequestWithFlow(Object state)
   at System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
						</StackTrace>
						<ExceptionString>System.ServiceModel.ServiceActivationException: The service '/ExternalServices/WS/SPP/REST/SPPService.svc' cannot be activated due to an exception during compilation.  The exception message is: The type 'ABC.WebApp.ExternalServices.WS.SPP.Rest.SPPService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.. ---&amp;gt; System.InvalidOperationException: The type 'ABC.WebApp.ExternalServices.WS.SPP.Rest.SPPService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
   at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
   --- End of inner exception stack trace ---</ExceptionString>
						<InnerException>
							<Exception>
								<ExceptionType>System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
								<Message>The type 'ABC.WebApp.ExternalServices.WS.SPP.Rest.SPPService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.</Message>
								<StackTrace>   at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)</StackTrace>
								<ExceptionString>System.InvalidOperationException: The type 'ABC.WebApp.ExternalServices.WS.SPP.Rest.SPPService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
   at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)</ExceptionString>
							</Exception>
						</InnerException>
					</Exception>
				</TraceRecord>
			</DataItem>
		</TraceData>
	</ApplicationData>
</E2ETraceEvent>
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
	<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
		<EventID>131074</EventID>
		<Type>3</Type>
		<SubType Name="Error">0</SubType>
		<Level>2</Level>
		<TimeCreated SystemTime="2016-05-19T21:25:26.5470869Z" />
		<Source Name="System.ServiceModel" />
		<Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
		<Execution ProcessName="w3wp" ProcessID="7648" ThreadID="518" />
		<Channel/>
		<Computer>I1WHL-IT14-W7</Computer>
	</System>
	<ApplicationData>
		<TraceData>
			<DataItem>
				<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error">
					<TraceIdentifier>http://msdn.microsoft.com//library/System.ServiceModel.Diagnostics.EventLog.aspx</TraceIdentifier>
					<Description>Wrote to the EventLog.</Description>
					<AppDomain>/LM/W3SVC/2/ROOT-36-131081665645038842</AppDomain>
					<ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/DictionaryTraceRecord">
						<CategoryID.Name>EventLogCategory</CategoryID.Name>
						<CategoryID.Value>5</CategoryID.Value>
						<InstanceID.Name>EventId</InstanceID.Name>
						<InstanceID.Value>3221356547</InstanceID.Value>
						<Value0>System.ServiceModel.ServiceHostingEnvironment+HostingManager/23490878</Value0>
						<Value1>System.ServiceModel.ServiceActivationException: The service '/ExternalServices/WS/SPP/REST/SPPService.svc' cannot be activated due to an exception during compilation.  The exception message is: The type 'ABC.WebApp.ExternalServices.WS.SPP.Rest.SPPService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.. ---&amp;gt; System.InvalidOperationException: The type 'ABC.WebApp.ExternalServices.WS.SPP.Rest.SPPService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
   at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
   --- End of inner exception stack trace ---
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath, EventTraceActivity eventTraceActivity)</Value1>
					</ExtendedData>
				</TraceRecord>
			</DataItem>
		</TraceData>
	</ApplicationData>
</E2ETraceEvent>
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
	<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
		<EventID>131074</EventID>
		<Type>3</Type>
		<SubType Name="Error">0</SubType>
		<Level>2</Level>
		<TimeCreated SystemTime="2016-05-19T21:25:26.5490871Z" />
		<Source Name="System.ServiceModel" />
		<Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
		<Execution ProcessName="w3wp" ProcessID="7648" ThreadID="518" />
		<Channel/>
		<Computer>I1WHL-IT14-W7</Computer>
	</System>
	<ApplicationData>
		<TraceData>
			<DataItem>
				<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error">

Open in new window

Didn't realize the contents of the .SVC file are case-sensitive. The word "Rest" in the .SVC file should have been all caps to match the all caps logical path.