Search Results

Search found 70 results on 3 pages for 'svcutil'.

Page 2/3 | < Previous Page | 1 2 3  | Next Page >

  • Create and Consume WCF service using Visual Studio 2010

    - by sreejukg
    In this article I am going to demonstrate how to create a WCF service, that can be hosted inside IIS and a windows application that consume the WCF service. To support service oriented architecture, Microsoft developed the programming model named Windows Communication Foundation (WCF). ASMX was the prior version from Microsoft, was completely based on XML and .Net framework continues to support ASMX web services in future versions also. While ASMX web services was the first step towards the service oriented architecture, Microsoft has made a big step forward by introducing WCF. An overview of planning for WCF can be found from this link http://msdn.microsoft.com/en-us/library/ff649584.aspx . The following are the important differences between WCF and ASMX from an asp.net developer point of view. 1. ASMX web services are easy to write, configure and consume 2. ASMX web services are only hosted in IIS 3. ASMX web services can only use http 4. WCF, can be hosted inside IIS, windows service, console application, WAS(Windows Process Activation Service) etc 5. WCF can be used with HTTP, TCP/IP, MSMQ and other protocols. The detailed difference between ASMX web service and WCF can be found here. http://msdn.microsoft.com/en-us/library/cc304771.aspx Though WCF is a bigger step for future, Visual Studio makes it simpler to create, publish and consume the WCF service. In this demonstration, I am going to create a service named SayHello that accepts 2 parameters such as name and language code. The service will return a hello to user name that corresponds to the language. So the proposed service usage is as follows. Caller: SayHello(“Sreeju”, “en”) -> return value -> Hello Sreeju Caller: SayHello(“???”, “ar”) -> return value -> ????? ??? Caller: SayHello(“Sreeju”, “es”) - > return value -> Hola Sreeju Note: calling an automated translation service is not the intention of this article. If you are interested, you can find bing translator API and can use in your application. http://www.microsofttranslator.com/dev/ So Let us start First I am going to create a Service Application that offer the SayHello Service. Open Visual Studio 2010, Go to File -> New Project, from your preferred language from the templates section select WCF, select WCF service application as the project type, give the project a name(I named it as HelloService), click ok so that visual studio will create the project for you. In this demonstration, I have used C# as the programming language. Visual studio will create the necessary files for you to start with. By default it will create a service with name Service1.svc and there will be an interface named IService.cs. The screenshot for the project in solution explorer is as follows Since I want to demonstrate how to create new service, I deleted Service1.Svc and IService1.cs files from the project by right click the file and select delete. Now in the project there is no service available, I am going to create one. From the solution explorer, right click the project, select Add -> New Item Add new item dialog will appear to you. Select WCF service from the list, give the name as HelloService.svc, and click on the Add button. Now Visual studio will create 2 files with name IHelloService.cs and HelloService.svc. These files are basically the service definition (IHelloService.cs) and the service implementation (HelloService.svc). Let us examine the IHelloService interface. The code state that IHelloService is the service definition and it provides an operation/method (similar to web method in ASMX web services) named DoWork(). Any WCF service will have a definition file as an Interface that defines the service. Let us see what is inside HelloService.svc The code illustrated is implementing the interface IHelloService. The code is self-explanatory; the HelloService class needs to implement all the methods defined in the Service Definition. Let me do the service as I require. Open IHelloService.cs in visual studio, and delete the DoWork() method and add a definition for SayHello(), do not forget to add OperationContract attribute to the method. The modified IHelloService.cs will look as follows Now implement the SayHello method in the HelloService.svc.cs file. Here I wrote the code for SayHello method as follows. I am done with the service. Now you can build and run the service by clicking f5 (or selecting start debugging from the debug menu). Visual studio will host the service in give you a client to test it. The screenshot is as follows. In the left pane, it shows the services available in the server and in right side you can invoke the service. To test the service sayHello, double click on it from the above window. It will ask you to enter the parameters and click on the invoke button. See a sample output below. Now I have done with the service. The next step is to write a service client. Creating a consumer application involves 2 steps. One generating the class and configuration file corresponds to the service. Create a project that utilizes the generated class and configuration file. First I am going to generate the class and configuration file. There is a great tool available with Visual Studio named svcutil.exe, this tool will create the necessary class and configuration files for you. Read the documentation for the svcutil.exe here http://msdn.microsoft.com/en-us/library/aa347733.aspx . Open Visual studio command prompt, you can find it under Start Menu -> All Programs -> Visual Studio 2010 -> Visual Studio Tools -> Visual Studio command prompt Make sure the service is in running state in visual studio. Note the url for the service(from the running window, you can right click and choose copy address). Now from the command prompt, enter the svcutil.exe command as follows. I have mentioned the url and the /d switch – for the directory to store the output files(In this case d:\temp). If you are using windows drive(in my case it is c: ) , make sure you open the command prompt with run as administrator option, otherwise you will get permission error(Only in windows 7 or windows vista). The tool has created 2 files, HelloService.cs and output.config. Now the next step is to create a new project and use the created files and consume the service. Let us do that now. I am going to add a console application to the current solution. Right click solution name in the solution explorer, right click, Add-> New Project Under Visual C#, select console application, give the project a name, I named it TestService Now navigate to d:\temp where I generated the files with the svcutil.exe. Rename output.config to app.config. Next step is to add both files (d:\temp\helloservice.cs and app.config) to the files. In the solution explorer, right click the project, Add -> Add existing item, browse to the d:\temp folder, select the 2 files as mentioned before, click on the add button. Now you need to add a reference to the System.ServiceModel to the project. From solution explorer, right click the references under testservice project, select Add reference. In the Add reference dialog, select the .Net tab, select System.ServiceModel, and click ok Now open program.cs by double clicking on it and add the code to consume the web service to the main method. The modified file looks as follows Right click the testservice project and set as startup project. Click f5 to run the project. See the sample output as follows Publishing WCF service under IIS is similar to publishing ASP.Net application. Publish the application to a folder using Visual studio publishing feature, create a virtual directory and create it as an application. Don’t forget to set the application pool to use ASP.Net version 4. One last thing you need to check is the app.config file you have added to the solution. See the element client under ServiceModel element. There is an endpoint element with address attribute that points to the published service URL. If you permanently host the service under IIS, you can simply change the address parameter to the corresponding one and your application will consume the service. You have seen how easily you can build/consume WCF service. If you need the solution in zipped format, please post your email below.

    Read the article

  • WCF: WSDL-first approach: Problems with generating fault types

    - by Juri
    Hi, I'm currently in the process of creating a WCF webservice which should be compatible with WS-I Basic Profile 1.1. I'm using a wsdl-first approach (actually for the first time), defining first the xsd for the complex types, the WSDL and then using svcutil.exe for generating the according server as well as client-side interfaces/proxies. So far everything works fine. Then I decided to add a fault to my WSDL. Regenerating with svcutil succeeded, but then I noticed that my generated fault doesn't have the properties I defined in my xsd file (which is imported by my WSDL). Fault XSD definition <?xml version="1.0" encoding="UTF-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://product.mycompany.com/groupsfault_v1.xsd" xmlns:tns="http://product.mycompany.com/groupsfault_v1.xsd"> <complexType name="groupsFault"> <sequence> <element name="code" type="int"/> <element name="message" type="string"/> </sequence> </complexType> </schema> Generated .Net fault object [System.Diagnostics.DebuggerStepThroughAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")] [System.Xml.Serialization.XmlSchemaProviderAttribute("ExportSchema")] [System.Xml.Serialization.XmlRootAttribute(IsNullable=false)] public partial class groupFault : object, System.Xml.Serialization.IXmlSerializable { private System.Xml.XmlNode[] nodesField; private static System.Xml.XmlQualifiedName typeName = new System.Xml.XmlQualifiedName("groupFault", "http://sicp.services.siag.it/groups_v1.wsdl"); public System.Xml.XmlNode[] Nodes { get { return this.nodesField; } set { this.nodesField = value; } } public void ReadXml(System.Xml.XmlReader reader) { this.nodesField = System.Runtime.Serialization.XmlSerializableServices.ReadNodes(reader); } public void WriteXml(System.Xml.XmlWriter writer) { System.Runtime.Serialization.XmlSerializableServices.WriteNodes(writer, this.Nodes); } public System.Xml.Schema.XmlSchema GetSchema() { return null; } public static System.Xml.XmlQualifiedName ExportSchema(System.Xml.Schema.XmlSchemaSet schemas) { System.Runtime.Serialization.XmlSerializableServices.AddDefaultSchema(schemas, typeName); return typeName; } } Is this ok?? I'd expect to have an object created that contains properties for "code" and "message" s.t. you can then throw it by using something like ... throw new FaultException<groupFault>(new groupFault { code=100, message="error" }); ... (sorry for the lower-case type definitions, but this is generated code from the WSDL) Why doesn't the svcutil.exe generate those properties?? Some sources on the web suggested to add the /useSerializerForFaults option. I tried it, it doesn't work giving me an exception that the fault type is missing on the wsdl:portType declaration. Validation with several other tools succeeded however. Any help is VERY appreciated :) thx

    Read the article

  • WCF Web Service chnage wsdl name and targetNamespace

    - by Graham
    All, I'm a little new to WCF over IIS but have done some ASMX web services before. My WCF service is up and running but the helper page generated by the web service for me has the default names, i.e. the page that says: You have created a service. To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax: svcutil.exe http://localhost:53456/ServicesHost.svc?wsdl In a standard ASMX site I would use method/class attributes to give the web service a name and a namespace. When I click on the link the WSDL has: <wsdl:definitions name="SearchServices" targetNamespace="http://tempuri.org/" i.e. not the WCF Service Contract Name and Namespace from my Interface. I assume the MEX is using some kind of default settings but I'd like to change them to be the correct names. How can I do this?

    Read the article

  • WCF host address question

    - by Estelle
    when I setup the wcf service on a web server, I set the end point address as <endpoint address="http://www.mydomin.com/clientname/happy.svc" binding="basicHttpBinding" name="happysvcbasic" contract="happysvc.Ihappysvc"> </endpoint> but when type in above address on a browser, I get a different host name, which is the internal server name, such as, To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax: svcutil.exe http://internalservername.domain/clientname/happy.svc?wsdl I tried to add the host/baseaddress tag, but make no difference, what I missed? thanks for help.

    Read the article

  • How to access WCF RIA service from Windows Service?

    - by Duncan Bayne
    I have a functioning SL4 application; inside the ClientBin directory I have an .svc file that describes my service: <% @ServiceHost Service="MyApp.Services.MyServiceFactory="System.ServiceModel.DomainServices.Hosting.DomainServiceHostFactory" %> When I browse to http://localhost:52878/ClientBin/MyApp-Services-MyService.svc I see the following: "You have created a service. To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax: svcutil.exe http://localhost:52878/ClientBin/MyApp-Services-MyService.svc?wsdl" I want to access that service from a Windows Service application. My understanding is that I need to enable SOAP end-points in order to make this happen. So, I add the following to my web.config file: <domainServices> <endpoints> <add name="soap" type="System.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> </endpoints> </domainServices> Firstly, Intellisense complains about the presence of the tag, saying "The element system.ServiceModel has invalid child element domainServices." Secondly, the aforementioned Silverlight application stops working, presumably because this change breaks the underlying web services. Thirdly, it appears that the System.ServiceModel.DomainServices.Hosting assembly doesn't actually contain the SoapXmlEndpointFactory type; if I try to browse to the service after adding the above to web.config I see: "Could not load type 'System.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory' from assembly 'System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'." If I inspect the assembly using Reflector, I see that it contains the DomainServiceEndpointFactory and PoxBinaryEndpointFactory types, but no SoapXmlEndpointFactory. Could someone please let me know what I'm doing wrong? I can't believe that it should be this hard to simply consume a WCF RIA service in something other than a Silverlight application! Yours, Duncan Bayne

    Read the article

  • Why won't VS2010 RC use my existing types when I add a service reference?

    - by Johan Driessen
    I have a huge problem getting services references in VS2010 RC to use existing assemblies. Even though I have a class library with all the data contracts (classes marked with DataContract and properties with DataMember) that is shared between the service project and the consuming project (which is a class library), when I add a service reference, the data contracts are regenerated withing the service reference instead of using the existing types. When I was using VS2010 beta 2, this worked fine, and I have existing service references using the very same data contracts. But if I add a new service reference, or even update an old one, it won't use the existing types anymore. I have made a mini-test-solution, with one service, one data contract type and one console app as a consumer (all in the same solution), and there it seems to work, but that's no great comfort to me. Is there any way to see why it can't use the existing types? Edit to clearify. It works to generate the proxy classes with svcutil.exe, and point to the data contracts dll, like this: svcutil.exe http://localhost/MyService.svc /reference:[Path To DataContracts]\DataContracts.dll /n:*,MyProject.MyServiceReference /ct:System.Collections.Generic.List`1 The question is, what possible reason could there be for Visual Studio to generate its own datacontracts instead of using the existing ones even though the "reuse" checkbox is checked and the datacontracts assembly is referenced.

    Read the article

  • Consuming a WCF Service

    - by Lijo
    Hi I created a WCF service which is hosted in windows service. I created a proxy using svcutil “svcutil.exe http://localhost:8000/ServiceModelSamples/FreeServiceWorld?wsdl” It generated an output.config file and proxy class. The output.config has the following element <client> <endpoint address="http://localhost:8000/ServiceModelSamples/FreeServiceWorld" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IWeather" contract="IWeather" name="WSHttpBinding_IWeather"> <identity> <servicePrincipalName value="host/D471DTRV.ustr.com" /> </identity> </endpoint> </client> I created a website (as client) and added a new C# file (MyFile.cs) into it. I copied the contents of the proxy class into MyFile.cs. [The output.config is not copied to the web site] In the code behnid of aspx, I am using the following code WeatherClient client= new WeatherClient("WSHttpBinding_IWeather"); It throws an exception as “Could not find endpoint element with name 'WSHttpBinding_IWeather' and contract 'IWeather' in the ServiceModel client configuration section.” Could you please help me to understand the missing link here? Thanks Lijo

    Read the article

  • WCF hosting: Can access svc file but cannot go to wsdl link

    - by Impulse
    Hello, I have a WCF service that is hosted in IIS 7.5. I have two servers, one for test and one for production. The service works fine on test server, but on the production server I have the following error. When I access the address http//..../service.svc I can see the default page that says: You have created a service. To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax: svcutil.exe http://..../service.svc?wsdl This will generate a configuration file and a code file that contains the client class. Add the two files to your client application and use the generated client class to call the Service. But when I click the wsdl link, I cannot go to the wsdl page. It returns me to this default web page without any errors. I am suspecting a network/firewall authorization error but does anybody have an experience like this one? All IIS settings are the same for test and production servers. Thank you, Best Regards.

    Read the article

  • How do I import service references to Unity3D?

    - by Timothy Williams
    I'm attempting access a service reference in Unity. I need two: the SOAP framework and a separate service called ContentVault. The respective service URL's are: SOAP: http://api.microsofttranslator.com/V2/Soap.svc ContentVault: http://ioun.wizards.com/ContentVault.svc Both services import fine in to Visual Studio. I've tried everything I can think of but they won't work with Unity. I just get various errors (changing depending on which solution I'm trying out). I've attempted using svcutil to export the services as external scripts, but all I got was a bunch of using errors. I've tried converting the code to work with .NET 2.0 to no avail, I've even tried making the services in to .DLL's to no success. How could get these services working with Unity?

    Read the article

  • Invoking a WCF service using claims based authentication

    - by ashwnacharya
    I have a WCF service deployed in a server machine. We are using claims based authentication to authenticate the WCF service caller. The WCF service is restricted by using IIS Authorization rules. How do I programmatically invoke the WCF service using .NET? The client app uses a proxy generated using SVCUtil. calling the service reads the credentials from a configuration file (not the app.config file, in fact the client application does not have a *.config file).

    Read the article

  • WCF client and non-wcf client

    - by Lijo
    Hi, Could you please tell what is the difference between a WCF client and a non-WCF client? When I generate proxy of a WCF service using svcutil and put that in client, what is created - wcf client or non-wcf client? When should I use WCF client and non-WCF Client? Thanks Lijo

    Read the article

  • WCF – interchangeable data-contract types

    - by nmarun
    In a WSDL based environment, unlike a CLR-world, we pass around the ‘state’ of an object and not the reference of an object. Well firstly, what does ‘state’ mean and does this also mean that we can send a struct where a class is expected (or vice-versa) as long as their ‘state’ is one and the same? Let’s see. So I have an operation contract defined as below: 1: [ServiceContract] 2: public interface ILearnWcfServiceExtend : ILearnWcfService 3: { 4: [OperationContract] 5: Employee SaveEmployee(Employee employee); 6: } 7:  8: [ServiceBehavior] 9: public class LearnWcfService : ILearnWcfServiceExtend 10: { 11: public Employee SaveEmployee(Employee employee) 12: { 13: employee.EmployeeId = 123; 14: return employee; 15: } 16: } Quite simplistic operation there (which translates to ‘absolutely no business value’). Now, the data contract Employee mentioned above is a struct. 1: public struct Employee 2: { 3: public int EmployeeId { get; set; } 4:  5: public string FName { get; set; } 6: } After compilation and consumption of this service, my proxy (in the Reference.cs file) looks like below (I’ve ignored the rest of the details just to avoid unwanted confusion): 1: public partial struct Employee : System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged I call the service with the code below: 1: private static void CallWcfService() 2: { 3: Employee employee = new Employee { FName = "A" }; 4: Console.WriteLine("IsValueType: {0}", employee.GetType().IsValueType); 5: Console.WriteLine("IsClass: {0}", employee.GetType().IsClass); 6: Console.WriteLine("Before calling the service: {0} - {1}", employee.EmployeeId, employee.FName); 7: employee = LearnWcfServiceClient.SaveEmployee(employee); 8: Console.WriteLine("Return from the service: {0} - {1}", employee.EmployeeId, employee.FName); 9: } The output is: I now change my Employee type from a struct to a class in the proxy class and run the application: 1: public partial class Employee : System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged { The output this time is: The state of an object implies towards its composition, the properties and the values of these properties and not based on whether it is a reference type (class) or a value type (struct). And as shown above, we’re actually passing an object by its state and not by reference. Continuing on the same topic of ‘type-interchangeability’, WCF treats two data contracts as equivalent if they have the same ‘wire-representation’. We can do so using the DataContract and DataMember attributes’ Name property. 1: [DataContract] 2: public struct Person 3: { 4: [DataMember] 5: public int Id { get; set; } 6:  7: [DataMember] 8: public string FirstName { get; set; } 9: } 10:  11: [DataContract(Name="Person")] 12: public class Employee 13: { 14: [DataMember(Name = "Id")] 15: public int EmployeeId { get; set; } 16:  17: [DataMember(Name="FirstName")] 18: public string FName { get; set; } 19: } I’ve created two data contracts with the exact same wire-representation. Just remember that the names and the types of data members need to match to be considered equivalent. The question then arises as to what gets generated in the proxy class. Despite us declaring two data contracts (Person and Employee), only one gets emitted – Person. This is because we’re saying that the Employee type has the same wire-representation as the Person type. Also that the signature of the SaveEmployee operation gets changed on the proxy side: 1: [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] 2: [System.ServiceModel.ServiceContractAttribute(ConfigurationName="ServiceProxy.ILearnWcfServiceExtend")] 3: public interface ILearnWcfServiceExtend 4: { 5: [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILearnWcfServiceExtend/SaveEmployee", ReplyAction="http://tempuri.org/ILearnWcfServiceExtend/SaveEmployeeResponse")] 6: ClientApplication.ServiceProxy.Person SaveEmployee(ClientApplication.ServiceProxy.Person employee); 7: } But, on the service side, the SaveEmployee still accepts and returns an Employee data contract. 1: [ServiceBehavior] 2: public class LearnWcfService : ILearnWcfServiceExtend 3: { 4: public Employee SaveEmployee(Employee employee) 5: { 6: employee.EmployeeId = 123; 7: return employee; 8: } 9: } Despite all these changes, our output remains the same as the last one: This is type-interchangeability at work! Here’s one more thing to ponder about. Our Person type is a struct and Employee type is a class. Then how is it that the Person type got emitted as a ‘class’ in the proxy? It’s worth mentioning that WSDL describes a type called Employee and does not say whether it is a class or a struct (see the SOAP message below): 1: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 2: xmlns:tem="http://tempuri.org/" 3: xmlns:ser="http://schemas.datacontract.org/2004/07/ServiceApplication"> 4: <soapenv:Header/> 5: <soapenv:Body> 6: <tem:SaveEmployee> 7: <!--Optional:--> 8: <tem:employee> 9: <!--Optional:--> 10: <ser:EmployeeId>?</ser:EmployeeId> 11: <!--Optional:--> 12: <ser:FName>?</ser:FName> 13: </tem:employee> 14: </tem:SaveEmployee> 15: </soapenv:Body> 16: </soapenv:Envelope> There are some differences between how ‘Add Service Reference’ and the svcutil.exe generate the proxy class, but turns out both do some kind of reflection and determine the type of the data contract and emit the code accordingly. So since the Employee type is a class, the proxy ‘Person’ type gets generated as a class. In fact, reflecting on svcutil.exe application, you’ll see that there are a couple of places wherein a flag actually determines a type as a class or a struct. One example is in the ExportISerializableDataContract method in the System.Runtime.Serialization.CodeExporter class. Seems like these flags have a say in deciding whether the type gets emitted as a struct or a class. This behavior is different if you use the WSDL tool though. WSDL tool does not do any kind of reflection of the data contract / serialized type, it emits the type as a class by default. You can check this using the two command lines below:   Note to self: Remember ‘state’ and type-interchangeability when traversing through the WSDL planet!

    Read the article

  • Reusing my PagedList object on WCF

    - by AlexCode
    The problem: I have a custom collection PagedList<T> that is being returned from my WCF service as PagedListOfEntitySearchResultW_SH0Zpu5 when T is EntitySearchResult object. I want to reuse this PagedList<T> type between the application and the service. My scenario: I've created a PagedList<T> type that inherits from List<T>. This type is on a separated assembly that is referenced on both application and WCF service. I'm using the /reference option on the scvutil to enable the type reusing. I also don't want any arrays returned so I also use the /collection to map to the generic List type. I'm using the following svcutil command to generate the service proxy: "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\svcutil.exe" /collectionType:System.Collections.Generic.List`1 /reference:..\..\bin\Debug\App.Utilities.dll http://localhost/App.MyService/MyService.svc?wsdl /namespace:*,"App.ServiceReferences.MyService" /out:..\ServiceProxy\MyService.cs The PagedList object is something like: [CollectionDataContract] public partial class PagedList<T> : List<T> { public PagedList() { } /// <summary> /// Creates a new instance of the PagedList object and doesn't apply any pagination algorithm. /// The only calculated property is the TotalPages, everything else needed must be passed to the object. /// </summary> /// <param name="source"></param> /// <param name="pageNumber"></param> /// <param name="pageSize"></param> /// <param name="totalRecords"></param> public PagedList(IEnumerable<T> source, int pageNumber, int pageSize, int totalRecords) { if (source == null) source = new List<T>(); this.AddRange(source); PagingInfo.PageNumber = pageNumber; PageSize = pageSize; TotalRecords = totalRecords; } public PagedList(IEnumerable<T> source, PagingInfo paging) { this.AddRange(source); this._pagingInfo = paging; } [DataMember] public int TotalRecords { get; set; } [DataMember] public int PageSize { get; set; } public int TotalPages() { if (this.TotalRecords > 0 && PageSize > 0) return (int)Math.Ceiling((double)TotalRecords / (double)PageSize); else return 0; } public bool? HasPreviousPage() { return (PagingInfo.PageNumber > 1); } public bool? HasNextPage() { return (PagingInfo.PageNumber < TotalPages()); } public bool? IsFirstPage() { return PagingInfo.PageNumber == 1; } public bool? IsLastPage() { return PagingInfo.PageNumber == TotalPages(); } PagingInfo _pagingInfo = null; [DataMember] public PagingInfo PagingInfo { get { if (_pagingInfo == null) _pagingInfo = new PagingInfo(); return _pagingInfo; } set { _pagingInfo = value; } } }

    Read the article

  • Clients with multiple proxy and multithreading callbacks

    - by enzom83
    I created a sessionful web service using WCF, and in particular I used the NetTcpBinding binding. In addition to methods to initiate and terminate a session, other methods allow the client to send to one or more tasks to be performed (the results are returned via callback, so the service is duplex), but they also allow you to know the status of the service. Assuming you activate the same service on multiple endpoints, and assuming that the client knows these endpoints (for example, it could maintain a List of endpoints), the client should connect with one or more replicas of the same service. The client periodically updates the status of the service, so when it needs to perform a new task (the task is submitted by the user via UI), it selects the service currently less loaded and sends the task to it. Periodically, the client also initiates a maintenance procedure in order to disconnect from one or more overloaded service and in order to connect with new services. I created a client proxy using the svcutil tool. I wish each proxy can be used simultaneously by different threads, for example, in addition to the thread that submits the tasks using a proxy, there are also the following two threads which act periodically: a thread that periodically sends a request to the service in order to obtain the updated state; a thread that periodically selects a proxy to close and instantiates a new proxy to replace the closed one. To achieve these objectives, is it sufficient to create an array of proxies and manage their opening and closing in separate threads? I think I read that the proxy method calls are thread safe, so I would not need to perform a lock before requesting updates to the service. However, when the maintenance procedure (which is activated on its own thread) decides to close a proxy, should I perform a lock? Finally, each proxy is also associated with an object that implements the callback interface for the service: are the callbacks (invoked on the client) executed on different threads on the client? I would like to wrap the management of the proxy in one or more classes so that it can then easily manage within a WPF application.

    Read the article

  • Consuming WebSphere from WCF client: Unable to create AxisService from ServiceEndpointAddress

    - by JohnIdol
    I am consuming (or trying to consume) a WebSphere service from a WCF client (service reference + bindings generated through svcutil). Connection seems to be established successfully but I am getting the following error: CWWSS7200E: Unable to create AxisService from ServiceEndpointAddress [address] Rings any bell? I am guessing the request format is somehow being rejected by the service, I am sniffing it with fiddler and it looks fine overall (can post if ppl think it could help). Found this article, but it doesn't seem to apply to my case. Any help appreciated!

    Read the article

  • Consuming WebSphere service from WCF client: Unable to create AxisService from ServiceEndpointAddres

    - by JohnIdol
    I am consuming (or trying to consume) a WebSphere service from a WCF client (service reference + bindings generated through svcutil). Connection seems to be established successfully but I am getting the following error: CWWSS7200E: Unable to create AxisService from ServiceEndpointAddress [address] Rings any bell? I am guessing the request format is somehow being rejected by the service, I am sniffing it with fiddler and it looks fine overall (can post if ppl think it could help). Found this article, but it doesn't seem to apply to my case. Any help appreciated!

    Read the article

  • WCF - Cross platform question

    - by Lijo
    Hi Team, I have a simple WCF service, self hosting and a .net client. I am generating a proxy using svcutil. When I add the proxy to the client it asks me to add System.ServiceModel.dll. Well, I can add it since it is a test scenario and I am working in .Net platform. However, suppose I am using a machine that does not support .Net, how that platform would compensate for the System.ServiceModel? Could you please put some light on it? Thanks Lijo

    Read the article

  • IMetadataExchange endpoint purpose

    - by Paresh.Bijvani
    What is the purpose of IMetadataExchange endpoint. Some places i found that if i dont define this endpoint, adding service reference will not work OR creating proxy using svcutil wont work. But both of this working without having IMetadataExchange defined. If we have other endpoint with httpGetEnabled = true, we are able to create proxy from client. Also, some article says that we should delete IMetadataExchange before moving code to production and it should development period only so that other client cant see metadata. Doesnt this stop the behaviour of service having self describing itself? And if I have defined this IMetadataExchange endpoint, how can i see that on browser. Address whoch i have provided for this endpoint is not pulling any metadata in browser.

    Read the article

  • WCF - WebReferences not working

    - by JMSA
    At the client end, I have generated a Proxy using SvcUtil.exe and it is working fine. Then I have added a WebReference to the client assembly and calling the same method. But it is not working. My program is running in console mode and the method is suppose to return a string. It is not returning the string. I just see a blank console window. No exception is thrown. And after setting a debug point on the method call I see that, program is halted on the method call for ever. What should I look for to solve the problem? I am using VS2005. And adding the webReference by right-clicking the client project and then clicking "Add Web Reference" pop-up menu.

    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

  • Inject WCF proxy with credentials using StructureMap

    - by Steve Horn
    I have a service proxy generated by svcutil which generated an interface(IStudentContract) and a concrete type implementing (StudentContractClient). I'd like to have instances of StudentContractClient injected into my classes via StructureMap. My proxy also needs to have credentials supplied as seen in this passing unit test: <Test()> _ Public Sub Then_the_web_service_call_should_not_throw_an_exception() Dim studentServiceProxy As New StudentContractClient Dim credential As New NetworkCredential credential.Domain = ConfigurationManager.AppSettings("something") credential.UserName = ConfigurationManager.AppSettings("something") credential.Password = ConfigurationManager.AppSettings("something") studentServiceProxy.ClientCredentials.Windows.ClientCredential = credential Dim result = studentServiceProxy.GetCurrentTeachersByStudentSepid(26899) result.Count.ShouldEqual(4) End Sub My question is what would the structuremap configuration look like to have instances of IStudentContract injected with the credentials supplied? Thanks for any help!

    Read the article

  • wcf service on mobile 5.0

    - by user554271
    hi everyone, I have writed a primitive wcf (vs 2010) service and created proxy files by svcutil. Later I created a mobile project on vs2008 and added proxy files on project but this error occured. Error 1 The type or namespace name 'ServiceContractAttribute' does not exist in the namespace 'System.ServiceModel' (are you missing an assembly reference?) C:\Users\Abb\Documents\Visual Studio 2008\Projects\WCF\MobileService\MobileClient\Sample.cs the proxy files runs well on console application (vs 2008) but there is errors on mobile. System.ServiceModel doesnot support ServiceContractAttribute.

    Read the article

  • What's the best way to cancel an asynchronous WCF request?

    - by Pwninstein
    (Assuming a WCF method called "MyFunction") Currently, to support canceling a WCF request, I'm using the BeginMyFunction/EndMyFunction methods generated by svcutil (and handling an isCanceled flag when dispatching the results to the main thread). I'd like to use the MyFunctionAsync method (and hooking into MyFunctionAsyncCompleted event instead) for async calls instead of Begin/End. What is the best/supported way to handle canceling WCF requests if using MyFunctionAsyncCompleted, and still ensuring that the event doesn't get fired on a page that's no longer loaded (i.e. page navigation within a frame). Thanks!

    Read the article

  • Shared WCF client code between .NET and Silverlight apps?

    - by Eduardo Scoz
    I'm developing a .NET application that will have both a WinForms and a Silverlight client. Although the majority of code will be in the server, I'll need to have quite a bit of logic in the clients as well, and I would like to keep the client library code the same. From what I could figure out so far, I need to have two different project types, a class library and a Silverlight class library, and link the files from one project to the other. This seems kind of lame, but it works for simple code. My problem, though, is that the code generated by the SVCUtil.exe to access WCF services is different from the code generated by the slsvcutil.exe, and the silverlight code is actually incompatible with the .NET one: I get a bunch of problems with the System.ServiceModel.Channel classes when I try to import the class into .NET. Has anybody done anything similar to this before? What am I doing wrong?

    Read the article

< Previous Page | 1 2 3  | Next Page >