1

WebGET属性を使用してGET要求を受信できるメソッドを使用してWCfサービスを作成しました。同じメソッドで、Soap呼び出しも受信する必要があります(プログラマーがWCFへのサービス参照を行うと、メソッドを呼び出すことができます)。

私のインターフェースは:

[ServiceContract] 
public interface IService1 
{ 
  [OperationContract] 
  [WebGet(UriTemplate = "GetData?value={value}")] 
  string GetData(int value); 
} 

私の構成は次のとおりです。

<configuration>
 <system.web>
  <compilation debug="true" targetFramework="4.0" />
 </system.web>
 <system.serviceModel>
  <behaviors>
   <serviceBehaviors>    
    <behavior name="MyServiceBehavior">
     <serviceMetadata httpGetEnabled="true"/>
     <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior> 
   </serviceBehaviors>
   <endpointBehaviors>
    <behavior name="WebBehavior">
     <webHttp />
    </behavior>
   </endpointBehaviors>
  </behaviors>
  <services>
   <service name="WCFTestingGetService.Service1" behaviorConfiguration="MyServiceBehavior" >
    <endpoint address="" binding="webHttpBinding" contract="WCFTestingGetService.IService1" behaviorConfiguration="WebBehavior"></endpoint>
   </service>
  </services>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
 </system.serviceModel>
 <system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
 </system.webServer>
</configuration>

WebメソッドGetDataをHTTPGETおよびSOAPメソッドにすることはできますか?

構成に何を追加する必要がありますか?

4

2 に答える 2

2

同じサービスでRESTとSOAPを使用できますが、SOAPの場合、操作はHTTPPOSTで呼び出されます。契約は正しく定義されています。構成を変更する必要があります。

  <services> 
   <service name="WCFTestingGetService.Service1" behaviorConfiguration="MyServiceBehavior" > 
    <endpoint address="" binding="webHttpBinding" contract="WCFTestingGetService.IService1" behaviorConfiguration="WebBehavior"/>
    <endpoint address="soap" binding="basicHttpBinding" contract="WCFTestingGetService.IService1"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
   </service> 
  </services> 
于 2010-09-01T08:40:21.363 に答える
-1

webget属性を削除し、basichttpbindingを使用します。次に、任意のsoapまたはwcfクライアントを使用してサービスにアクセスできます。

svc以外にasmxをホストすることもできますが、それは静かではありません。

よろしく、

ミシェル

于 2010-09-01T08:11:27.747 に答える