tags:

views:

21

answers:

2

i created a WCf service with a method that can receive GET requests using WebGET attribute, i want the same method to receive Soap calls too (that when the programmer does a Service reference to the WCF, he will be able to call the method).

my interface is:

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

My configuration is:

<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>

Can i make teh web method GetData a HTTP GET and SOAP method ?

what do i need to add to the Config ?

A: 

I would delete the webget attribute and use basichttpbinding. Then you can access the service with any soap or wcf client.

You can also host an asmx besides the svc, but that doesn't feel quiet right.

Regards,

Michel

Michel van Engelen
i have deleted the Webget attribute and used the Basichttpbinding, now the WCFtestClient doesn't work.my config is:<endpoint address="" binding="basicHttpBinding" contract="WCFTestingGetService.IService1" behaviorConfiguration="WebBehavior"></endpoint>is it ok ? would i be able to work the method with the browser if i erase the Webget ?
Rodniko
Also add <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> and make sure you have this in the servicebehavior section: <serviceMetadata httpGetEnabled="true" />
Michel van Engelen
A: 

You can use REST and SOAP in the same service but in the case of SOAP the operation will be called with HTTP POST. Your contract is defined correctly. You have to modify your configuration:

  <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> 
Ladislav Mrnka