tags:

views:

1013

answers:

3

Hi, I have a WCF RESTFul service declared thus:

[ServiceContract]
public interface IGasPriceService
{
    [OperationContract]
    [WebGet
        (ResponseFormat = WebMessageFormat.Xml,
        BodyStyle = WebMessageBodyStyle.Bare,
        UriTemplate = "/GetGasPrice/For/ZipCode/{zipCode}"
        )]
    GasPriceData GetPriceData(string zipCode);

    [OperationContract]
    [WebGet
        (RequestFormat = WebMessageFormat.Xml,
        ResponseFormat = WebMessageFormat.Xml,
        BodyStyle = WebMessageBodyStyle.Bare,
        UriTemplate = "/GetGasPrice/For/City/{city}"
        )]
    GasPriceData GetPriceDataForCity(string city);

    [OperationContract]
    [WebInvoke
        (Method = "POST",
        RequestFormat = WebMessageFormat.Xml,
        UriTemplate = "/SetGasPrice/For/ZipCode/{zipCode}/Price/{price}"
        )]
    void SetPriceDataForZipCode(string zipCode, string price);
}

The methods GetPriceData and GetPriceDataforCity work, but the SetPriceDataForZipCode does not work. Can any one let me know why this dows not work.

When I issue a request like:

http://localhost:7002/SetGasPrice/For/ZipCode/45678/7.80

the message that I get is: EndPoint Not Found

Any ideas how to fix this?

thanks,

Arun

+4  A: 

Your url needs to be:

 http://localhost:7002/SetGasPrice/For/ZipCode/45678/Price/7.80

Or you need to change your template to:

"/SetGasPrice/For/ZipCode/{zipCode}/{price}"
tvanfosson
A: 

Thanks for the reply. As per your suggestion, I changed it to

http://localhost:7002/SetGasPrice/For/ZipCode/54568/5.788

and

    [OperationContract]
    [WebInvoke
        (Method = "POST",
        RequestFormat = WebMessageFormat.Xml,
        UriTemplate = "/SetGasPrice/For/ZipCode/{zipCode}/{price}"
        )]
    void SetPriceDataForZipCode(string zipCode, string price);

That gives me the message:

Method not allowed.

Any ideas how to resolve this?

thanks, Arun

this is a separate question altogether. you should prob accept tvanfosson's answer and repost if you have a new question
Greg Dean
Agreed with Greg.
Terry Donaghe
A: 

try

UriTemplate = "/SetGasPrice/For/ZipCode/{zipCode}/{dollars}.{cents}"