サーバーにデプロイした後、このサービスでエラーが発生する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
}
}
どこが間違っているのかわかりません。次のリンクの答えを試しましたが、何も機能しません。
誰かが助けることができるなら...