Search Results

Search found 26126 results on 1046 pages for 'generic service contract'.

Page 110/1046 | < Previous Page | 106 107 108 109 110 111 112 113 114 115 116 117  | Next Page >

  • Limit the number of service calls in a RESTful application

    - by Slavo
    Imagine some kind of a banking application, with a screen to create accounts. Each Account has a Currency and a Bank as a property, Currency being a separate class, as well as Bank. The code might look something like this: public class Account { public Currency Currency { get; set; } public Bank Bank { get; set; } } public class Currency { public string Code { get; set; } public string Name { get; set; } } public class Bank { public string Name { get; set; } public string Country { get; set; } } According to the REST design principles, each resource in the application should have its own service, and each service should have methods that map nicely to the HTTP verbs. So in our case, we have an AccountService, CurrencyService and BankService. In the screen for creating an account, we have some UI to select the bank from a list of banks, and to select a currency from a list of currencies. Imagine it is a web application, and those lists are dropdowns. This means that one dropdown is populated from the CurrencyService and one from the BankService. What this means is that when we open the screen for creating an account, we need to make two service calls to two different services. If that screen is not by itself on a page, there might be more service calls from the same page, impacting the performance. Is this normal in such an application? If not, how can it be avoided? How can the design be modified without going away from REST?

    Read the article

  • Checking to see if a generic class is inherited from an interface

    - by SnOrfus
    I've got a class that inherits from an interface. That interface defines an event that I'd like to subscribe to in the calling code. I've tried a couple of things, but they all resolve to false (where I know it's true). How can I check to see if a class implements a specific interface. Here's what I've tried (note, the object in question is a usercontrol that implements MyInterface, stored in an array of controls, only some of which implement MyInterface - it is not null): if (this.controls[index].GetType().IsSubclassOf(typeof(MyInterface))) ((MyInterface)this.controls[index]).Event += this.Handler; if (this.controls[index].GetType().IsAssignableFrom(typeof(MyInterface))) ((MyInterface)this.controls[index]).Event += this.Handler; if (this.controls[index].GetType() == typeof(MyInterface)) ((MyInterface)this.controls[index]).Event += this.Handler; All to no avail.

    Read the article

  • Invoking WCF service from Javascript

    - by KhanS
    I have a asp.net web application, and have some java script code in it. While calling the service I am getting the exception Service1 is undefined. Below is my code. Service: namespace WebApplication2 { // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together. [ServiceContract(Namespace="WCFServices")] public interface IService1 { [OperationContract] string HelloWorld(); } } Implementation namespace WebApplication2 { // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together. [ServiceBehavior(IncludeExceptionDetailInFaults = true)] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class Service1 : IService1 { public string HelloWorld() { return "Hello world from service"; } } } ASPX page: <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <asp:ScriptManager ID="QNAScriptManager" runat="server"> <Services> <asp:ServiceReference Path="~/Service1.svc" /> </Services> <Scripts> <asp:ScriptReference Path="~/Scripts/Questions.js" /> </Scripts> </asp:ScriptManager> </asp:Content> Java Script var ServiceProxy; function pageLoad() { ServiceProxy = new Service1(); ServiceProxy.set_defaultSucceededCallback(SucceededCallback); } function GetString() { ServiceProxy.HelloWorld(); } function SucceededCallback(result, userContext, methodName) { var RsltElem = document.getElementById("Results"); RsltElem.innerHTML = result + " from " + methodName + "."; alert("Msg received from service"); }

    Read the article

  • Deserialize generic collections - coming up empty

    - by AC
    I've got a settings object for my app that has two collections in it. The collections are simple List generics that contain a collection of property bags. When I serialize it, everything is saved with no problem: XmlSerializer x = new XmlSerializer(settings.GetType()); TextWriter tw = new StreamWriter(@"c:\temp\settings.cpt"); x.Serialize(tw, settings); However when I deserialize it, everything is restored except for the two collections (verified by setting a breakpoint on the setters: XmlSerializer x = new XmlSerializer(typeof(CourseSettings)); XmlReader tr = XmlReader.Create(@"c:\temp\settings.cpt"); this.DataContext = (CourseSettings)x.Deserialize(tr); What would cause this? Everything is pretty vanilla... here's a snippet from the settings object... omitting most of it. The PresentationSourceDirectory works just fine, but the PresentationModules' setter isn't hit: private string _presentationSourceDirectory = string.Empty; public string PresentationSourceDirectory { get { return _presentationSourceDirectory; } set { if (_presentationSourceDirectory != value) { OnPropertyChanged("PresentationSourceDirectory"); _presentationSourceDirectory = value; } } } private List<Module> _presentationModules = new List<Module>(); public List<Module> PresentationModules { get { var sortedModules = from m in _presentationModules orderby m.ModuleOrder select m; return sortedModules.ToList<Module>(); } set { if (_presentationModules != value) { _presentationModules = value; OnPropertyChanged("PresentationModules"); } } }

    Read the article

  • how to use anonymous generic delegate in C# 2.0

    - by matti
    Hi. I have a class called NTree: class NTree<T> { public NTree(T data) { this.data = data; children = new List<NTree<T>>(); _stopTraverse = false; } ... public void Traverse(NTree<T> node, TreeVisitor<T> visitor) { try { _stopTraverse = false; Traverse(node, visitor); } finally { _stopTraverse = false; } } private void TraverseInternal(NTree<T> node, TreeVisitor<T> visitor) { if (_stopTraverse) return; if (!visitor(node.data)) { _stopTraverse = true; } foreach (NTree<T> kid in node.children) Traverse(kid, visitor); } When I try to use Traverse with anonymous delegate I get: Argument '2': cannot convert from 'anonymous method' to 'NisConverter.TreeVisitor' The code: tTable srcTable = new tTable(); DataRow[] rows; rootTree.Traverse(rootTree, delegate(TableRows tr) { if (tr.TableName == srcTable.mappingname) { rows = tr.Rows; return false; } }); This however produces no errors: static bool TableFinder<TableRows>(TableRows tr) { return true; } ... rootTree.Traverse(rootTree, TableFinder); I have tried to put "arrowhead-parenthisis" and everything to anonymous delegate but it just does not work. Please help me! Thanks & BR -Matti

    Read the article

  • Java generic return type

    - by Colby77
    Hi, I'd like to write a method that can accept a type param (or whatever the method can figure out the type from) and return a value of this type so I don't have to cast the return type. Here is a method: public Object doIt(Object param){ if(param instanceof String){ return "string"; }else if(param instanceof Integer){ return 1; }else{ return null; } } When I call this method, and pass in it a String, even if I know the return type will be a String I have to cast the return Object. This is similar to the int param. How shall I write this method to accept a type param, and return this type?

    Read the article

  • Generic collection as a Java method argument

    - by Guido
    Is there any way to make this work in Java? public static void change(List<? extends Object> list, int position1, int position2) { Object obj = list.get(position1); list.set(position1, list.get(position2)); list.set(position2, obj); } The only way I've successfully avoided warnings and errors is this: public static <T> T change(List<T> list, int position1, int position2) { T obj = list.get(position1); list.set(position1, list.get(position2)); list.set(position2, obj); return obj; } but I don't like to be forced to return a value.

    Read the article

  • Equals method of System.Collections.Generic.List<T>...?

    - by Sambo
    I'm creating a class that derives from List... public class MyList : List<MyListItem> {} I've overridden Equals of MyListItem... public override bool Equals(object obj) { MyListItem li = obj as MyListItem; return (ID == li.ID); // ID is a property of MyListItem } I would like to have an Equals method in the MyList object too which will compare each item in the list, calling Equals() on each MyListItem object. It would be nice to simply call... MyList l1 = new MyList() { new MyListItem(1), new MyListItem(2) }; MyList l2 = new MyList() { new MyListItem(1), new MyListItem(2) }; if (l1 == l2) { ... } ...and have the comparisons of the list done by value. What's the best way...?

    Read the article

  • Relay WCF Service

    - by Matt Ruwe
    This is more of an architectural and security question than anything else. I'm trying to determine if a suggested architecture is necessary. Let me explain my configuration. We have a standard DMZ established that essentially has two firewalls. One that's external facing and the other that connects to the internal LAN. The following describes where each application tier is currently running. Outside the firewall: Silverlight Application In the DMZ: WCF Service (Business Logic & Data Access Layer) Inside the LAN: Database I'm receiving input that the architecture is not correct. Specifically, it has been suggested that because "a web server is easily hacked" that we should place a relay server inside the DMZ that communicates with another WCF service inside the LAN which will then communicate with the database. The external firewall is currently configured to only allow port 443 (https) to the WCF service. The internal firewall is configured to allow SQL connections from the WCF service in the DMZ. Ignoring the obvious performance implications, I don't see the security benefit either. I'm going to reserve my judgement of this suggestion to avoid polluting the answers with my bias. Any input is appreciated. Thanks, Matt

    Read the article

  • Generic Dictionary and generating a hashcode for multi-part key

    - by Andrew
    I have an object that has a multi-part key and I am struggling to find a suitable way override GetHashCode. An example of what the class looks like is. public class wibble{ public int keypart1 {get; set;} public int keypart2 {get; set;} public int keypart3 {get; set;} public int keypart4 {get; set;} public int keypart5 {get; set;} public int keypart6 {get; set;} public int keypart7 {get; set;} public single value {get; set;} } Note in just about every instance of the class no more than 2 or 3 of the keyparts would have a value greater than 0. Any ideas on how best to generate a unique hashcode in this situation? I have also been playing around with creating a key that is not unique, but spreads the objects evenly between the dictionaries buckets and then storing objects with matched hashes in a List< or LinkedList< or SortedList<. Any thoughts on this?

    Read the article

  • Open Source Utilization Questions: How do you lone wold programmers best take advantage of open sour

    - by Funkyeah
    For Clarity: So you come up with an idea for a new program and want to start hacking, but you also happen to be a one-man army. How do you programming dynamos best find and utilize existing open-source software to give you the highest jumping off point possible when diving into your new project? When you do jump in where the shit do you start from? Any imaginary scenarios would be welcome, e.g. a shitty example might be utilizing a open-source database with an open-source IM client as a starting off point to a make a new client where you could tag and store conversations and query those tags at a later time.

    Read the article

  • Steps in creating a web service using Axis2 - The client code

    - by zengr
    I am trying to create a web service, my tools of trade are: ** Axis2, Eclipse, Tomcat, Ant ** I need to create a web service from Code, i.e. Write a basic java class which will have the methods to be declared in the WSDL. Then use java2WSDL.sh to create my WSDL. So, is this approach correct: Write my Java class with actual business logic package packageNamel; public class Hello{ public void World(String name) { SOP("Hello" + name); } } Now, when I pass this Hello.java to java2WSDL.sh, this will give me the WSDL. Finally, I will write the services.xml file, and create the Hello.aar with following dir structure: Hello.aar packageName Hello.class META-INF services.xml MANIFEST.MF Hello.WSDL Now, I assume, my service will be deployed when I put the aar in tomcat1/webapps/axis2/WEB-INF/services But, here comes my problem, HOW DO I ACCESS THE METHOD World(String name)???!!, i.e. I am clueless about the client code! Please enlighten me on making a very basic web service and calling the method. The above described 3 steps might be wrong. It's a community wiki, feel free to edit. Thanks

    Read the article

  • WCF Security in a Windows Service

    - by Alphonso
    I have a WCF service which can run as Console App and a Windows Service. I have recently copied the console app up to a W2K3 server with the following security settings: <wsHttpBinding> <binding name="ServiceBinding_Security" transactionFlow="true" > <security mode="TransportWithMessageCredential" > <message clientCredentialType="UserName" /> </security> </binding> </wsHttpBinding> <serviceCredentials> <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Common.CustomUserNameValidator, Common" /> </serviceCredentials> Security works fine with no problems. I have exactly the same code, but running in a windows service and I get the following error when I try to call any of the methods from a client: System.ServiceModel.Security.MessageSecurityException was unhandled Message="An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail." Source="mscorlib" StackTrace: Server stack trace: at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout) ...... (lots of stacktrace info - not very useful) InnerException: System.ServiceModel.FaultException Message="An error occurred when verifying security for the message." The exception tells me nothing. I'm assuming that it has something to do with acces to system resources from the Windows Service. I've tried running it under the same account as the console app, but no luck. Does anyone have any ideas?

    Read the article

  • writing a web service with dynamically determined web methods

    - by quillbreaker
    Let's say I have a text file of basic mathematical functions. I want to make a web service that answers these mathematical functions. Say the first one is y=x*x. If I wanted to turn this into a web service, I could simply do this: [WebMethod] public int A(int x) { return x*x; } However, I've extracted the function from the list by hand and coded it into a function by hand. That's not what I want to do. I want the wsdl for the service to be generated at call time directly from the text file, and I want the web method calls to the service to go to a specific method that also parses the text file at run time. How much heavy lifting is this? I've found a sample on how to generate WSDLs dynamically at this link, but there's a lot more to do beyond that and I don't want to bark up this tree if there are parts of the project that arn't feasible. Does anyone have any links, guides, books, or positive experiences trying this kind of thing?

    Read the article

  • WCF Service timeout in Callback

    - by Muckers Mate
    I'm trying to get to grips with WCF, in particular writing a WCF Service application with callback. I've setup the service, together with the callback contract but when the callback is called, the app is timing out. Essentially, from a client I'm setting a property within the service class. The Setter of this property, if it fails validation fires a callback and, well, this is timing out. I realise that this is probably to it not being an Asynchronous calback, but can someone please show me how to resolve this? Thanks // The call back (client-side) interface public interface ISAPUploadServiceReply { [OperationContract(IsOneWay = true)] void Reply(int stateCode); } // The Upload Service interface [ServiceContract(CallbackContract = typeof(ISAPUploadServiceReply))] public interface ISAPUploadService { int ServerState { [OperationContract] get; [OperationContract(IsOneWay=true)] set; And the implementation... public int ServerState { get { return serverState; } set { if (InvalidState(Value)) { var to = OperationContext.Current.GetCallbackChannel<ISAPUploadServiceReply>(); to.Reply(eInvalidState); } else serverState = value; } }

    Read the article

  • Generic function pointers in C

    - by Lucas
    I have a function which takes a block of data and the size of the block and a function pointer as argument. Then it iterates over the data and performes a calculation on each element of the data block. The following is the essential outline of what I am doing: int myfunction(int* data, int size, int (*functionAsPointer)(int)){ //walking through the data and calculating something for (int n = 0; n < size; n++){ data[n] = (*function)(data[n]); } } The functions I am passing as arguments look something like this: int mycalculation(int input){ //doing some math with input //... return input; } This is working well, but now I need to pass an additional variable to my functionpointer. Something along the lines int mynewcalculation(int input, int someVariable){ //e.g. input = input * someVariable; //... return input; } Is there an elegant way to achieve this and at the same time keeping my overall design idea?

    Read the article

  • Windows 7 Service Pack 1 Install Failing

    - by Cu Jimmy
    I am having real trouble updating one of my machines to Win7 Service Pack 1. Its an Asus P5K board with an X9650 Quad Core Extreme chip, which is a less common type of chip. Was wondering if anyone has had issues with this kind of kit or if it may just be the motherboard is a little gone. The error message I get back from Microsoft Update is WindowsUpdate_80091007 and WindowsUpdate_dt000 which are fairly generic errors. Tried installing with the sp1 file based installer and got nowhere. The actual installer crashes with an SP Installer has crashed Its a fresh install on a fully scrubbed drive (an Intel 120GB SSD).

    Read the article

  • How to explain traits?

    - by Partial
    How would you explain traits to a new C++ programmer? How would you explain traits to a C programmer? How would you explain traits to a Java/Ruby/Python/C# or any other OOP language programmer?

    Read the article

  • A simple WCF Service (POX) without complex serialization

    - by jammer59
    I'm a complete WCF novice. I'm trying to build a deploy a very, very simple IIS 7.0 hosted web service. For reasons outside of my control it must be WCF and not ASMX. It's a wrapper service for a pre-existing web application that simply does the following: 1) Receives a POST request with the request body XML-encapsulated form elements. Something like valuevalue. This is untyped XML and the XML is atomic (a form) and not a list of records/objects. 2) Add a couple of tags to the request XML and the invoke another HTTP-based service with a simple POST + bare XML -- this will actually be added by some internal SQL ops but that isn't the issue. 3) Receive the XML response from the 3rd party service and relay it as the response to the original calling client in Step 1. The clients (step 1) will be some sort of web-based scripting but could be anything .aspx, python, php, etc. I can't have SOAP and the usual WCF-based REST examples with their contracts and serialization have me confused. This seems like a very common and very simple problem conceptually. It would be easy to implement in code but IIS-hosted WCF is a requirement. Any pointers?

    Read the article

  • Does anyone know how to detect whether a Windows Service is running through Java

    - by GKelly
    There's plenty of information on running Java apps as services, but I need to know how to detect whether a windows service is running or not. Does anyone know how??? At the DOS prompt, I can run: tasklist /svc|findstr "NonRunningService" echo Return code for N onRunningService is %ERRORLEVEL% tasklist /svc|findstr "RunningService" echo Return code for RunningService is %ERRORLEVEL% I get the following: Return code for NonRunningService is 1 Return code for RunningService is 0 In code, I have: int retCode = Runtime.getRuntime.exec("tasklist /svc|findstr \"NonRunningService\"").waitFor(); System.out.println("Return code for NonRunningService is " + retCode); retCode = Runtime.getRuntime.exec("tasklist /svc|findstr \"RunningService\"").waitFor(); System.out.println("Return code for RunningService is " + retCode); I get the following output Return code for NonRunningService is 1 Return code for RunningService is 1 According to the JavaDocs, the waitFor() should block until the process finishes, and give me the exit value of the process. I've also tried using the Process/ProcessBuilder command line calls: //'tasklist /nh /fi "SERVICES eq RunningService"' will return a line for // each running service of the requested type. Process p1 = new ProcessBuilder("tasklist", "/nh", "/fi" "SERVICES eq RunningService").start(); p1.waitFor(); BufferedReader is = new BufferedReader(new InputStreamReader(p1.getInputStream())); String line = is.readLine(); System.out.println("Service - " + line); System.out.println("Running? ", (line==null?"No":"Yes"); gives: Service - Running? No even when I get lines in the output at the command line!

    Read the article

  • C# Generic Arrays and math operations on it

    - by msedi
    Hello, I'm currently involved in a project where I have very large image volumes. This volumes have to processed very fast (adding, subtracting, thresholding, and so on). Additionally most of the volume are so large that they event don't fit into the memory of the system. For that reason I have created an abstract volume class (VoxelVolume) that host the volume and image data and overloads the operators so that it's possible to perform the regular mathematical operations on volumes. Thereby two more questions opened up which I will put into stackoverflow into two additional threads. Here is my first question. My volume is implemented in a way that it only can contain float array data, but most of the containing data is from an UInt16 image source. Only operations on the volume can create float array images. When I started implementing such a volume the class looked like following: public abstract class VoxelVolume<T> { ... } but then I realized that overloading the operators or return values would get more complicated. An example would be: public abstract class VoxelVolume<T> { ... public static VoxelVolume<T> Import<T>(param string[] files) { } } also adding two overloading operators would be more complicated: ... public static VoxelVolume<T> operator+(VoxelVolume<T> A, VoxelVolume<T> B) { ... } Let's assume I can overcome the problems described above, nevertheless I have different types of arrays that contain the image data. Since I have fixed my type in the volumes to float the is no problem and I can do an unsafe operation when adding the contents of two image volume arrays. I have read a few threads here and had a look around the web, but found no real good explanation of what to do when I want to add two arrays of different types in a fast way. Unfortunately every math operation on generics is not possible, since C# is not able to calculate the size of the underlying data type. Of course there might by a way around this problem by using C++/CLR, but currently everything I have done so far, runs in 32bit and 64bit without having to do a thing. Switching to C++/CLR seemed to me (pleased correct me if I'm wrong) that I'm bound to a certain platform (32bit) and I have to compile two assemblies when I let the application run on another platform (64bit). Is this true? So asked shortly: How is it possible to add two arrays of two different types in a fast way. Is it true that the developers of C# haven't thought about this. Switching to a different language (C# - C++) seems not to be an option. I realize that simply performing this operation float []A = new float[]{1,2,3}; byte []B = new byte[]{1,2,3}; float []C = A+B; is not possible and unnecessary although it would be nice if it would work. My solution I was trying was following: public static class ArrayExt { public static unsafe TResult[] Add<T1, T2, TResult>(T1 []A, T2 []B) { // Assume the length of both arrays is equal TResult[] result = new TResult[A.Length]; GCHandle h1 = GCHandle.Alloc (A, Pinned); GCHandle h2 = GCHandle.Alloc (B, Pinned); GCHandle hR = GCHandle.Alloc (C, Pinned); void *ptrA = h1.ToPointer(); void *ptrB = h2.ToPointer(); void *ptrR = hR.ToPointer(); for (int i=0; i<A.Length; i++) { *((TResult *)ptrR) = (TResult *)((T1)*ptrA + (T2)*ptrB)); } h1.Free(); h2.Free(); hR.Free(); return result; } } Please excuse if the code above is not quite correct, I wrote it without using an C# editor. Is such a solution a shown above thinkable? Please feel free to ask if I made a mistake or described some things incompletely. Thanks for your help Martin

    Read the article

  • Concrete Implementation of Generic Form Not Working in Designer

    - by Dov
    I have a base class, defined as below (I'm also using DevExpress components): public abstract partial class BaseFormClass<R> : XtraForm where R : DataRow { ... } Contrary to what I've read from elsewhere, I'm still able to design this class. I didn't have to create a concrete class from it to do so. But, when I create a concrete class descended from it (as below), that class won't work in the designer. public partial class ConcreteFormClass : BaseFormClass<StronglyTypedRow> { ... } I get this message: The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file: ConcreteFormClass --- The base class 'BaseFormClass' could not be loaded. Ensure the assembly has been referenced and that all projects have been built. Has anyone seen this before? Any sort of known workaround?

    Read the article

  • C# Delegate under the hood question.

    - by Ted
    Hi Guys I was doing some digging around into delegate variance after reading the following tquestion in SO. "delegate-createdelegate-and-generics-error-binding-to-target-method" (sorry not allowed to post more than one hyperlink as a newbie here!) I found a very nice bit of code from Barry kelly at https://www.blogger.com/comment.g?blogID=8184237816669520763&postID=2109708553230166434 Here it is (in a sugared-up form :-) using System; namespace ConsoleApplication4 { internal class Base { } internal class Derived : Base { } internal delegate void baseClassDelegate(Base b); internal delegate void derivedClassDelegate(Derived d); internal class App { private static void Foo1(Base b) { Console.WriteLine("Foo 1"); } private static void Foo2(Derived b) { Console.WriteLine("Foo 2"); } private static T CastDelegate<T>(Delegate src) where T : class { return (T) (object) Delegate.CreateDelegate( typeof (T), src.Target, src.Method, true); // throw on fail } private static void Main() { baseClassDelegate a = Foo1; // works fine derivedClassDelegate b = Foo2; // works fine b = a.Invoke; // the easy way to assign delegate using variance, adds layer of indirection though b(new Derived()); b = CastDelegate<derivedClassDelegate>(a); // the hard way, avoids indirection b(new Derived()); } } } I understand all of it except this one (what looks very simple) line. b = a.Invoke; // the easy way to assign delegate using variance, adds layer of indirection though Can anyone tell me: how it is possible to call invoke without passing the param required by the static function. When is going on under the hood when you assign the return value from calling invoke What does Barry mean by extra indirection (in his comment)

    Read the article

< Previous Page | 106 107 108 109 110 111 112 113 114 115 116 117  | Next Page >