Quantcast
Channel: WCF Data Services forum
Viewing all 877 articles
Browse latest View live

Make all Entity class in EDM Model derive from a base class, for Odata Services

$
0
0

I tried creating all the entities of the EDM model derived from a base Entity, (oData Service)

but it was not retrieving any data no error pop'ed up. 

when I removed the base class , the data retrieval was successful, I am looking for some solution where we can implement the base class which is not part of the data structure.


svanamali


Creating a WCF services

$
0
0

Hello Experts,

I am new to the WCF Data services and trying to learn them. I am trying to create a WCF Data Service for an Oracle Database. What I have is a complex query which queries from various tables in Oracle DB with various filters. And through the Webservice we will need to pass an Element Value (called Project ID) which execute the complex query and returns those results.

When I googled, I tried creating ADO.Net Entity Data Model by selecting the required tables from the DB.

But I am little confused where will I be giving the complex query. Can anyone please suggest me how will I be proceeding with this

Push SQL Server Changes To Android Through WCF

$
0
0

Hello,

I have a SQL Server 2008 R2 database that serves as a backend for multiple apps. I want to be able to detect certain changes in a few of the tables (ie. row insert/row update/row deleted) and push those changes to an Android app. I already use a WCF RESTful Service to pull data from SQL Server to the Android, so the simplest way seems to be to also use the same WCF service to push SQL Server changes back to the Android.

My question is, how do I detect changes made in SQL Server from WCF?

Thank you so much!

S Lane

