我创建了一个 wcf 服务,该服务在服务器上部署后出现错误,该服务在本地主机上运行良好,所以我不知道我错在哪里
我的Service.svc是:
<%@ ServiceHost Language="C#" Debug="true" Service="mobile.Service" CodeBehind="Service.svc.cs" %>
我的web.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!--Path for Photo Gallery Images-->
<add key="PhotoGalleryPath" value="http://www.abc.com/photogallery/"/>
<!--Path for Video Gallery Images-->
<add key="VideoPath" value="http://www.abc.com/video/"/>
<!--Path for Video URL-->
<add key="VideoURLPath" value="http://ventunotech.com/watch/"/>
<!--Path for Web URL for Share News through mail, FB, Twitter-->
<add key="WebUrlforNews" value="http://www.abc.com/news.aspx?id="/>
<add key="WebUrlforArticle" value="http://www.abc.com/article.aspx?id="/>
<!--Folder Name with Path for News and Article Images (Change this according to Your Server Folder Path) and give this folder to write permission-->
<add key="ImagePath" value="http://www.abc.com/mobile/images/"/>
</appSettings>
<connectionStrings>
<add name="con" connectionString="Data Source=184.122.1.55;Initial Catalog=Data;Integrated Security=SSPI;"/>
</connectionStrings>
<system.web>
<compilation debug="true"/>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service behaviorConfiguration="APIService.ServiceBehavior" name="APIService.Service">
<endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" contract="APIService.IService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="APIService.ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="web" maxBufferPoolSize="1500000" maxReceivedMessageSize="1500000" maxBufferSize="1500000">
<readerQuotas maxArrayLength="656000" maxBytesPerRead="656000" maxDepth="32" maxNameTableCharCount="656000" maxStringContentLength="656000"/>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
我的IService.cs
namespace APIService
{
[ServiceContract]
public interface IService
{
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "/GetCities", BodyStyle = WebMessageBodyStyle.WrappedRequest,
RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
ItemList GetCities();
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "/GetStates", BodyStyle = WebMessageBodyStyle.WrappedRequest,
RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
ItemList GetStates();
}
[DataContract]
public class Item
{
[DataMember]
public string ID { get; set; }
[DataMember]
public string Name { get; set; }
}
[DataContract]
public class ItemList
{
[DataMember]
public List<Item> Items { get; set; }
}
}
我的Service.svc.cs
namespace APIService
{
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service : IService
{
SqlConnection offcon = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());
SqlDataAdapter adp;
SqlCommand cmd;
DataSet ds = new DataSet();
DataSet ds1 = new DataSet();
ItemList items = new ItemList();
NewsList newslist = new NewsList();
CommentList commentslist = new CommentList();
UserProfile userPrf = new UserProfile();
#region CityList
public ItemList GetCities()
{
try
{
adp = new SqlDataAdapter("Select * from tblCity", offcon);
adp.Fill(ds, "City");
DataTable City = ds.Tables["City"];
var item = (from d in City.AsEnumerable()
select new Item
{
ID = d.Field<Int32>("intCityId").ToString(),
Name = d.Field<string>("strTitle")
}).ToList();
items.Items = item;
}
catch (Exception ex)
{
ex.Message.ToString();
}
return new ItemList { Items = items.Items };
}
#endregion
#region StateList
public ItemList GetStates()
{
try
{
adp = new SqlDataAdapter("select * from tblState ", offcon);
adp.Fill(ds, "State");
DataTable State = ds.Tables["State"];
var item = (from d in State.AsEnumerable()
select new Item
{
ID = d.Field<Int32>("intStateId").ToString(),
Name = d.Field<string>("strTitle")
}).ToList();
items.Items = item;
}
catch (Exception ex)
{
ex.Message.ToString();
}
return new ItemList { Items = items.Items };
}
#endregion
}
}
我不知道我错在哪里,我尝试了以下链接的答案,但对我没有任何作用:
如果有人可以帮助...