更新の回答:
VS の [サービス参照の追加] ダイアログを使用してプロキシ コードを作成したようです。VS ASR ダイアログは WCF REST を完全にはサポートしていないため、プロキシ コードに [WebInvoke] 属性がありません。[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
クライアント プロキシの操作に属性を追加してみてください。ソース:
[OperationContract] メソッドで複数のパラメーターが使用されている場合、WCF サービス プロキシが例外をスローする
あなたの質問を明確に理解できれば。各メソッドの前に WebInvoke 属性を追加する場合は、( IService.cs ) のような WCF サービス インターフェイス クラスに移動します。App_Code フォルダーに配置されている可能性があります。
[ServiceContract]
public interface IService
{
[OperationContract]
[WebInvoke(Method = "GET",ResponseFormat = WebMessageFormat.Json,BodyStyle = WebMessageBodyStyle.Wrapped,UriTemplate = "LogIn/{username}/{password}")]
void DoWork();
}
プロキシ クラスの設定を変更する場合は、web 構成の system.ServiceModel タグの下に移動します。
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:56662/WebSite2/Service.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
contract="ServiceReference1.IService" name="BasicHttpBinding_IService" />
</client>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>