Reputation: 3665
I did the search again and again but I don't really know what am I missing. I have WCF method and after calling, the service return with error 404, resource can not be found.
The url like this: localhost:3522/AccountService.svc/accountbalance/1
I run it from Visual with IIS 8 Express.
The WCF method like this
[ServiceContract]
public interface IAccountService
{
[OperationContract]
[WebGet(UriTemplate = "accountbalance/{accountId}")]
decimal GetAccountBalance(string accountId);
}
And this is my web.config
<bindings>
</basicHttpBinding>
<webHttpBinding>
<binding name="WebHttpBinding">
<security mode="Transport">
<transport clientCredentialType="Windows" proxyCredentialType="Windows" />
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ProfileServiceDefaultBehavior"
name="MyWcfService.AccountService">
<endpoint behaviorConfiguration="RestFulBehavior" binding="webHttpBinding"
bindingConfiguration="WebHttpBinding" name="AccountServiceEndpoint"
bindingName="AccountServiceBinding" contract="MyWcfService.IAccountService" />
<endpoint address="mex" behaviorConfiguration="" binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="RestFulBehavior">
<webHttp automaticFormatSelectionEnabled="true" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ProfileServiceDefaultBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
Upvotes: 1
Views: 7722
Reputation: 3665
I resolved the issue by 2 ways:
Transport
security mode, SSL
must be enabled and the service must be call in SSL channed.TransportCredentialOnly
security mode, the Restful service works fine with http
.@adkSerenity: thanks for the SSL suggestion, and tracing.
Best Regards, Vu
Upvotes: 2
Reputation: 7067
Based on a brief review, the service section of the config file seems to be missing the baseAddresses element.
<host>
<baseAddresses>
<add baseAddress="https://localhost:3522/AccountService.svc" />
</baseAddresses>
</host>
In addition, you may want to consider enabling WCF Tracing and Logging, so you can review the WCF service startup events for any errors. The following link provides a good overview:
http://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx
Final note: since your service binding has [security mode="Transport"], make sure your server side certificate is configured correctly to support ssl.
Regards,
Upvotes: 2