次のようなWCFサービスがあります。
[ServiceContract]
public class SomeService
{
[WebInvoke(UriTemplate = "/test", Method = "POST")]
public string Test()
{
using (var reader = OperationContext.Current.RequestContext.RequestMessage.GetReaderAtBodyContents())
{
var content = reader.ReadOuterXml().Replace("<Binary>", "").Replace("</Binary>", "");
return content;
}
}
}
そして、次のような構成ファイルがあります。
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="Project.SomeService">
<endpoint address="" binding="webHttpBinding" contract="Project.SomeService"
bindingConfiguration="webHttpBinding_SomeService" behaviorConfiguration="endpointBehavior_SomeService" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="webHttpBinding_SomeService">
<security mode="None"></security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="endpointBehavior_SomeService">
<webHttp helpEnabled="true" defaultOutgoingResponseFormat="Json" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!-- 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="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
しかし、POST
メソッドを使用してこのURLでフィドラーを使用して呼び出すと:
http://localhost:1111/SomeService.svc/Test
体で:
asdasd
代わりに返されますがYXNkYXNk
、なぜこのようになったのですか?
私のコードは、C#、フレームワーク 4、VS2010Pro でビルドされています。
助けてください。前もって感謝します。