Issue while upgrading from WCF data service 2.0 to 5.0 (Could not load file or assembly 'System.Data.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.)

$
0
0

I have data web service application developed in .net 4.0 with WCF version 2.0

I have downloaded the new version of wcf data service in my machine which is on Windows 7.

I have already removed all references to system.data.service and system.data.service and system.data.service.client and added references to the new DLL installed for version 5.0

I have updated the MAx protocol to point to version 3

config.DataServiceBehavior.MaxProtocolVersion =

DataServiceProtocolVersion.V3;

I have updated the markup of the wcf to point to version 5

<%

@ServiceHostLanguage="C#"Factory="System.Data.Services.DataServiceHostFactory, System.Data.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"Service="ca.esi.hd.integration.crm.wcfdataservice.WcfDataService"%>

After that I have got the following error and I think the application still looking at the old version

Could not load file or assembly 'System.Data.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.

the TRace of the assembly load give me the following error(It looks like the project still looking at the old version)

Please advise. I am trying to upgrade my web service to use collection as input.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Data.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' could not be loaded.

=== Pre-bind state information ===
LOG: User = XXXX\XXXX
LOG: DisplayName = System.Data.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 (Fully-specified)
LOG: Appbase = file:///C:/Users/XXX/Documents/Visual Studio 2010/Projects/Web service/CrmQA-Scheduler2/ESICrmWcfService/
LOG: Initial PrivatePath = C:\Users\XXX\Documents\Visual Studio 2010\Projects\Web service\CrmQA-Scheduler2\ESICrmWcfService\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\XXXX\Documents\Visual Studio 2010\Projects\Web service\CrmQA-Scheduler2\ESICrmWcfService\web.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Data.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

On WcfDataService URI i can't update if the entity key field contains an slash. With Frmaework 4.6.1 and entity framework 6

$
0
0
On WcfDataService URI i can't update if the entity key field contains an slash. With Frmaework 4.6.1 and entity framework 6

vs 2013 dot net 4.6 service reference missing Microsoft.Data.Services.Design

$
0
0

Hello,

         I have been running into an issue when I try to add service refs to a .net 4.6 project in vs 2013; I get the following dialog

---------------------------
Microsoft Visual Studio
---------------------------
Could not load file or assembly 'Microsoft.Data.Services.Design, Version=5.6.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
---------------------------
OK   
---------------------------

Checking

C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.Data.Services.Design

I see a folder for 5.0.0; and I have tried installing

https://www.microsoft.com/en-us/download/details.aspx?id=45308&wa=wsignin1.0

to no avail.

I did use this https://sourceforge.net/projects/gacbrowser/ and found various language resource files exist for the 5.6.3 release are in the gac; but this is of little use as the assembly itself is mia.

Any advice would be appreciated.

   -Andrew


Recover Deleted Cases on CRM 2011 Dynamic

$
0
0

i have deleted  Cases accidentally and i'm trying to return them we have the auditing permission but we only found the user Access Summary in the Audit Summary View.however the IT department take an image backup of the CRM weekly .i want only to access the SQL database in order to return the deleted records but i don't know exactly how to find them .also  the CRM server is a local server.

Please Help ..




Error using WS-AT (MSDTC) between cross-machines with WSHttpBinding

$
0
0

I've got two systems and I want to use a distributed transaction, so I can assure that they are always synchronized. The transaction must be over internet, as both servers will not be in the same domain.

Here are the configurations I've already made about certificates and SSL:

  1. Created a self-signed certificate A for machine A, installed on both Trusted Root Authoritiesand Personal stores
  2. Created a self-signed certificate B for machine B, installed on both Trusted Root Authoritiesand Personal stores
  3. Installed certificate B with the public key on the machine A on both Trusted Root Authoritiesand Personal stores
  4. Installed certificate A with the public key on the machine B on both Trusted Root Authoritiesand Personal stores

Theoretically, SSL should suffice with those configurations.

On MSDTC configurations:

  1. Enabled network DTC access
  2. Allowed inbound and outbound on both machine A and B
  3. Using 'mutual authentication required' (also tested with 'no authentication required')
  4. Allowed remote clients

And next are the configurations I've made on WS-AT:

  1. Enabled WS-Atomic, of course
  2. On machine A, set the certificate A as the Endpoint Certificate
  3. On machine A, set the certificate B as the Authorized Certificates
  4. On machine B, set the certificate B as the Endpoint Certificate
  5. On machine B, set the certificate A as the Authorized Certificates
  6. Set the port to 442 (the one I'm using on tets only)

For instance, the address that I'm using for communication between the servers are "https://IP:442/ws" and always machine A (client) calls machine B (server), never the opposite. I'musing WSHttpBinding.

Both certificates' subject name (common name) matches with machine name, as told as required in msdn (can't insert link yet).

Theoretically, MSDTC and WS-AT configurations are all set with this.

In code, using WCF, everything needed are well done, like the attributes TransactionFlow, TransactionScopeRequired, etc.

An importante note is that it's working when I run both applications on the same intranet or locally, but when I try over the internet, I got this error:

"The flowed transaction could not be unmarshaled. The following exception occurred: The MSDTC transaction manager's WS-AtomicTransaction protocol service 'Version10' is disabled and cannot unmarshal incoming transactions."

Does anyone know what I'm missing?

Searching on the internet, this error seems to be caused by a failure on the SSL negotiation, but I just don't know whats missing on the configuration.

Main link I'm using as guide: "MSDN: Configurint WS-Atomic Transaction Support" (can't insert link yet, but that's the topics name on msdn)

--- EDIT/UPDATE 1 ---

After registering the certificate as sslcert from netsh on port 442 on the server (machine B), the error changes to:

"The flowed transaction could not be unmarshaled. The following exception occurred: The WS-AtomicTransaction protocol service could not unmarshal the flowed transaction. The following exception occured: A fault reply with code CoordinatorRegistrationFailed was received. The fault reason follows: The WS-AT protocol service failed to register with its coordinator. A connection could not be established."

While searching I've fount it's because the server (machine B) is not trusting the client (machine A), but still don't know what's missing.

-- CODE PART --

I'm using the following configuration of bindings:

WSHttpBinding binding = BindingFactory.CreateWSHttpBinding(); binding.TransactionFlow = true; binding.Security.Mode = SecurityMode.TransportWithMessageCredential; binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate; binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName; binding.Security.Message.NegotiateServiceCredential = NegotiateServiceCredential; binding.Security.Message.EstablishSecurityContext = true; binding.ReliableSession.Enabled = false; binding.ReliableSession.Ordered = false;

A litte bit of code implementation, just showing some examples:

// Interface between apps public class IProvider { [TransactionFlow(TransactionFlowOption.Allowed)] void Method(int parameter1); } --- // Server side implementation of interface [ServiceBehavior(ReleaseServiceInstanceOnTransactionComplete = false)] public class Provider { [OperationBehavior(TransactionScopeRequired = true)] public void Method(int parameter1) { return parameter1; // only for example } } --- // Code that is calling the other service TransactionOptions transactionOptions = new TransactionOptions() { Timeout = new TimeSpan(0, 15, 0), IsolationLevel = IsolationLevel.ReadCommitted, }; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, transactionOptions)) { // Code calling the other service on machine B... using (IProvider provider = new Provider()) provider.Method(1);

scope.Complete;
}

