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
Web.Config
Client:
url: http://localhost:81/ExternalServices/WS/SPP/REST/SPPService.svc
Message: The service '/ExternalServices/WS/SPP/ REST/SPPSe rvice.svc' cannot be activated due to an exception during compilation. Â The exception message is: The type 'ProjectName.ExternalServi ces.WS.SPP .Rest.SPPS ervice', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/servic eHostingEn vironment/ serviceAct ivations could not be found.
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" %>
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>
ISPPService.csnamespace ProjectName.ExternalServices.WS.SPP.REST
{
[ServiceContract]
public interface ISPPService
{
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "GetProductionDetail")]
string GetProductionDetail(Stream data);
}
}
SPPService.csnamespace 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";
}
}
}
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);
}
}
Message: The service '/ExternalServices/WS/SPP/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
ASKER
Open in new window