I'm using VS2012 and ServiceStack 4.0.46. I have setup a web service which is working as expected. I now need to setup a second web service which makes calls to the first one.
In my second web service I have tried to add a ServiceStack reference to the first service. This mostly works however in the file created I get
/* Options:
Date: 2015-11-11 09:25:20
Version: 4.046
BaseUrl: http://nlc20030:8008/api
//GlobalNamespace:
//MakePartial: True
//MakeVirtual: True
//MakeDataContractsExtensible: False
//AddReturnMarker: True
//AddDescriptionAsComments: True
//AddDataContractAttributes: False
//AddIndexesToDataMembers: False
//AddGeneratedCodeAttributes: False
//AddResponseStatus: False
//AddImplicitVersion:
//InitializeCollections: True
//IncludeTypes:
//ExcludeTypes:
//AddDefaultXmlNamespace: http://schemas.servicestack.net/types
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using ServiceStack;
using ServiceStack.DataAnnotations;
using NLC.Library;
using Waste.Collection;
using Wards;
using Syndication.RSS;
using AbandonedVehicle;
using Search.Address;
using Waste.Collection.Asbestos;
using Waste.Collection.Asbestos.SinceDate;
using Waste.Collection.Bulky;
using Waste.Collection.Bulky.SinceApril;
using Waste.Collection.Bulky.SinceDate;
using Calendar.BinCollection;
using Calendar;
using Search.Civica.Client;
using Search.Civica;
using Dog.Fouling.Cleanse;
using Waste.Litter.Cleanse;
using Search.Confirm;
using CrossSystem;
using Dog;
using DateInfo.English;
using Encrypt;
using Flytipping;
using ;
using Dog.Fouling.Investigate;
using Waste.Litter.Investigate;
using IsValid.NINO.ECS;
using IsValid.NASS;
using IsValid.NINO;
using IsValid;
using IsValid.PostCode;
using IsValid.UPRN;
using IsValid.USRN;
using Job;
using Job.Recent;
using Light;
using LLPG;
using LLPG.Property;
using Requests;
using Noise;
using Odour;
using VictoriaForms;
using Waste.PrivateProperty;
using Encrypt.RC4.Hex;
using Encrypt.RC4;
using Search;
using Smoke;
using SOA.Call.Environment;
using SOA.Call.Environment.Operations;
using SOA.Call.Environment.Operations.System.IsError;
using SOA.Call.Environment.Operation.System.IsError.StartRecord;
using SOA.Call.Environment.Operations.System;
using SOA.Message;
using SOA;
using Search.Street;
using Waste.Collection.Tomorrow.Feed;
using Waste.Collections.Tomorrow;
It's the
using ;
line which is causing me issues
I've checked the DTO's in my original web service and there appears to be nothing that is out of order. If I delete the line above, it reappears when I save the file.
I've clearly done something wrong but am unsure how to figure out what
After some investigation I have discovered the root cause of this issue, it was, as I originally suspected, my fault. I tracked it down to one particular Service and it turned out that the get method was using the wrong class, which happened to have the same name, as the intended request DTO.
So I had
Public Class HonorificService
Inherits ServiceStack.Service
Public Function [Get](request As Honorific) As Object
When I should have had
Public Class HonorificsService
Inherits ServiceStack.Service
Public Function [Get](request As Lookups.Honorific) As Object
Related
I have a reporting-based website using ServiceStack and OrmLite, using a SQL Server back-end. Due to the duration of some of the reports, I'd like to either globally, or selectively (via Service-derived class or some attribute) make queries that run reports have a longer CommandTimeout. I'd like to keep using the existing code to query data for the reports (Db.Select, Db.SqlList calls), so I won't have to write boiler-plate code in each reporting class & method.
I've tried using the AlwaysUseCommand, but that requires declaring a single command that has an open connection. I don't see how I can do that without opening the connection in my AppHost.Configure method and never closing it. It'd be nicer if it were a function pointer, but alas.
I've also looked at overriding the Db property of Service, but that just returns an open IDbConnection without letting me override command created.
It seems like my last option is to create a custom DbConnection class, like the MiniProfiler's ProfiledDbConnection, but I'd have to implement a dozen abstract methods. It seems like overkill in order to set one property on a DbCommand.
So, in ServiceStack.OrmLite, how do I globally modify the CommandTimeout of DbCommands that are created?
You can change the CommandTimeout globally with:
OrmLiteConfig.CommandTimeout = NewTimeoutInSeconds;
Scoped Timeout
You can also specify a Timeout for a particular db connection with:
using (var db = dbFactory.OpenDbConnection())
{
db.SetCommandTimeout(NewTimeoutInSeconds);
}
I'm triying to use Media Foundation to play mp3 file and I have a problem getting PresentationDesctiptor using CreatePresentationDescriptor method
What am I doing:
Start MF using MFStartup
Create session using MFCreateMediaSession
Create SourceResolver using MFCreateSourceResolver
Create MediaSource using CreateObjectFromURL from SourceResolver
Create topology using MFCreateTopology
Trying to create PresentationDescriptor using CreatePresentationDescriptor from MediaSource
When I call CreatePresentationDescriptor no error/exception occurs it just stands there and does nothing. When I pause Visual Strudio it indicates that program is still waiting for method to finish. What am I doing wrong ?
I did not metion that I use C# for this (did not think this was relevant)
The problem was that when importing com interfaces in C# you need to import all methods of interface not only those that are called. Some methods can call not imported methods and cause Access Violation that is not reported to Visual Strudio debugger and as a result it seems like method is never finished invokink.
I am using the very excellent servicestack libaries and trying to generate a ASP.NET web-service reference (old style not WCF) from within VS2010 across my servicestack WSDL - Soap11. To nicely wrap the service WSDL.
The DTO's are in a seperate assembly/namespace (My.WS.DTO) from the AppHost/services and are following the request/response naming convention.. when I try to generate the reference through visual studio I get the following error in VS.
Custom tool error: Unable to import WebService/Schema. Unable to import binding 'BasicHttpBinding_ISyncReply' from namespace 'http://schemas.servicestack.net/types'. Unable to import operation 'GetMyDetails'. The element 'http://schemas.servicestack.net/types:GetMyDetails' is missing.
NOTE: GetMyDetails is just the first service that appears in the list - so I dont believe this is the problem.
I have tried adding the assembly namespace in the AppHost file using
EndpointHostConfig.Instance.WsdlServiceNamespace = "My.WS.DTO"; and this just causes the same generation error (as above) but with 'My.WS.DTO' instead of 'http://schemas.servicestack.net/types'.
I assume it is perhaps some sort of referencing problem but any guidance as to what I might be doing wrong would be great.
cheers
I don't know if this is still an issue for you but I had a similar problem and found that I had not decorated one of my DTOs with [DataContract] and [DataMember] attributes, as described on the SOAP Support wiki page. Once you have added these to your DTO it will be declared in the type section of the WSDL.
Have a look at using [DataContract (Namespace = "YOUR NAMESPACE")] on top of your DTO's. This is how my objects are referenced.
[DataContract(Namespace = "My.WS.DTO")]
public class Account{
}
I also use this in my service model. [System.ServiceModel.ServiceContract()] and [System.ServiceModel.OperationContract()]
[System.ServiceModel.ServiceContract()]
public class SendGetAccountResponseService : IService<SendGetAccountNotification>
{
#region IService implementation
[System.ServiceModel.OperationContract()]
public object Execute (SendGetAccountNotification request)
{
Console.WriteLine ("Reached");
return null;
}
#endregion
}
Hope this helps / solves your problem.
I know this is an old question, but I had to add SOAP support for a 3rd party that refused to support REST very recently to my ServiceStack implementation so it could still be relevant to other people still having this issue.
I had the same issue you were having:
Unable to import binding 'BasicHttpBinding_ISyncReply'...
And like mickfold previously answered I needed to add [DataContract] and [DataMember] to my class definitions and their properties.
But I also had to add the following to my AssemblyInfo.cs file before the error went away for me:
[assembly: ContractNamespace("http://schemas.servicestack.net/types", ClrNamespace = "My Type Namespace")]
I assume that you will need one of these lines for every single namespace where you have a type declared, which based upon the original question above would be My.WS.DTO.
Is it possible to use ASP.NET Dynamic Data with SubSonic 3 in-place of Linq to SQL classes or the Entity Framework? MetaModel.RegisterContext() throws an exception if you use the context class that SubSonic generates. I thought I remembered coming across a SubSonic/Dynamic Data example back before SubSonic 3 was released but I can't find it now. Has anyone been able to get this to work?
I just got Subsonic 3.0.0.4 ActiveRecord working last night in Visual Studio 2010 with my SQLite database after a little bit of work and I've tried to document the steps taken here for your benefit.
Start by adding a New Item -> WCF Data Service to the project you're using to host your webapp/webservices then modify it similar to my PinsDataService.svc.cs below:
public class PinsDataService : DataService<PINS.Lib.dbPINSDB>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.UseVerboseErrors = true;
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
}
At this point your Dynamic Data Service would probably be working if you matched all the database naming conventions perfectly but I didn't have that kind of luck. In my ActiveRecord.tt template I had to prepend the following two lines before the public partial class declarations:
[DataServiceKey("<#=tbl.PrimaryKey #>")]
[IgnoreProperties("Columns")]
public partial class <#=tbl.ClassName#>: IActiveRecord {
I then added references to System.Data and System.Data.Services.Client followed by the inclusion of using statements for using System.Data.Services and using System.Data.Services.Common at the top of the ActiveRecord.tt template.
The next step was to use the IUpdateable partial class implementation from this blog post http://blogs.msdn.com/aconrad/archive/2008/12/05/developing-an-astoria-data-provider-for-subsonic.aspx and change the public partial class dbPINSDB : IUpdatable to match my subsonic DatabaseName declared in Settings.ttinclude
Then to consume the data in a separate client app/library I started by adding a 'Service Reference' named PinsDataService to the PinsDataService.svc from my client app and went to town:
PinsDataService.dbPINSDB PinsDb =
new PinsDataService.dbPINSDB(new Uri("http://localhost:1918/PinsDataService.svc/"));
PinsDataService.Alarm activeAlarm =
PinsDb.Alarms.Where(i => i.ID == myAA.Alarm_ID).Take(1).ElementAt(0);
Note how I'm doing a Where query that returns only 1 object but I threw in the Take(1) and then ElementAt(0) because I kept getting errors when I tried to use SingleOrDefault() or First()
Hope this helps--also, I'm already aware that dbPINSDB is a really bad name for my Subsonic Database ;)
Is it possible to extend the SubSonic generator without modifying it's code?
I would like to add my own custom methods that i can use inside the templates. Somthing similair like the Utility.GetVariableType method.
You can't extend the built in templates, but you can replace them with your own templates without changing SubSonic.dll. See the templateDirectory parameter here: http://subsonicproject.com/docs/Generated_Classes/#Customizing_Active_Record
An example configuration would be:
<SubSonicService defaultProvider="Northwind" enableTrace="true"
templateDirectory="C:\Program Files\SubSonic\SubSonic 2.0.3\Templates\MVC">
<providers>
<clear/>
<add name="Northwind" type="SubSonic.SqlDataProvider, SubSonic"
connectionStringName="Northwind" generatedNamespace="Northwind"/>
</providers>
</SubSonicService>
You can get the current version of the built-in ActiveRecord templates from here.
I've found the solution for my own problem :).
I can now extend SubSonic with functionality i need in the templates without needing to rebuild or change any of the SubSonic code itself.
It works for what i wanted to do and i think it can be usefull for others as well so here it is:
Create a new class library SubSonicHelper. Mine has a class looking like this:
using System;
using System.Collections.Generic;
using System.Text;
namespace Helpers.SubSonic
{
public class GeneratorHelper
{
public bool IsColumnAllowed(string columnName)
{
return columnName.Length == 1 ||
(columnName.Length > 1 &&
(!(columnName[0].ToString().Equals("_") &&
columnName[columnName.Length - 1].ToString().Equals("_"))))
}
}
}
Build the assembly and copy SubSonicHelper.dll to your subsonic project.
Setup your SubSonic project to use your own templates using the templateDirectory parameter.
Edit your own templates and at the following after the const bool showGenerationInfo = false;
System.Reflection.Assembly a = System.Reflection.Assembly.LoadFile(
System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "SubSonicHelper.dll"));
object instance = a.CreateInstance("Helpers.SubSonic.GeneratorHelper");
Type type = instance.GetType();
After this you have an instance of the GeneratorHelper that you can use inside the template. For accessing the methods you need to do the following:
Create an array of objects for the parameters of the method you want to use. I have the columnName parameter which i set to col.propertyName. This is inside the foreach (TableSchema.TableColumn col in cols) loop in the Update method.
Call the method you want to use with the object array as argument.
Check the result object to see the result of the method.
object[] arg = new object[]{col.PropertyName};
object isColumnAllowedResult = type.InvokeMember("IsColumnAllowed", System.Reflection.BindingFlags.Default | System.Reflection.BindingFlags.InvokeMethod, null, instance, arg);
if (Convert.ToBoolean(isColumnAllowedResult))
That's it! Now i can extend the SubSonicHelper class with other methods i want to use inside the template.
The short answer is no. If you come up with something useful, submit a patch and it will likely be integrated into the core. You can submit patches here: http://code.google.com/p/subsonicproject/issues/list
can you not import a dll in the template?
like
<%# Import namespace="NewHelpers.Utilities"%>
and then call the function or create an instance of the object