スタック交換を検索しましたが、これと同様の質問がたくさんありますが、この問題を解決できませんでした。Azure Web サービス ロールではなく、Azure Web ロール (通常の Web ページも実行しているため) で WCF Web サービスを実行する必要があります。WCF サービスをセットアップし、web.config でエンドポイントを定義しましたが、ブラウザーまたはクライアントを介してエンドポイントに接続できません。以下はコードです - 誰かが何が間違っているのかアドバイスしてくれれば本当にありがたいです.
以下のコードを考えると、ブラウザで次のように動作すると仮定します
http://127.0.0.1:81/testAPI.svc/store/
しかし、指定しただけで404が返されます
http://127.0.0.1:81/testAPI.svc
Web サービスがあることを示すページが表示されます。
ItestAPI.cs
namespace MvcWebRole1
{
[ServiceContract]
public interface ItestAPI
{
[OperationContract]
[WebGet(UriTemplate = "store",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare)]
List<Financials> GetStoreActuals();
}
}
testAPI.svc
namespace MvcWebRole1
{
public class testAPI : ItestAPI
{
public List<Financials> GetStoreActuals()
{
return GetActuals();
}
private List<Financials> GetActuals()
{
List<Financials> Actuals = new List<Financials>
{
new Financials
{
Store = "Store1", Profit = "10000000", Sales = "2000000"
},
new Financials
{
Store = "Store2", Profit = "20000000", Sales = "30000"
},
new Financials
{
Store = "Store3", Profit = "30000000", Sales = "4000000"
},
new Financials
{
Store = "Store4", Profit = "4000000", Sales = "500000"
},
};
return Actuals;
}
}
[DataContract]
public class Financials
{
[DataMember]
public string Store { get; set; }
[DataMember]
public string Sales { get; set; }
[DataMember]
public string Profit { get; set; }
}
}
そして最後にweb.configのサービス モデル
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="servicebehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="restbehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name ="MvcWebRole1.testAPI" behaviorConfiguration ="servicebehavior" >
<endpoint name ="RESTEndPoint"
contract ="MvcWebRole1.ItestAPI"
binding ="webHttpBinding"
address =""
behaviorConfiguration ="restbehavior"/>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
ここで何か助けてくれてありがとう!