Calling WCF Module through URI Template

Topics: General, Writing modules
Jan 14, 2012 at 7:04 AM
Edited Jan 16, 2012 at 4:30 AM

Hi ,

I am creating a WCF in orchard module with URI template so I can directly send the request to the service methods.

My WCF module is working, if I consume the service with reference in any other application but calling through request by POST method gives me 404,

Following is service interface code

    public interface IWCFMessageService:ISingletonDependency
        [OperationContract(Name = "LoginIn")]
        [WebInvoke(UriTemplate = "LoginIn", Method = "POST")]
        Boolean LoginIn();

       [WebInvoke(UriTemplate = "LogOut", Method = "POST")]
        Boolean LogOut();


and hosted through routes 

   private static ServiceRoute _route = new ServiceRoute("Services/MessageSystem",
                                                  new OrchardServiceHostFactory(),
        public IEnumerable<RouteDescriptor> GetRoutes()
            return new[] {
                     new RouteDescriptor { 
                         Priority = 20,
                         Route = _route


and following is the calling through URL


   System.Net.WebRequest _request = System.Net.WebRequest.Create("http://localhost:30320/OrchardLocal/Services/MessageSystem/LoginIn");
            _request.ContentType = "application/x-www-form-urlencoded";
            _request.Method = "POST";
            //We need to count how many bytes we're sending. Post'ed Faked Forms should be name=value&
            byte[] bytes = System.Text.Encoding.ASCII.GetBytes("");
            _request.ContentLength = bytes.Length;
            System.IO.Stream _stream = _request.GetRequestStream();
            _stream.Write(bytes, 0, bytes.Length); //Push it out there
            System.Net.WebResponse _responce = _request.GetResponse();


but if i am using same service and this calling out side the orchard it working perfectly.

Help me out



Mar 20, 2012 at 9:55 AM

I have the same problems. :(

Mar 20, 2012 at 10:31 AM

fixed in this changeset