It's important to say again that it's working both locally and client and server inside intranet.



Getting Unable to load metadata exception while trying return custom class object in webget method of OData service.

$
0
0
We have WCF data service( OData service) on top of entity framework( edmx) and have written some custom operation in the wcf data service to implement some business logic. We are able to access these custom service operations along with edmx entities. But when we try to add a service operation which return custom class object which is not part of entity context( edmx), then we are facing an issue "unable to load metadata". We have tried different approaches to manually set datacontract attibute, dataservice key on the custom class and adding manually that entity as "public virtual DbSet<customclass> customlist{ get; set; }" to dbcontext but we are facing below issue:

"The server encountered an error processing the request. The exception message is 'Unable to load metadata for return type 'System.Linq.IQueryable`1[Entities.tblUser]' of method 'System.Linq.IQueryable`1[Entities.tblUser] GetUser(System.String, System.String)'."

We are using MaxDataProtocolVersion.V3 in wcf data service and entity framework 6.0

Please let us know whether custom class object return type is supported in WCF data service or not?

Will WCF Data Services release new version in furture?

$
0
0

I want to use it but now my models has a lot of Enum.

Can you tell me if you will solve this someday or give me some other good way to use EF with my sever and winform client?

thank you!

What is the logic behind a class in wcf service is decorated with DataContract and Serializable attribute????

$
0
0

Hi can anyone tell me the reason,

In wcf we are using datacontract serializatin by default rt???...what benefit we will get if we use both serializable and datacontract???

  [DataContract]
    [Serializable()]
    public class Data
    {

//Properties and methods

   }


Latheesh K Contact No:+91-9747369936

WCF Data service $metadata 404 (Not Found) when deploying client app

$
0
0

Dear Gurus

I have developed simple WCF Data service with visual studio 2015 the service uses EF that connects to two tables in SQL server 2008 it was just straight Data service with no code in it only the generated code 

using System;
using System.Collections.Generic;
using System.Data.Services;
using System.Data.Services.Common;
using System.Linq;
using System.ServiceModel.Web;
using System.Web;

namespace MIKMODataServiceSite
{
    public class MIKMOWCFDataService : DataService< MIKMOEntities >
    {
        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
        {
            // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
            // Examples:
            config.SetEntitySetAccessRule("*", EntitySetRights.All);
            //config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
        }
    }
}

and below the web.config 

<?xml version="1.0" encoding="utf-8"?><!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  --><configuration><configSections><!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --><section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /></configSections><system.web><compilation debug="true" targetFramework="4.5.2" /><httpRuntime targetFramework="4.5.2" /></system.web><system.codedom><compilers><compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" /><compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" /></compilers></system.codedom><connectionStrings><add name="MIKMOEntities" connectionString="metadata=res://*/MIKMODataService.csdl|res://*/MIKMODataService.ssdl|res://*/MIKMODataService.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=MIKMO;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /></connectionStrings><entityFramework><defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"><parameters><parameter value="v13.0" /></parameters></defaultConnectionFactory></entityFramework><system.serviceModel><serviceHostingEnvironment aspNetCompatibilityEnabled="true" /><behaviors><serviceBehaviors><behavior name="Metadata"><serviceMetadata httpGetEnabled="true" /></behavior></serviceBehaviors></behaviors></system.serviceModel></configuration>

and hosted it on my local IIS and things were more than perfect then i developed a client app with SAPUI5 framework and again it was so smooth with zero errors until i hosted my client app on the local IIS i started to get the following error $metadata 404 (Not Found) 

