views:

367

answers:

1

Hi,

i am trying to host a service in IIS which has 2 methods... 1 of them can also be accesed via a simple HTTP-GET request...

This is my config:

  <service name="Svc.PaymentService" behaviorConfiguration="DefaultBehavior">
    <endpoint address="PaymentService.svc/"
              bindingName="Http"
              binding="basicHttpBinding"
              bindingConfiguration="httpBinding"
              contract="Svc.IPaymentService" />
    <endpoint address="WEBGETPaymentService.svc/"
              behaviorConfiguration="EndpointWebGetBehavior"
              binding="webHttpBinding" 
              contract="Svc.IPaymentService" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/MyService/" />
      </baseAddresses>
    </host>
  </service>

the content auf the SVC files is just a simple redirect to my classes

<%@ ServiceHost Service="Svc.PaymentService"  %>
<%@ Assembly Name="MyService" %>

and the interface looks like this:

    [OperationContract]
    string SOAPMethod(
        string test);

    [OperationContract]
    [WebGet(UriTemplate = "asdf?test={test}")]
    string RESTfulMethod(
        string test);

When i am trying to host the service in IIS and call it via HTTP-GET Request, i always receive a 404...

http://localhost/MyService/WEBGETPaymentService.svc/RESTfulMethod/asdf?test=hello

Anyway, when i try to call the SOAP method via PaymentService.svc it works...

Any ideas what the mistake is?

Thanks

+3  A: 

Well, in order to use the webHttpBinding, you need to use the WebServiceHost (see MSDN docs) in your REST based *.svc file.

So your WEBGETPaymentService.svc should look like this:

<%@ ServiceHost Language="C#" Debug="True" 
    Service="Svc.PaymentService"
    Factory="System.ServiceModel.Activation.WebServiceHostFactory"  %>

so in that case, it will then use the WebServiceHost and do all the necessary magic to make REST possible in WCF.

Also check out the WCF REST developer center on MSDN for more info on how to host and use WCF REST services.

marc_s
mhm, it didn't solve my problem.. now i get a "No eservice endpoint defined", but i am quite sure the definition is correct...
David
what URL do you use? Based on your config, it would have to be something like `http://localhost/MyService/WEBGETPaymentService.svc/asdf?test=abc` - are you missing part of that URL, maybe??
marc_s
ah, it turns out i am an idiot.. thanks for your help ;)
David