Reputation:
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?
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?
Upvotes: 2
Views: 3310
Reputation:
try
UriTemplate = "/SetGasPrice/For/ZipCode/{zipCode}/{dollars}.{cents}"
Upvotes: 1
Reputation: 532635
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}"
Upvotes: 5