我创建了一个非常简单的WCF,并通过执行“复制网站”将其部署到托管提供商。在本地,它设置为使用开发服务器(不在IIS中)。该域处于完全信任权限下。在本地,我可以访问Service.svc页面,但不在托管提供商。无法部署简单的WCF - 获取“无法找到资源”
的代码如下:
Service.svc
<%@ ServiceHost Language="C#" Debug="true" Service="Service" CodeBehind="~/App_Code/Service.cs" Factory="CustomHostFactory" %>
Service.cs
// NOTE: If you change the class name "Service" here, you must also update the reference to "Service" in Web.config and in the associated .svc file.
public class Service : IService
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
public CompositeType GetDataUsingDataContract(CompositeType composite)
{
if (composite.BoolValue)
{
composite.StringValue += "Suffix";
}
return composite;
}
}
class CustomHostFactory : ServiceHostFactory
{
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
// If more than one base address exists then return the second address,
// otherwise return the first address
if (baseAddresses.Length > 1)
{
return new ServiceHost(serviceType, baseAddresses[1]);
}
else
{
return new ServiceHost(serviceType, baseAddresses[0]);
}
}
}
class CustomHost : ServiceHost
{
public CustomHost(Type serviceType, params Uri[] baseAddresses)
: base(serviceType, baseAddresses)
{ }
}
的Web.config
<system.serviceModel>
<services>
<service name="Service" behaviorConfiguration="ServiceBehavior">
<!-- Service Endpoints -->
<endpoint address="" binding="wsHttpBinding" 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>
任何帮助吗?
我创建了一个虚拟目录(名称:WCFService),目标类型是一个指向wwwroot的文件夹。我有我的所有文件在wwwroot下,所以文件夹结构如下所示: wwwroot - > App_Code,App_Data,Service.svc,Web.config。 然后我浏览到http://aa.xx.com/WCFService/Service.svc,并得到相同的错误 – Nick 2009-11-15 17:57:49
我也将所有文件移动到wwwroot \ WCFService文件夹后尝试过,但遇到同样的问题:( – Nick 2009-11-15 18:07:40
你有没有得到这个工作?我有同样的问题,并真正搭上这个工作。 – ElHaix 2009-11-24 19:29:25