While developing i didnt get that error and i was developing the client app with Eclipse that uses Apache tomcat to run the SAPUI5 app 

Kindly assist is there is anything to be done in WCF data service app or is it IIS issue 

Thanks for your consideration 

Accepting client certificates for WCF authentication

$
0
0

Hi, I'm looking for a full explanation on how to setup client authentication via certificate to my WCF service. I've looked at some samples that I've found via google and I'm getting mixed information. Some are telling me to use IIS configuration to manage it, others show web.config settings in ServiceBehavior.

What I have so far

* WCF service hosted on Windows Server 2012 R2, works with "client certificates: ignore" in SSL settings using Windows authentication

If I change to "client certificates: accept" I get 401 all the time.

What I need to do:

* Change configuration of service to accept a client certificate OR Windows authentication

* Specify a list of certificates to accept:

For example: If issued by [thumbprint], accept or if CN = [CN], accept

I can't seem to find a clear example that shows me how I can do this.


Many thanks in advance!

Using DataTable between webservice and client

$
0
0

Hi

I have a small problem regarding Oracle BLOB data, .NET DataTable and MS Access database.

The scenario is this:
A client starts a request of data to a WCF Webservice.
The Webservice fetch data from an Oracle 12 database. The tables can consist of MS Word files, saved in an OracleLob column of type BLOB.
The Webservice then reads the data into a System.Data.DataTable.

The service returns the data to the client and the client saves it to a local MS Access database.

The remaining problem is the files, witch won't open in Word, but inform me that the file is corrupt.
I can see that the file size of the service-file is bigger than the size of the original file.

Where has the error occurred?

This is the facts and actual code:
Oracle database
        DATA_TYPE: BLOB

System.Data.DataTable column
        Dim Col2 As New Data.DataColumn()
        Col2.DataType = System.Type.GetType("System.Byte[]")
        Col2.ColumnName = "FLDGRMFILE"
        Col2.Caption = "GRMfil"
        Col2.AllowDBNull = True
        mobTable.Columns.Add(Col2)

Read the data
        Dim myBlob As OracleLob = rsS.GetOracleLob(rsS.GetOrdinal("FLDGRMFILE"))
        srcGrm = New Byte(myBlob.Length) {}
        myBlob.Read(srcGrm, 0, srcGrm.Length)
        objRow("FLDGRMFILE") = srcGrm

Extract file data from System.Data.DataTable column
        Dim fileBytes As Byte() = rw("FLDGRMFILE")

Save it to the Access database
        cmC = New OleDb.OleDbCommand("UPDATE TBLGRM SET fldGRMFile=? WHERE fldSkbObjectName = " & srcObject, cnC)
        Dim Prm As New OleDb.OleDbParameter("@fldGRMFile", OleDb.OleDbType.LongVarBinary, fileBytes.Length,         ParameterDirection.Input, False, 0, 0, Nothing, DataRowVersion.Current, fileBytes)
        cmC.Parameters.Add(Prm)
        cmC.ExecuteNonQuery()

Export file from Access database
        Open strImagePath For Binary As #intNum
        fileLength = rs(0).FieldSize
        byteBlob() = rs(0).GetChunk(0, fileLength)
        Put #intNum, , byteBlob()
        Close #intNum


Best Regards Peter Karlström Midrange AB, Sweden



Can anyone Explain to me What is the use of "DataMember" attribute inside a ServiceContrac interface

$
0
0

In the following code snippet,

In interface i can write properties without implementation but in wcf how it will behave and what is its uses.In the client side while consuming the service i ca access only the methods which are decorated with operationcontract .I can'nt access the DataMember properties.Then what is the use of Datamember inside a servicecontract.

 [ServiceContract]
    public interface IServer
    {
        [OperationContract]
        string DoWork();
       [DataMember]
         int ID { get; set; }
        [DataMember]
        string  Name { get; set; }
    }

Regards,

Latheeesh


Latheesh K Contact No:+91-9747369936



I want to run the WCF Services Application

$
0
0

