単純な文字列を返す REST サービスがあります。WCF テスト クライアントを使用すると、サービスは期待値を返しますが、ブラウザーを使用してサービスにアクセスすると、ページが空になります。何か案は?すべてのコードは以下です。
CUCC.svc.cs
public class CUCC : ICUCC
{
public string AllAtms(string serviceKey)
{
//return new XElement("AllAtms") ;
return "test";
}
//public XElement AllOrganizationAtms(string serviceKey, int organizationId)
//{
// return new XElement("AllOrganizationAtms");
//}
}
ICUCC.cs
[ServiceContract]
public interface ICUCC
{
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "AllAtms/{serviceKey}")]
string AllAtms(string serviceKey);
//[OperationContract]
//[WebInvoke(Method = "GET",
// ResponseFormat = WebMessageFormat.Xml,
// BodyStyle = WebMessageBodyStyle.Wrapped,
// UriTemplate = "AllAtms/{serviceKey}/{organizationId}")]
//XElement AllOrganizationAtms(string serviceKey, int organizationId);
}
web.config
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings />
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<httpRuntime />
</system.web>
<system.serviceModel>
<services>
<service name="CUCC.AllAtms" behaviorConfiguration="ServiceBehaviour">
<endpoint address="" binding="webHttpBinding" contract="CUCC.AllAtms" behaviorConfiguration="web"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true" httpsGetBinding="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
アップデート
申し訳ありませんが、私が使用している URL を含めるのを忘れていました。
http://localhost:51870/CUCC.svc/AllAtms/testing