Search Results

Search found 259 results on 11 pages for 'xmlserializer'.

Page 9/11 | < Previous Page | 5 6 7 8 9 10 11  | Next Page >

  • WCF MessageContract Help - MessageBodyMember with hyphenated name

    - by Hcabnettek
    Hi All, I need a bit of WCF help. This project uses message contracts. The transport seems to work ok. I have this code for a response type. namespace tpoke.Contracts { [MessageContract(IsWrapped = true)] public class AuthenticationResponseMC { [MessageBodyMember(Name = "authentication-token")] public Guid AuthenticationToken; } } Now when I run the operation that returns this, I try to deserialize using the XmlSerializer. The is not what I'm needing. I need it to be <authentication-token xmlns="http://tpoke.wcf.com">e13xxxx-xxxx-xxxx-xxxxxx</authentication-token> How can I make this work correctly? Do I need to add the namespace to MessageBodyMember? Why is the hyphen being stripped out? Any tips or advice is certainly appreciated. Thanks, ~ck in San Diego

    Read the article

  • Problem deserializing xml file

    - by Andy
    I auto generated an xsd file from the below xml and used xsd2code to get a c# class. The problem is the entire xml doesn't deserialize. Here is how I'm attempting to deserialize: static void Main(string[] args) { using (TextReader textReader = new StreamReader("config.xml")) { // string temp = textReader.ReadToEnd(); XmlSerializer deserializer = new XmlSerializer(typeof(project)); project p = (project)deserializer.Deserialize(textReader); } } here is the actual XML: <?xml version='1.0' encoding='UTF-8'?> <project> <scm class="hudson.scm.SubversionSCM"> <locations> <hudson.scm.SubversionSCM_-ModuleLocation> <remote>https://svn.xxx.com/test/Validation/CPS DRTest DLL/trunk</remote> </hudson.scm.SubversionSCM_-ModuleLocation> </locations> <useUpdate>false</useUpdate> <browser class="hudson.scm.browsers.FishEyeSVN"> <url>http://fisheye.xxxx.net/browse/Test/</url> <rootModule>Test</rootModule> </browser> <excludedCommitMessages></excludedCommitMessages> </scm> <openf>Hello there</openf> <buildWrappers/> </project> When I run the above, the locations node remains null. Here is the xsd that I'm using: <?xml version="1.0" encoding="utf-8"?> <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xs:element name="project"> <xs:complexType> <xs:all> <xs:element name="openf" type="xs:string" minOccurs="0" /> <xs:element name="buildWrappers" type="xs:string" minOccurs="0" /> <xs:element name="scm" minOccurs="0"> <xs:complexType> <xs:sequence> <xs:element name="useUpdate" type="xs:string" minOccurs="0" msdata:Ordinal="1" /> <xs:element name="excludedCommitMessages" type="xs:string" minOccurs="0" msdata:Ordinal="2" /> <xs:element name="locations" minOccurs="0"> <xs:complexType> <xs:sequence> <xs:element name="hudson.scm.SubversionSCM_-ModuleLocation" minOccurs="0"> <xs:complexType> <xs:sequence> <xs:element name="remote" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="browser" minOccurs="0"> <xs:complexType> <xs:sequence> <xs:element name="url" type="xs:string" minOccurs="0" msdata:Ordinal="0" /> <xs:element name="rootModule" type="xs:string" minOccurs="0" msdata:Ordinal="1" /> </xs:sequence> <xs:attribute name="class" type="xs:string" /> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="class" type="xs:string" /> </xs:complexType> </xs:element> </xs:all> </xs:complexType> </xs:element> <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element ref="project" /> </xs:choice> </xs:complexType> </xs:element> </xs:schema>

    Read the article

  • Custom XML Serialization, how to write custom root element?

    - by Beta033
    I'm probably just doing this wrong, i know. i'm using custom serialization and when the xml is generated it's putting the class name as the root element Example: <MyClassName> <MyIntendedRootNode> <ObjectType> <Property1/> <Property2/> ... I'm inoking the serialization by calling xmlserializer.Serialize(writer,Me) so i'm sure that has something to do with it. I've tried putting XMLRoot onto the class, but i think as vb is compiling this partial class with it's aspx page, it's either overwriting this property or ignoring it entirely. ideally i'd like to just tell it to either throw away everything it has and use a different root element. Anybody else do this except me? Thanks

    Read the article

  • How to deserialize null array to null in c#?

    - by Aen Sidhe
    Here is my class: public class Command { [XmlArray(IsNullable = true)] public List<Parameter> To { get; set; } } When I serialize an object of this class: var s = new XmlSerializer(typeof(Command)); s.Serialize(Console.Out, new Command()); it prints as expected (xml header and default MS namespaces are omitted): <Command><To xsi:nil="true" /></Command> When I took this xml and tried to deserialize it I got stucked, because it always print "Not null": var t = s.Deserialize(...); if (t.To == null) Console.WriteLine("Null"); else Console.WriteLine("Not null"); How to force deserializer to make my list null, if it is null in xml?

    Read the article

  • .Net SvcUtil: attributes must be optional

    - by Michel van Engelen
    Hi, I'm trying to generate C# code classes with SvcUtil.exe instead of Xsd.exe. The latter is giving me some problems. Command line: SvcUtil.exe myschema.xsd /dconly /ser:XmlSerializer Several SvcUtil problems are described and solved here: http://blog.shutupandcode.net/?p=761 One problem I can't solve is this one: Error: Type 'DatafieldDescription' in namespace '' cannot be imported. Attributes must be optional and from namespace 'http://schemas.microsoft.com/2003/10/Seri alization/'. Either change the schema so that the types can map to data contract types or use ImportXmlType or use a different serializer. ' I changed <xs:attribute name="Order" use="required"> to <xs:attribute name="Order" use="optional"> and <xs:attribute name="Order"> But the error remains. Is it possible to use attributes, or do I have to delete them all (in that case, this excercition is over)?

    Read the article

  • Is this code thread-safe?

    - by mafutrct
    I've got a class with several properties. On every value update, a Store method is called with stores all fields (in a file). private int _Prop1; public int Prop1 { get { return _Prop1; } set { _Prop1 = value; Store(); } } // more similar properties here... private XmlSerializer _Ser = new ...; private void Store() { lock (_Ser) { using (FileStream fs = new ...) { _Ser.Serialize (fs, this); } } } Is this design thread-safe? (Btw, if you can think of a more appropriate caption, feel free to edit.)

    Read the article

  • HOWTO: Deserialize WCF message using OperationContract

    - by Stefan
    Hi, I succeeded in building a WCF client generated by svcutil.exe from the WSDL. Using the generated client proxy class I can call the web service of an external service supplier. I also succeeded in coding a message inspector, as I need to log both raw XML request and response as full SOAP message to the database. For an emergency szenario I also need to be able to "import" a raw XML response. I found many hints on using XMLSerializer or deserializing WCF messages based on the message contract. But how can I deserialize a raw XML response based on an operation contract? For a first test I use one of the logged raw responses, save it to a file and now try to deserialize it to the response type as generated in the client proxy. Somehow I must succeed in calling DeserializeReply() from class ClientOperation. But how to get there? I happily acced any help as I'm quite new to WCF... TIA, Stefan

    Read the article

  • Weird behaviour of a deserialized class

    - by orloffm
    I've got a huge XML file that's being deserialized by XmlSerializer in an XSD-generated class structure. Everything used to work just fine, but now a weird thing started happening. Sometimes (50% of runs) a field of a certain object of a class that's deep in the class tree just changes to a certain value of the same field of a different object of the same class. It happens when entering some function, when debugger steps from opening "{" to the first line of code. I understand that it's stupid question, but maybe someone have any thoughts?

    Read the article

  • Is it possible to coerce string values in xml to bool?

    - by Kugel
    Let's suppose I have xml like this one: <Server Active="No"> <Url>http://some.url</Url> </Server> C# class looks like this: public class Server { [XmlAttribute()] public string Active { get; set; } public string Url { get; set; } } Is it possible to change Active property to type bool and have XmlSerializer coerce "Yes" "No" to bool values? Edit: Xml is received, I cannot change it. So, in fact, i'm interested in deserialization only.

    Read the article

  • Configuration file reading. Best practice

    - by Andrew Florko
    Application stores configuration data in custom section of configuration file. This information is used all over the application. Nowadays I use helper static class to to provide access like this (some code omitted or simplified): [XmlRoot("webSiteSection")] public class WebSiteConfig : IConfigurationSectionHandler { public static WebSiteConfig Current { get { if (_current == null) _current = (WebSiteConfig) ConfigurationManager.GetSection("webSiteSection"); return _current; } } [XmlElement("section1")] public Section1 Section1 { get; set; } [XmlElement("section2")] public Section2 Section2 { get; set; } ... public object Create(object parent, object configContext, XmlNode section) { var serializer = new XmlSerializer(typeof(WebSiteConfig)); return serializer.Deserialize(new XmlNodeReader(section)); } } Then I use it like this <%: WebSiteConfig.Current.Section1.Value1 %> <%: WebSiteConfig.Current.Section1.Value2 %> What do you think of it? I find it usable because it keeps code simple, but also confused as IConfigurationSectionHandler is deprecated since .NET Framework 2.0

    Read the article

  • Powershell's import-clixml from string

    - by rocku
    Is there any way to run import-clixml cmdlet on a string or xml object? It requires a file path as input to produce ps objects and can't get input from an xml object. Since there is convertto-xml cmdlet which serializes ps object into xml object, why isn't there a convertfrom-xml, which would do the opposite? I am aware of System.Xml.Serialization.XmlSerializer class which would do just that, however I would like to stick with cmdlets to do this. Is there any way to do this with cmdlets (probably just with import-clixml), without creating temporary files?

    Read the article

  • How to set default values to the properties of dynamically loaded types at runtime for XML serializa

    - by Erkan Y.
    I need to serialize dynamically loaded types' classes using XMLSerializer. When using XML serializer non initialized values are not being serialized. I dont have control over the assemblies I am working with so can not use XML attributes for specifying default values on properties. So I think I need to set all properties and sub properties to their default values recursively and then serialize. ( Please let me know if there is any better way ) Followed this : Activator.CreateInstance(propType); but above line complains about not having a parameterless constructor for some types. Tried this : subObject = FormatterServices.GetUninitializedObject(propType); but this one gives an error "value was invalid" with no inner exception. Please let me know if you need any further information.

    Read the article

  • Decimal point removed from decimals in a Serialized XML

    - by MiguelM
    I'm using XmlSerializer with classes created from a xsd using xsd.exe. It has worked fine for months. Now I'm receiving reports that in some cases the created xml file has all decimals serialized without a decimal point, e.g. 123.45 is serialized as 12345. I haven't been able to reproduce the problem, but I'm suspecting it may be related to localization. This is my first C# project, so I may be overlooking something basic. Could localization cause this problem? How can I make the serialization process locale independent? Any idea of something else that could cause this problem?

    Read the article

  • Can anyone recommend a .Net XML Serialization library?

    - by James
    Can anyone recommend a .Net XML Serialization library (ideally open source). I am looking for a robust XML serialization library that I can throw any object at, which will produce a human readable XML representation of the public properties for logging purposes. I never need to be able to deserialize. XmlSerializer's requirement of an object having a parameter constructor is too restrictive for what I want. DataContractSerializer does not give enough control over the output (which is not particularly human-readable). Any recommendations appreciated! Thanks

    Read the article

  • Is there a way to send text to an aspcontrol via jquery

    - by Garrith Graham
    Is there a way to send data to an aspcontrol say a label called label1? Via jquery? I know jquery only likes html but is there a way to just send the raw text to an asp control using a similar method below: <script type="text/javascript"> $(document).ready(function () { var label = $("#<%= testLabel.ClientID %>"); var div = $("<div></div>").html("content").attr('id', 'test'); var serializer = new XMLSerializer(); label.text(serializer.serializeToString(div)); }); </script>

    Read the article

  • Save objects to a database?

    - by Eric
    So far in my .Net coding adventures I've only had a need to save information to files. So I've used XmlSerializer and DataContractSerializer to serialize attributed classes to XML files. My next project, however, requires that I save and retrieve information from a SQL server database. I'm wondering what my options are for doing this. The current version of the app, which was not created by me, uses a lot of hard coded SQL commands. But now I'm trying to avoid doing anything where I have to read or write individual fields to or from the database or objects. I especially want to avoid a lot of hard coded SQL in my code. I like how the serializer classes just figure out how to read and write XML files based on the attributes and or public properties of the class. Is there something similar for a database rather then XML?

    Read the article

  • Weblogic 10.0: SAMLSignedObject.verify() failed to validate signature value

    - by joshea
    I've been having this problem for a while and it's driving me nuts. I'm trying to create a client (in C# .NET 2.0) that will use SAML 1.1 to sign on to a WebLogic 10.0 server (i.e., a Single Sign-On scenario, using browser/post profile). The client is on a WinXP machine and the WebLogic server is on a RHEL 5 box. I based my client largely on code in the example here: http://www.codeproject.com/KB/aspnet/DotNetSamlPost.aspx (the source has a section for SAML 1.1). I set up WebLogic based on instructions for SAML Destination Site from here:http://www.oracle.com/technology/pub/articles/dev2arch/2006/12/sso-with-saml4.html I created a certificate using makecert that came with VS 2005. makecert -r -pe -n "CN=whatever" -b 01/01/2010 -e 01/01/2011 -sky exchange whatever.cer -sv whatever.pvk pvk2pfx.exe -pvk whatever.pvk -spc whatever.cer -pfx whatever.pfx Then I installed the .pfx to my personal certificate directory, and installed the .cer into the WebLogic SAML Identity Asserter V2. I read on another site that formatting the response to be readable (ie, adding whitespace) to the response after signing would cause this problem, so I tried various combinations of turning on/off .Indent XMLWriterSettings and turning on/off .PreserveWhiteSpace when loading the XML document, and none of it made any difference. I've printed the SignatureValue both before the message is is encoded/sent and after it arrives/gets decoded, and they are the same. So, to be clear: the Response appears to be formed, encoded, sent, and decoded fine (I see the full Response in the WebLogic logs). WebLogic finds the certificate I want it to use, verifies that a key was supplied, gets the signed info, and then fails to validate the signature. Code: public string createResponse(Dictionary<string, string> attributes){ ResponseType response = new ResponseType(); // Create Response response.ResponseID = "_" + Guid.NewGuid().ToString(); response.MajorVersion = "1"; response.MinorVersion = "1"; response.IssueInstant = System.DateTime.UtcNow; response.Recipient = "http://theWLServer/samlacs/acs"; StatusType status = new StatusType(); status.StatusCode = new StatusCodeType(); status.StatusCode.Value = new XmlQualifiedName("Success", "urn:oasis:names:tc:SAML:1.0:protocol"); response.Status = status; // Create Assertion AssertionType assertionType = CreateSaml11Assertion(attributes); response.Assertion = new AssertionType[] {assertionType}; //Serialize XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("samlp", "urn:oasis:names:tc:SAML:1.0:protocol"); ns.Add("saml", "urn:oasis:names:tc:SAML:1.0:assertion"); XmlSerializer responseSerializer = new XmlSerializer(response.GetType()); StringWriter stringWriter = new StringWriter(); XmlWriterSettings settings = new XmlWriterSettings(); settings.OmitXmlDeclaration = true; settings.Indent = false;//I've tried both ways, for the fun of it settings.Encoding = Encoding.UTF8; XmlWriter responseWriter = XmlTextWriter.Create(stringWriter, settings); responseSerializer.Serialize(responseWriter, response, ns); responseWriter.Close(); string samlString = stringWriter.ToString(); stringWriter.Close(); // Sign the document XmlDocument doc = new XmlDocument(); doc.PreserveWhiteSpace = true; //also tried this both ways to no avail doc.LoadXml(samlString); X509Certificate2 cert = null; X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser); store.Open(OpenFlags.ReadOnly); X509Certificate2Collection coll = store.Certificates.Find(X509FindType.FindBySubjectDistinguishedName, "distName", true); if (coll.Count < 1) { throw new ArgumentException("Unable to locate certificate"); } cert = coll[0]; store.Close(); //this special SignDoc just overrides a function in SignedXml so //it knows to look for ResponseID rather than ID XmlElement signature = SamlHelper.SignDoc( doc, cert, "ResponseID", response.ResponseID); doc.DocumentElement.InsertBefore(signature, doc.DocumentElement.ChildNodes[0]); // Base64Encode and URL Encode byte[] base64EncodedBytes = Encoding.UTF8.GetBytes(doc.OuterXml); string returnValue = System.Convert.ToBase64String( base64EncodedBytes); return returnValue; } private AssertionType CreateSaml11Assertion(Dictionary<string, string> attributes){ AssertionType assertion = new AssertionType(); assertion.AssertionID = "_" + Guid.NewGuid().ToString(); assertion.Issuer = "madeUpValue"; assertion.MajorVersion = "1"; assertion.MinorVersion = "1"; assertion.IssueInstant = System.DateTime.UtcNow; //Not before, not after conditions ConditionsType conditions = new ConditionsType(); conditions.NotBefore = DateTime.UtcNow; conditions.NotBeforeSpecified = true; conditions.NotOnOrAfter = DateTime.UtcNow.AddMinutes(10); conditions.NotOnOrAfterSpecified = true; //Name Identifier to be used in Saml Subject NameIdentifierType nameIdentifier = new NameIdentifierType(); nameIdentifier.NameQualifier = domain.Trim(); nameIdentifier.Value = subject.Trim(); SubjectConfirmationType subjectConfirmation = new SubjectConfirmationType(); subjectConfirmation.ConfirmationMethod = new string[] { "urn:oasis:names:tc:SAML:1.0:cm:bearer" }; // // Create some SAML subject. SubjectType samlSubject = new SubjectType(); AttributeStatementType attrStatement = new AttributeStatementType(); AuthenticationStatementType authStatement = new AuthenticationStatementType(); authStatement.AuthenticationMethod = "urn:oasis:names:tc:SAML:1.0:am:password"; authStatement.AuthenticationInstant = System.DateTime.UtcNow; samlSubject.Items = new object[] { nameIdentifier, subjectConfirmation}; attrStatement.Subject = samlSubject; authStatement.Subject = samlSubject; IPHostEntry ipEntry = Dns.GetHostEntry(System.Environment.MachineName); SubjectLocalityType subjectLocality = new SubjectLocalityType(); subjectLocality.IPAddress = ipEntry.AddressList[0].ToString(); authStatement.SubjectLocality = subjectLocality; attrStatement.Attribute = new AttributeType[attributes.Count]; int i=0; // Create SAML attributes. foreach (KeyValuePair<string, string> attribute in attributes) { AttributeType attr = new AttributeType(); attr.AttributeName = attribute.Key; attr.AttributeNamespace= domain; attr.AttributeValue = new object[] {attribute.Value}; attrStatement.Attribute[i] = attr; i++; } assertion.Conditions = conditions; assertion.Items = new StatementAbstractType[] {authStatement, attrStatement}; return assertion; } private static XmlElement SignDoc(XmlDocument doc, X509Certificate2 cert2, string referenceId, string referenceValue) { // Use our own implementation of SignedXml SamlSignedXml sig = new SamlSignedXml(doc, referenceId); // Add the key to the SignedXml xmlDocument. sig.SigningKey = cert2.PrivateKey; // Create a reference to be signed. Reference reference = new Reference(); reference.Uri= String.Empty; reference.Uri = "#" + referenceValue; // Add an enveloped transformation to the reference. XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform(); reference.AddTransform(env); // Add the reference to the SignedXml object. sig.AddReference(reference); // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). KeyInfo keyInfo = new KeyInfo(); keyInfo.AddClause(new KeyInfoX509Data(cert2)); sig.KeyInfo = keyInfo; // Compute the signature. sig.ComputeSignature(); // Get the XML representation of the signature and save // it to an XmlElement object. XmlElement xmlDigitalSignature = sig.GetXml(); return xmlDigitalSignature; } To open the page in my client app, string postData = String.Format("SAMLResponse={0}&APID=ap_00001&TARGET={1}", System.Web.HttpUtility.UrlEncode(builder.buildResponse("http://theWLServer/samlacs/acs",attributes)), "http://desiredURL"); webBrowser.Navigate("http://theWLServer/samlacs/acs", "_self", Encoding.UTF8.GetBytes(postData), "Content-Type: application/x-www-form-urlencoded");

    Read the article

  • NserviceBus throws exception when referencing a Nettiers assembly

    - by IGoor
    We use nettiers as a our data layer, and we recently have started looking at using NServiceBus, but we have hit a wall. We have a windows service which hosts NSB and references our Nettiers assembly. the service is throwing an exception when the following line is encountered. var Bus = Configure.With().SpringBuilder() .XmlSerializer() .MsmqTransport() .IsTransactional(false) .PurgeOnStartup(false) .UnicastBus() .ImpersonateSender(false) .CreateBus() .Start(); the exceptions that is throw is: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. the loader exception message is: Could not load file or assembly 'Microsoft.Practices.Unity, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.":"Microsoft.Practices.Unity, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 stacktrace is: at System.Reflection.Module._GetTypesInternal(StackCrawlMark& stackMark) at System.Reflection.Assembly.GetTypes() at NServiceBus.Configure.<>c__DisplayClass1.<With>b__0(Assembly a) in d:\BuildAgent-03\work\672d81652eaca4e1\src\config\NServiceBus.Config\Configure.cs:line 122 at System.Array.ForEach[T](T[] array, Action`1 action) at NServiceBus.Configure.With(Assembly[] assemblies) in d:\BuildAgent-03\work\672d81652eaca4e1\src\config\NServiceBus.Config\Configure.cs:line 122 at NServiceBus.Configure.With(IEnumerable`1 assemblies) in d:\BuildAgent-03\work\672d81652eaca4e1\src\config\NServiceBus.Config\Configure.cs:line 111 at NServiceBus.Configure.With(String probeDirectory) in d:\BuildAgent-03\work\672d81652eaca4e1\src\config\NServiceBus.Config\Configure.cs:line 101 at NServiceBus.Configure.With() in d:\BuildAgent-03\work\672d81652eaca4e1\src\config\NServiceBus.Config\Configure.cs:line 78 at MessageSender.Program.Main(String[] args) in C:\Development\NSBTest4\MessageSender\Program.cs:line 18 without the nettiers reference NSB works fine. Any idea what the problem is and how to solve it? thanks.

    Read the article

  • ASP.NET MVC 2 with NServiceBus unable to load requested types

    - by dp
    I am trying to use NServiceBus with an ASP.NET MVC 2 website (using VS 2010 and the .NET 4.0 framework). However, when I run the site on my local machine, I get the following error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. Here are the relevant steps I have taken: Downloaded the NServiceBus.2.0.0.1145 binaries In my asp.net mvc app, I've added references to NServiceBus.dll and NServiceBus.Core.dll In Global.asax.cs I've added: public static IBus Bus { get; private set; } protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); Bus = NServiceBus.Configure .WithWeb() .Log4Net() .DefaultBuilder() .XmlSerializer() .MsmqTransport() .IsTransactional(false) .PurgeOnStartup(false) .UnicastBus() .ImpersonateSender(false) .CreateBus() .Start(); } In web.config, I've added: <MsmqTransportConfig InputQueue="MyWebClient" ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5"/> <UnicastBusConfig> <MessageEndpointMappings> <add Messages="Messages" Endpoint="MyServerInputQueue"/> </MessageEndpointMappings> </UnicastBusConfig> The error indicates that the problem is with the first line in the Global.asax.cs file. Is it possible that there is a problem with NServiceBus running under .NET 4.0?

    Read the article

  • How to use InterfaceInterceptor with NServiceBus UnityBuilder

    - by David
    I have a MessageHandler with a dependency declared as: public IRepository<Person> PersonRepository {get;set;} I set up my Unity container with: IUnityContainer container = new UnityContainer(); container.AddNewExtension<Interception>(); container.RegisterType(typeof(IRepository<Person>), typeof(Example.Data.InMemory.Repository<Person>)); container.Configure<Interception>() .AddPolicy("PersonAddAdvice") .AddMatchingRule(new AddMatchingRule()) .AddCallHandler(new PersonAddedEventPublishingCallHandler()); container.Configure<Interception>() .SetInterceptorFor<IRepository<Person>>(new InterfaceInterceptor()); Then I Init my endpoint with: class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization { public void Init() { NServiceBus.Configure.With() .Log4Net() .UnityBuilder(ContainerConfig.LoadContainer()) .XmlSerializer(); } } (ContainerConfig.LoadContainer() returns the pre-configured IUnityContainer) the problem is that the IRepository dependency in my MessageHandler is not resolved (it's null when handling the messages). If I remove the interception configuration from the Unity container, and simply do this: IUnityContainer container = new UnityContainer(); container.RegisterType(typeof(IRepository<Person>), typeof(Example.Data.InMemory.Repository<Person>)); It works as expected, and the MessageHandler has an instance if IRepository resolved.

    Read the article

  • NullReferenceException when initializing NServiceBus within web application Application_Start method

    - by SteveBering
    I am running the 2.0 RTM of NServiceBus and am getting a NullReferenceException when my MessageModule binds the CurrentSessionContext to my NHibernate sessionfactory. From within my Application_Start, I call the following method: public static void WithWeb(IUnityContainer container) { log4net.Config.XmlConfigurator.Configure(); var childContainer = container.CreateChildContainer(); childContainer.RegisterInstance<ISessionFactory>(NHibernateSession.SessionFactory); var bus = NServiceBus.Configure.WithWeb() .UnityBuilder(childContainer) .Log4Net() .XmlSerializer() .MsmqTransport() .IsTransactional(true) .PurgeOnStartup(false) .UnicastBus() .ImpersonateSender(false) .LoadMessageHandlers() .CreateBus(); var activeBus = bus.Start(); container.RegisterInstance(typeof(IBus), activeBus); } When the bus is started, my message module starts with the following: public void HandleBeginMessage() { try { CurrentSessionContext.Bind(_sessionFactory.OpenSession()); } catch (Exception e) { _log.Error("Error occurred in HandleBeginMessage of NHibernateMessageModule", e); throw; } } In looking at my log, we are logging the following error when the bind method is called: System.NullReferenceException: Object reference not set to an instance of an object. at NHibernate.Context.WebSessionContext.GetMap() at NHibernate.Context.MapBasedSessionContext.set_Session(ISession value) at NHibernate.Context.CurrentSessionContext.Bind(ISession session) Apparently, there is some issue in getting access to the HttpContext. Should this call to configure NServiceBus occur later in the lifecycle than Application_Start? Or is there another workaround that others have used to get handlers working within an Asp.NET Web application? Thanks, Steve

    Read the article

  • How do I match complete XML objects in a string?

    - by cyclotis04
    I'm attempting to find complete XML objects in a string. They have been placed in the string by an XmlSerializer, but may or may not be complete. I've toyed with the idea of using a regular expression, because it seems like the kind of thing they were built for, except for the fact that I'm trying to parse XML. I'm trying to find complete objects in the form: <?xml version="1.0"?> <type> <field>value</field> ... </type> My thought was a regex to find <?xml version="1.0"?><type> and </type>, but if a field has the same name as type, it obviously won't work. There's plenty of documentation on XML parsers, but they seem to all need a complete, fully-formed document to parse. My XML objects can be in a string surrounded by pretty much anything else (including other complete objects). hw<e>reR@lot$0fr@ndm&nchrs%<?xml version="1.0"?><type><field>...</field>...</type>@ndH#r$omOre!!>nuT6erjc?y!<?xml version="1.0"?><type><field>...</field>...</type>ty!=] A regex would be able to match a string while excluding the random characters, but not find a complete XML object. I'd like some way to extract an object, parse it with a serializer, then repeat until the string contains no more valid objects.

    Read the article

  • How to add XmlInclude attribute dynamically

    - by Anindya Chatterjee
    I have the following classes [XmlRoot] public class AList { public List<B> ListOfBs {get; set;} } public class B { public string BaseProperty {get; set;} } public class C : B { public string SomeProperty {get; set;} } public class Main { public static void Main(string[] args) { var aList = new AList(); aList.ListOfBs = new List<B>(); var c = new C { BaseProperty = "Base", SomeProperty = "Some" }; aList.ListOfBs.Add(c); var type = typeof (AList); var serializer = new XmlSerializer(type); TextWriter w = new StringWriter(); serializer.Serialize(w, aList); } } Now when I try to run the code I got an InvalidOperationException at last line saying that The type XmlTest.C was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically. I know that adding a [XmlInclude(typeof(C))] attribute with [XmlRoot] would solve the problem. But I want to achieve it dynamically. Because in my project class C is not known prior to loading. Class C is being loaded as a plugin, so it is not possible for me to add XmlInclude attribute there. I tried also with TypeDescriptor.AddAttributes(typeof(AList), new[] { new XmlIncludeAttribute(c.GetType()) }); before var type = typeof (AList); but no use. It is still giving the same exception. Does any one have any idea on how to achieve it?

    Read the article

  • Component returned failure code: 0x80600011 [nsIXSLTProcessorObsolete.transformDocument]

    - by Sean Ochoa
    So, I'm using the XSLT plugin for JQuery, and here's my code: function AddPlotcardEventHandlers(){ // some code } function reportError(exception){ alert(exception.constructor.name + " Exception: " + ((exception.name) ? exception.name : "[unknown name]") + " - " + exception.message); } function GetPlotcards(){ $("#content").xslt("../xml/plotcards.xml","../xslt/plotcards.xsl", AddPlotcardEventHandlers,reportError); } Here's the modified jquery plugin. I say that its modified because I've added callbacks for success and error handling. /* * jquery.xslt.js * * Copyright (c) 2005-2008 Johann Burkard (<mailto:[email protected]>) * <http://eaio.com> * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. * */ /** * jQuery client-side XSLT plugins. * * @author <a href="mailto:[email protected]">Johann Burkard</a> * @version $Id: jquery.xslt.js,v 1.10 2008/08/29 21:34:24 Johann Exp $ */ (function($) { $.fn.xslt = function() { return this; } var str = /^\s*</; if (document.recalc) { // IE 5+ $.fn.xslt = function(xml, xslt, onSuccess, onError) { try{ var target = $(this); var change = function() { try{ var c = 'complete'; if (xm.readyState == c && xs.readyState == c) { window.setTimeout(function() { target.html(xm.transformNode(xs.XMLDocument)); if (onSuccess) onSuccess(); }, 50); } }catch(exception){ if (onError) onError(exception); } }; var xm = document.createElement('xml'); xm.onreadystatechange = change; xm[str.test(xml) ? "innerHTML" : "src"] = xml; var xs = document.createElement('xml'); xs.onreadystatechange = change; xs[str.test(xslt) ? "innerHTML" : "src"] = xslt; $('body').append(xm).append(xs); return this; }catch(exception){ if (onError) onError(exception); } }; } else if (window.DOMParser != undefined && window.XMLHttpRequest != undefined && window.XSLTProcessor != undefined) { // Mozilla 0.9.4+, Opera 9+ var processor = new XSLTProcessor(); var support = false; if ($.isFunction(processor.transformDocument)) { support = window.XMLSerializer != undefined; } else { support = true; } if (support) { $.fn.xslt = function(xml, xslt, onSuccess, onError) { try{ var target = $(this); var transformed = false; var xm = { readyState: 4 }; var xs = { readyState: 4 }; var change = function() { try{ if (xm.readyState == 4 && xs.readyState == 4 && !transformed) { var processor = new XSLTProcessor(); if ($.isFunction(processor.transformDocument)) { // obsolete Mozilla interface resultDoc = document.implementation.createDocument("", "", null); processor.transformDocument(xm.responseXML, xs.responseXML, resultDoc, null); target.html(new XMLSerializer().serializeToString(resultDoc)); } else { processor.importStylesheet(xs.responseXML); resultDoc = processor.transformToFragment(xm.responseXML, document); target.empty().append(resultDoc); } transformed = true; if (onSuccess) onSuccess(); } }catch(exception){ if (onError) onError(exception); } }; if (str.test(xml)) { xm.responseXML = new DOMParser().parseFromString(xml, "text/xml"); } else { xm = $.ajax({ dataType: "xml", url: xml}); xm.onreadystatechange = change; } if (str.test(xslt)) { xs.responseXML = new DOMParser().parseFromString(xslt, "text/xml"); change(); } else { xs = $.ajax({ dataType: "xml", url: xslt}); xs.onreadystatechange = change; } }catch(exception){ if (onError) onError(exception); }finally{ return this; } }; } } })(jQuery); And, here's my error msg: Object Exception: [unknown name] - Component returned failure code: 0x80600011 [nsIXSLTProcessorObsolete.transformDocument] Here's the info on the browser that I'm using for testing (with firebug v1.5.4 add-on installed): Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 Here's my XML: <?xml version="1.0" encoding="ISO-8859-1"?> <plotcardCollection sortby="order"> <plotcard order="2" id="1378"> <name><![CDATA[[placeholder for name of plotcard 1378]]]></name> <content><![CDATA[[placeholder for content of plotcard 1378]]]></content> <tagCollection> <tag id="3"><![CDATA[[placeholder for tag with id=3]]]></tag> <tag id="7"><![CDATA[[placeholder for tag with id=7]]]></tag> </tagCollection> </plotcard> <plotcard order="1" id="2156"> <name><![CDATA[[placeholder for name of plotcard 2156]]]></name> <content><![CDATA[[placeholder for content of plotcard 2156]]]></content> <tagCollection> <tag id="2"><![CDATA[[placeholder for tag with id=2]]]></tag> <tag id="9"><![CDATA[[placeholder for tag with id=9]]]></tag> </tagCollection> </plotcard> </plotcardCollection> Here's my XSLT: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/plotcardCollection"> <xsl:variable name="sortby" select="@sortby" /> <xsl:for-each select="plotcard"> <xsl:sort select="$sortby" data-type="number" order="ascending"/> <div> <!-- Start Plotcard --> <xsl:attribute name="class">Plotcard</xsl:attribute> <xsl:for-each select="@"> <xsl:value-of select="name()"/> <xsl:text>='</xsl:text> <xsl:if test="name() = 'id'"> <xsl:text>Plotcard-</xsl:text> </xsl:if> <xsl:value-of select="." /> <xsl:text>'</xsl:text> </xsl:for-each> <!-- Start Plotcard Name Section --> <div> <xsl:attribute name="class"> <xsl:text disable-output-escaping="yes">PlotcardName</xsl:text> </xsl:attribute> <xsl:value-of select="name/text()"/> </div> <!-- Start Plotcard Content Section --> <div> <xsl:attribute name="class"> <xsl:text disable-output-escaping="yes">PlotcardContent</xsl:text> </xsl:attribute> <xsl:value-of select="content/text()"/> </div> </div> </xsl:for-each> </xsl:template> </xsl:stylesheet> I'm really not sure what to do about this.... any thoughts?

    Read the article

  • WCF contracts - namespaces and SerializationExceptions

    - by qntmfred
    I am using a third party web service that offers the following calls and responses http://api.athirdparty.com/rest/foo?apikey=1234 <response> <foo>this is a foo</foo> </response> and http://api.athirdparty.com/rest/bar?apikey=1234 <response> <bar>this is a bar</bar> </response> This is the contract and supporting types I wrote [ServiceContract] [XmlSerializerFormat] public interface IFooBarService { [OperationContract] [WebGet( BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Xml, UriTemplate = "foo?key={apikey}")] FooResponse GetFoo(string apikey); [OperationContract] [WebGet( BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Xml, UriTemplate = "bar?key={apikey}")] BarResponse GetBar(string apikey); } [XmlRoot("response")] public class FooResponse { [XmlElement("foo")] public string Foo { get; set; } } [XmlRoot("response")] public class BarResponse { [XmlElement("bar")] public string Bar { get; set; } } and then my client looks like this static void Main(string[] args) { using (WebChannelFactory<IFooBarService> cf = new WebChannelFactory<IFooBarService>("thirdparty")) { var channel = cf.CreateChannel(); FooResponse result = channel.GetFoo("1234"); } } When I run this I get the following exception Unable to deserialize XML body with root name 'response' and root namespace '' (for operation 'GetFoo' and contract ('IFooBarService', 'http://tempuri.org/')) using XmlSerializer. Ensure that the type corresponding to the XML is added to the known types collection of the service. If I comment out the GetBar operation from IFooBarService, it works fine. I know I'm missing an important concept here - just don't know quite what to look for. What is the proper way to construct my contract types, so that they can be properly deserialized?

    Read the article

< Previous Page | 5 6 7 8 9 10 11  | Next Page >