I have looked a lot into ServiceStack question in Stackoverflow and really running out of options. Spent a lot of time and tried a lot of options but not being able to run my ServiceStack services in IIS. I have a virtual directory under default website named as api and the physical location pointing that to is bin directory of servicestack assemblies. Just for testing I have put an index.htm in the bin folder and when on server I navigate to : localhost/api , I get the contents of index.htm from bin folder. However as you see in below code , my client invocation of Sericestack service via JSONServiceClient results in 404 exception. I am not sure what am I missing. Thanks much in advance
PS: have posted on SO but didnt receive a response.
Here is my code:
using System.Configuration;
using ServiceStack.OrmLite;
using ServiceStack.OrmLite.SqlServer;
// logging
using ServiceStack.Logging;
// Service Interface project
public class xxxService : Service
{
public List<xxxResponse> Get(xxxQuery xxxQuery)
}
[Route("/xxxFeature/{xxxSerialNo}/{xxxVersion}")]
public class xxxQuery : IReturn<List<xxxResponse>>
{
public string xxxSerialNo { get; set; }
public string xxxVersion { get; set; }
public string xxxId { get; set; }
public string xxxName { get; set; }
}
public class xxxResponse
{
public int ID { get; set; }
public string Name { get; set; }
public string Version { get; set; }
public string Size { get; set; }
public ResponseStatus ResponseStatus { get; set; }
}
Web.config
--
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<location path="api">
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
<authorization>
<allow users="*" />
</authorization>
</system.web>
<!-- Required for IIS7 -->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
</location>
<system.webServer>
<directoryBrowse enabled="false" />
</system.webServer>
</configuration>
Global.asax.cs
----
public class Global : System.Web.HttpApplication
{
public class xxxServiceAppHost : AppHostBase
{
public xxxServiceAppHost()
: base("xxx Services", typeof(xxxService).Assembly)
{
#region "Log4Net"
// log4net.Util.LogLog.InternalDebugging = true;
ServiceStack.Logging.LogManager.LogFactory = new Log4NetFactory(true);
Log4NetUtils.ConfigureLog4Net(ConfigurationManager.ConnectionStrings[ConfigurationManager.AppSettings["ServerDB"]].ConnectionString);
#endregion "Log4Net"
}
public override void Configure(Funq.Container container)
{
container.Register<IDbConnectionFactory>(c => new OrmLiteConnectionFactory(ConfigurationManager.ConnectionStrings[ConfigurationManager.AppSettings["ServerDB"]].ConnectionString, SqlServerDialect.Provider));
SetConfig(new EndpointHostConfig { ServiceStackHandlerFactoryPath = "api" });
}
}
// To avoid conflicts with ASP.NET MVC add ignore rule in Global.asax RegisterRoutes method e.g: routes.IgnoreRoute ("api/{*pathInfo}");
public void RegisterRoutes(RouteCollection routes)
{
routes.Ignore("api/{*pathInfo}");
}
protected void Application_Start(object sender, EventArgs e)
{
new xxxServiceAppHost().Init();
}
protected void Session_Start(object sender, EventArgs e)
{
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
}
protected void Session_End(object sender, EventArgs e)
{
}
protected void Application_End(object sender, EventArgs e)
{
}
}
// client invocation
try
{
xxxServiceClient = new JsonServiceClient("http://111.16.11.111/api/xxxService");
List<xxxResponse> xxxResponses = xxxServiceClient.Get(new xxxQuery { xxxSerialNo = "22222", xxxVersion = "0.0" });
}
catch (WebServiceException excp)
{
throw excp;
}
--
You received this message because you are subscribed to the Google Groups "ServiceStack .NET Open Source REST Web Services Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to servicestack...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.