When I added a WCF Services Application, then the corresponding service has been quoted., It appears a window when I run it, I can call the method on the inside . The problem is when I re run, this magical form disappeared, replaced by the list of files, it allows me to copy the code inside to create host .  How can I do, I need to copy this code to where it can run,  it has been that window, where it goes, and how to make it appear again?

The more detailed the better, I hope to have a map to guide me.

Any advise appreciated.

WCF Error VS 2015 on Windows 10

$
0
0

Hi people,
Sorry for my english in advance.

I'm writing this post because two partners of mine have a problem connecting to two services. The error is the following:

"An unsecured error or incorrectly secured fault was received from the other party. See the inner fault exception for the fault code and detail."

I've been reading similar errors regarding a difference between the server and local time, but there is no difference in this case.
The weird fact is that me and other developers have W8 and there is no error, all is working right for us. The only who have problems are they, whom have W10 (clean instalation, not upgrade). 

Are there a possibility that a certificate is not compatible with Windows 10? They are also using Visual Studio 2015. 
There is a particular case too, that a partner is using W10 but is developing with VS2012 instead of 2015 and is working well, so, could be a problem of framework?

Have you an advice or tip?

Thank you in advance!


DBDomainService & DbContext RIA Class Library, EF 5

$
0
0

Dear All,

I am using EF5, Silverlight, RIA Service in a project.

I have a RIA class library project (with the two projects), I have setup everything correctly for the other SL projects to the class library.

I created .EDMX in RIA .web project for the database and I got the following class generated:

public partial class SCEntities : DbContext
{
     public SCEntities()
         : base("name=SCEntities")
    {
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        throw new UnintentionalCodeFirstException();
    }

    public DbSet<period> periods { get; set; }
    public DbSet<user> users { get; set; }
}

In my client SL application, I can't get a reference to the DbContext class (SCEntities).

I created a DomainService Class in the RIA Class .web project it inherit the DBDomainService (as previous EF4) as follows:

public partial class SCDomainService : DbDomainService<SCEntities>
{
}

I go back to my SL application & I can reference the SCDomainService with no problem.

Why I can not reference or access the SCEntities (dbcontext) ?

Is it right to go with the DomainService?

Best.

OData unbounded function

$
0
0

I have an OData webapi project that works for all of the standard OData queries.  However, I have need of a custom function and have tried many variations from references I've googled, but still cannot get it.  I keep getting an error saying that my path is not a valid OData path template.

In my webApiConfig.cs, 

            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
            builder.EntitySet<Disclosure>("Disclosures").EntityType.HasKey(r => new { r.pKey });
            builder.EntityType<Disclosure>();

I set the builder.Namespace = "All";

and then I try setting up the custom path:

            var disclosure = builder.EntitySet<Disclosure>("Disclosures").EntityType;
            builder.EntityType<Disclosure>().Function("PDF").Returns<string>();

this one is an attempt at a bound function, but I'd gladly use an unbounded one if I could get that work.

In my controller, I have the following:

        [ODataRoute("Disclosures({key})/All.Models.PDF")]
        public IHttpActionResult PDF()
        {
            string result = "";

            return Ok(result);
        }


This is with the assumption that I would call this via syntax like:

http://localhost:51789/Odata/Disclosures(e0580a6f-dd77-45e0-b83e-593862149b85)/PDF

although, if I could do it as an unbounded function where I could just call PDF and pass in the key, I'd gladly do that.

Please help.

PS.  I'm even open to creating a generic, non-Odata controller, and just having the function there, but then I'd still need help setting up the route to it.


Stockton

Filter operation such startsWith in Odata

$
0
0
startswith operation in filter,

Returns the all records which has "given letter as starting letter", This wont consider, it is small letter(lower case letter) or capital letter(upper case letter)

http://mvc.syncfusion.com/Services/Northwnd.svc/Suppliers?$select=SupplierID,ContactName&$filter=startswith(ContactName,'a')&$orderby=ContactName

In this url,

i have set filter as startswith(ContactName,'a')

which returns all the record which has upper case "A" and lower case "a"

But my requirement is, i want to get the record which has lower case 'a' only.

Is there any methods, or workaround to achieve this requirement.
Viewing all 877 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>