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

WCF OData $top with "nextLink"

$
0
0

I'm building a WCF Data Service and I found a strange behaviour when I make a GET with the $top parameter set.

I was expecting, as I found on many sources on the Internet, that the response would give a "nextLink" in case that there were more items than the specified in the $top parameter... that doesn't occur! Why!? Am I doing something wrong? How can I control the page size on the client side and use the "nextLink" to navigate to the next page?

If I omit the $top parameter, the server controls the page size and retrieves the "nextLink" parameter... but if I use the $top parameter, server never returns "nextLink"! Is this a bug?

Best regards,

Fernando Rocha




Bing News Search API Results

$
0
0

I am working on a custom news widget for a client. He wants to include news that only has a particular company name as well as one or more industry terms. For companies [Company A, Company B, Company C], he wants to display aggregated results (newest first) using the following search terms.

"Company A" AND ("electric vehicle" OR "PHEV" OR "energy storage" OR "lithium-ion" OR "capacitor" OR "graphite" OR "separators" OR "community energy storage" OR "electricity storage" OR "advanced batteries")"Company B" AND ("electric vehicle" OR "PHEV" OR "energy storage" OR "lithium-ion" OR "capacitor" OR "graphite" OR "separators" OR "community energy storage" OR "electricity storage" OR "advanced batteries")"Company C" AND ("electric vehicle" OR "PHEV" OR "energy storage" OR "lithium-ion" OR "capacitor" OR "graphite" OR "separators" OR "community energy storage" OR "electricity storage" OR "advanced batteries")
  1. I can't find the exact limitations of the Bing News Search API - what are the maximum number of terms?
  2. The results that are returned don't necessarily contain the company name. How can this be explained?

.Net Client fails to Update Odata Controller

$
0
0

Created an Odata MVC WEb API. Running it Locally IIS Express 7.5 to debug it.

Created a .Net WPF client app.

Here is code to load from client:

private Container _proxy;

private DataServiceCollection<EF_WO> _wos = new DataServiceCollection<EF_WO>();

I am able to Get data and can step through the Odata call.

I am able to Insert and Delete Data and can step through the Odata call

I Cannot Update, when I change values in a WPF datagrid and call Savechanges . It will not call the Odata UpdateEntityKey override

Even if I manually update the dataservice collection from the client it will not update. It gives a generic DataserviceRequestError.

I looked at the Entity and its state is modified...

The IIS Express Log says a 404 Error?

Please Help...

Server :

Using Entity Framework 5

Using Oracle 11.2.30.2 Client

Project is ASP.Net WEB API MVC 4

Odata

Client:

WPF application using a datagrid

Cannot materialize complex or primitive type - WCF Data services

$
0
0

i use WCF Data services along with Entity framework to talk to the SQL Server database. The data is not directly accessed through the ORM but instead ,the stored procedures are used to fetch and insert data.

I do a function import on the Entity framework and invoke them through the Web get calls from the WCF Dataservice.Most of the times these procedures return collection of Complex types(generated from EF).

This is how i execute from my asp.net mvc app

Context.Execute<T>("<service uri>","GET",true);

Here is the error i get everytime

Cannot materialize a collection of a primitives or complex without the type being a collection.

Does the latest WCF Data services client does not support collection of complex types.

I am using the latest version of WCF Data services client which is 5.5

I am stuck on this for few days now.What is the actual reason for this error

How do I tell my service (all calls REST/JSON) to handle OPTIONS requests?

$
0
0

Hi;

I have written a WCF service to return JSON on REST requests. Works great with a browser hitting it. But when my JavaScript hits it, the first request is an OPTIONS request for the url with "Access-Control-Request-Method: GET".

What do I need to do so the service will respond appropriately when asked if a GET can be requested on a url?

thanks - dave


Who will win The Windward International Collegiate Programming Championships?

WCFDataService Firefox/Chrome error

$
0
0

When calling our WCFDataService from firefox or chrome we are getting a missing file error that does not happen in IE.

The error is as follows and the call to the error is at the bottom.

(I tried to format it but MSDN is acting weird today.)

[FileNotFoundException: Could not load file or assembly 'App_Web_k0ezqwsd, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)+0
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +567
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +192
   System.Reflection.Assembly.Load(String assemblyString) +35
   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +255
   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1413
   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +50
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1172

  

[ServiceActivationException: The service '/ItDataServices.svc' cannot be activated due to an exception during compilation.  The exception message is: Could not load file or assembly 'App_Web_k0ezqwsd, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified..]
   System.Runtime.AsyncResult.End(IAsyncResult result) +901424
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +178702
   System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +107

The code to call the method is as follows           

_entities.BeginExecute< LoginResult>(new Uri(String.Format("GetUserLogin?username='{0}'&password='{1}'&release='{2}'&pcName='{3}'&macAddress='{4}'&ipAddress='{5}'&isNoc={6} ", CurrentUser.UserName, CurrentUser.Password, release, pcName, macAddress, ipAddress, 0), UriKind.Relative), result => GetUserLoginCallback(result), _entities, ODataConstants.MethodGet, false);

REST - doing a GET with a really long url

$
0
0

Hi all;

I'm not sure if this is the best forum for this question. If not, please point me to the correct one.

We are trying to implement a REST server (using WCF). One problem we are hitting is we can have a GET with a really long url. The url includes a parameter of ?select={really long query}.

This is a get as we're asking for data back. We are not creating or updating data. However, the url could easily be over 2K and it would not surprise me if at times it was over 8K.

So what's the solution? The safest seems to be do a post where the select is in the body. But that's a violation of REST. Any suggestions?

thanks - dave


Who will win The Windward International Collegiate Programming Championships?

WCF Data Services and EF5 auto-compiled query support with parameterized query

$
0
0

Hi,

EF5 introduced auto-compiled query, this feature dramatically improve performance of Entity Framework.

When we use WCF Data Service over an EF5 context, we automatically benefit from this feature. However it is possible to improve the way WCF Data Service build it expression tree to better use the auto-compiled query feature.

Imagine we have the following query :

http://localhost/WebApplication6/DataService.svc/Products(1)

WCF Data Service will translate it to the following expression tree :

.Call System.Linq.Queryable.Where(
    .Constant<System.Linq.EnumerableQuery`1[WebApplication6.Product]>(WebApplication6.Product[]),
    '(.Lambda #Lambda1<System.Func`2[WebApplication6.Product,System.Boolean]>))

.Lambda #Lambda1<System.Func`2[WebApplication6.Product,System.Boolean]>(WebApplication6.Product $element) {
    $element.ProductId == 1
}

This expression tree will be compiled by EF5 (great!).
However, if we query for another productId, WCF Data Service will generate a new expression tree (the only difference will be the constant value). When EF5 will verify if it has already compiled this expression tree, it won't find it and think that this expression is a new one, so it will compiled this new expression tree.

  => Each time we query for a new ProductId, EF5 will compiled a new expression tree (and cache it) :(

EF5 can compiled these expression trees once if they used a ParameterExpressioninstead of ConstantExpression.

Does the WCF Data Services team has planned to used ParameterExpression instead ofConstantExpression ? If no, pleased could you planned it ?I think it will boost a lot of WCF Data Services Scenario :-)

By the way, I think it should be possible to use an ExpressionVisitor to rewrite the query and use parameterExpression instead of ConstantExpression. I didn't try it yet.

Thanks,

Cyril DURAND 




The server encountered an error processing the request. See server logs for more details.

$
0
0

I'm getting this all of the time when I run my service.

 

I'm running in Cassini (Vs.net 2008 developer server) and I don't have a clue where the log files are or what's causing this.  I put a break point in my code and no joy.  It was working and then it died when I made a change to my Entity set, but going backwards doesn't fix it so I'm at a loss as to what's going on.

Failed insert requests with Microsoft.Data.Services.Client and secure OData streaming service

$
0
0

I have a streaming WCF OData service hosted in IIS that is accessing a mysql database to store images as blobs. To implement it I followed the instructions in Data Services Streaming Provider Series: Implementing a Streaming Provider (Part 1). I also built a WPF client using the Microsoft.Data.Services.Client library that creates, reads, updates, and deletes images through the service according to Data Services Streaming Provider Series-Part 2: Accessing a Media Resource Stream from the Client. Everything works fine until I secure the service using Basic Authentication with SSL and HTTPS.

When authorization is required, read, update, and delete still work, but the creation of new records fails.

For successful creation request over HTTP I see the following request pattern in my IIS logs:

2013-06-25 11:39:13 ::1 POST /PictureService/PictureData.svc/PhotoInfo - 80 - ::1 Microsoft+ADO.NET+Data+Services 201 0 0 59476
2013-06-25 11:39:13 ::1 MERGE /PictureService/PictureData.svc/PhotoInfo(75) - 80 - ::1 Microsoft+ADO.NET+Data+Services 204 0 0 11

For successful update requests over HTTPS this is what is logged:

2013-06-25 12:17:34 ::1 PUT /AddressBookService/AddressBookService.svc/PictureInfos(AddressBookEntryId=1,AddressBookId=1,PictureInfoId=6)/$value - 443 - ::1 Microsoft+ADO.NET+Data+Services 401 1 0 5
2013-06-25 12:17:38 ::1 PUT /AddressBookService/AddressBookService.svc/PictureInfos(AddressBookEntryId=1,AddressBookId=1,PictureInfoId=6)/$value - 443 Alice ::1 Microsoft+ADO.NET+Data+Services 204 0 0 4045
2013-06-25 12:17:38 ::1 MERGE /AddressBookService/AddressBookService.svc/PictureInfos(AddressBookEntryId=1,AddressBookId=1,PictureInfoId=6) - 443 - ::1 Microsoft+ADO.NET+Data+Services 401 1 0 3
2013-06-25 12:17:39 ::1 MERGE /AddressBookService/AddressBookService.svc/PictureInfos(AddressBookEntryId=1,AddressBookId=1,PictureInfoId=6) - 443 Alice ::1 Microsoft+ADO.NET+Data+Services 204 0 0 926

Each failed request without authorization header is followed by a successful one in which the authorization header for user "Alice" is included. There is one PUT and one MERGE request for each update operation as described in the above links.

Upon a creation request, though, only one POST is issued which fails due to the absence of an authorization header.

2013-06-25 12:19:35 ::1 POST /AddressBookService/AddressBookService.svc/PictureInfos - 443 - ::1 Microsoft+ADO.NET+Data+Services 401 1 0 4

It appears as if the Microsoft.Data.Services.Client library forgets to answer the SSL challenge with a follow-up request containing the required authorization header.

Stepping through the service code, I found that in the Dispose() method of my IDataServiceStreamProvider implementation, the _picture entity (created inside GetWriteStream()) is correctly initialized using HTTP so that I can retrieve the matching PictureData record if it exists or create a new one if it does not. But when a create request is processed over HTTPS, _picture has all default nulls and 0s.


        public Stream GetWriteStream(object entity, string etag, bool? checkETagForEquality, DataServiceOperationContext operationContext)
        {       
            if (checkETagForEquality != null)
            {
                // This stream provider implementation does not support ETags associated with BLOBs.
                // This means that we do not track concurrency for a media resource
                // and last-in wins on updates.
                throw new DataServiceException(400, "This service does not support ETags associated with BLOBs");
            }

            PictureInfo image = entity as PictureInfo;
            if (image == null)
            {
                throw new DataServiceException(500, "Internal Server Error: the Media Link Entry could not be determined.");
            }
            // Set the file name from the Slug header; if we don't have a
            // Slug header, just set a temporary name which is overwritten
            // by the subsequent MERGE request from the client.
            image.FileName = operationContext.RequestHeaders["Slug"] ?? "newFile";

            // Set the content type, which cannot be null.
            image.ContentType = operationContext.RequestHeaders["Content-Type"];

            MemoryStream photoStream = new MemoryStream();
            // Cache image and stream in order to create or update the PhotoData record
            // while maintaining transactional integrity in the disposer.
            // Note that it is not enough to remmeber only the PhotoId,
            // since the PictureInfo entity needs to be deleted from the database if something goes wrong.
            _picture = image;
            _pictureStream = photoStream;
            return photoStream;
        }

public void Dispose() { if (_pictureStream != null) { try { using (AddressBookEntities another = new AddressBookEntities()) { // Copy the image data into the corresponding PhotoData record PictureData pictureData = (from pd in another.PictureDatas where pd.PictureInfoId == _picture.PictureInfoId select pd).SingleOrDefault(); if (pictureData == null)                        {
                            // Create a new PictureData record and connect it to the corresponding PictureInfo record
                            pictureData = new PictureData
{ PictureInfoId = _picture.PictureInfoId, AddressBookEntryId = _picture.AddressBookEntryId, AddressBookId = _picture.AddressBookId }; another.PictureDatas.AddObject(pictureData); } pictureData.PictureStream = _pictureStream.GetBuffer(); another.SaveChanges(); _pictureStream = null; } } catch { // A problem occurred when saving the entity to the database, // hence delete the entity. _context.DeleteObject(_picture); throw new DataServiceException("An error occurred. The photo could not be saved."); } }

I don't even know where to start to make this work. Is the Client library at fault or did I misunderstand something fundamental?

Any pointers are greatly appreciated.


json v5

$
0
0

Hi All

I have upgraded to WCF DataServices 5.0.2 and want to return JSON (for size of data being returned) the service will only be used by a windows forms application. So no AJAX.

Now I have followed http://blogs.msdn.com/b/astoriateam/archive/2012/04/11/what-happened-to-application-json-in-wcf-ds-5-0.aspx, if I add the accept header below it throws a NOTSupportedException  "The content type 'application/json' is not currently supported."

  Request.Accept = "application/json;odata=verbose";

Service code to show V3 support


    public static void InitializeService(DataServiceConfiguration config)
    {
      config.SetEntitySetAccessRule("*", EntitySetRights.All);
      config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);

      config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
    }

Client code

   var DataSource = ConfigurationManager.AppSettings["DataSource"].ToString();
        var ctx = new MyEntities(new Uri(Url));
        ctx.IgnoreResourceNotFoundException = true;
        ctx.Credentials = System.Net.CredentialCache.DefaultCredentials;

ctx.SendingRequest += delegate(object sender, SendingRequestEventArgs args)
          {
            var Request = ((HttpWebRequest)args.Request);
            Request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

            Request.Accept = "application/json;odata=verbose";

            Request.Headers.Add("MaxDataServiceVersion", "3.0");

            Request.Proxy = null;
          };

AddOrUpdate Object without fetching entire table

$
0
0

The project is Silverlight 5. I have an image table (inherited from previous consultant group) and it contains two images for each customer. I cannot pull this whole table down so I retrieved a single record from the table and set my objects id to that, it is a primary key. Since I am not pulling down the entire table I guess it is just inserting new rows. I don't want to delete first but if I have to I guess I will.

I tried fetching just the records pertaining to the table and customer back but I receive and 'does not support object' error.

Any help in forcing it to update an existing record?

            LogoFile lf = new LogoFile()
            {
                CustImage = CustomerLogo,
                Thumbnail = Thumbnail,
                CustomerId = SelectedCustomer.CustomerId,
                Customer = c.FirstOrDefault().Entity
            };
            if (lfID > -1)
                lf.LogoId = lfID;
            _entities.AddToLogoFiles(lf);
            _entities.UpdateObject(lf);
            _entities.BeginSaveChanges(SaveChangesOptions.ReplaceOnUpdate, result =>
            {
                View.Dispatcher.BeginInvoke(() =>
                {
                    var res = _entities.EndSaveChanges(result).ToList();
                    foreach (ChangeOperationResponse change in res)
                    {
                        EntityDescriptor descriptor = change.Descriptor as EntityDescriptor;

                        if (descriptor != null)
                        {
                            LogoFile addFile= descriptor.Entity as LogoFile;
                            if (addFile != null)
                            {
                                Console.WriteLine("New File added with ID {0}.", addFile.LogoId);
                            }
                        }

                    }
                    IsBusy = false;
                });
            }, _entities);

OData v3 service from VS 2010 not generating proper Schema element (JayData)

$
0
0

I have a WCF Data Service which is supporting V3 of OData. I can prove this by using the any and all methods when querying but I'm trying to consume this service using JayData and JayData only generates V2 client code. It does so by choosing version based on the namespace of the Schema element that's part of the metadata of the WCF service.

I am using Visual Studio 2010, WCF Data Services 5.5, and Entity Framework.

Namespace versions from JayData and OData spec are as follows:

public static Dictionary<string, string> NamespaceVersions  = new Dictionary<string,string>
  {
    {"http://schemas.microsoft.com/ado/2007/05/edm", "V11" },
    {"http://schemas.microsoft.com/ado/2006/04/edm", "V1" },
    {"http://schemas.microsoft.com/ado/2008/09/edm", "V2" },
    {"http://schemas.microsoft.com/ado/2009/08/edm", "V21" },
    {"http://schemas.microsoft.com/ado/2009/11/edm", "V3" }
  };

Visual Studio generates the following metadata schema:

<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0"><edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="1.0" m:MaxDataServiceVersion="3.0"><Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm"

How can I correct this namespace so clients can properly consume the service that rely on this namespace?

odata for multiple database.

$
0
0

Hi all,

  I have 5 types of real estate data and its all resides in different database.Currently I need to create a service which can handle all the types of data and based on customer type I need to give different data.These database don't have any kind of relations technically

For ex: customer A may request document 1 type data(db1),document 2 type data(db2) and customer B may request

document 3 type data(db4),document 2(db2) like that.

Based on my research articles saying that you cannot add multiple entity model in a oddataservice. What will be the best

approach I can use in this scenario?Is there anything I can do without creating 5 odata service for handling 5 different document types(5 database)?

Regards,

Jeena

Workaround for returning Collection of Complex Types from WCF Data Service

$
0
0

As there is a shortcoming with the current WCF Data Service .Net client library with returning complex data types i worked upon the following workaround

I have a Entity Model MyEntities and in it I have imported the stored procedure as Function GetProduct and mapped it to a complex type Product

I have created a class MyCustomEntities and another class CustomProduct which is similar to the complex type Product. I have now created a data service on top of MyCustomEntities. Following is my code

    public class CustomDataService : DataService<MyCustomEntities>
    {
        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
        {
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
            config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
            config.SetServiceOperationAccessRule("*", ServiceOperationRights.AllRead);
            config.UseVerboseErrors = true;
        }

        [WebGet]
        public List<CustomProduct> GetProductsByCompany(string coId)
        {
            return CurrentDataSource.GetProducts(Convert.ToInt16(coId)).ToList();
        }
    }

    public class MyCustomEntities
    {
        public IQueryable<CustomProduct> listProduct
        {
            get
            {
                return new List<CustomProduct>().AsQueryable();
            }
        }


        public IQueryable<CustomProduct> GetProducts(int coId)
        {
            MyEntities context = new MyEntities();
            var customList = from results in context.GetProduct(coId)
                                where results.PartNumber != null
                                select new CustomProduct { PartNumber = results.PartNumber, Description = results.Description, Price = results.Price };

            return customList.AsQueryable<CustomProduct>();
        }
    }


    [DataServiceKeyAttribute("Id")]
    public class CustomProduct
    {
        public int Id { get; set; }
        public string PartNumber { get; set; }
        public string Description { get; set; }
        public decimal Price { get; set; }
    }
}

With this approach I am able to return the result of my stored procedure as a List of my custom class. This is not a straight forward way but it is a workaround with wcf data service with reflection provider approach. Can someone please validate this approach and let me know if there are any loopholes in this approach. Your suggestions are important as I want to use this approach in one of my live projects

Thanks,

Vandana


OData Client Error "A missing or empty content type header was found when trying to read a message. The content type header is required."

$
0
0

I'm writing a WCF client application to read data from SAP Netweaver Gateway OData feed.  I'm using VS 2012 and C#.

I can't get past a DataServiceQueryException whose InnerException contains the message in the title, above.

I monitored everything in fiddler.  The right query goes out.  The right data comes back.  The header contains 'content-type: application/atom+xml; charset=utf-8'. 

I can hit the same OData source using LINQPad and everything works as expected.

Has anyone else ever encountered this message?  Any ideas of something I could try?


SJT00

How can I get the WCF DS Client to not fail reading the results of a service operation that returns the type generated by a stored procedure call?

$
0
0

The short of it:

Is there a way to materialize service operations that use Entity Framework, but do a stored procedure call instead of Linq to Entities?

The details:

I have an OData (WCF Data Service) that has several service operations in it. They all work fine.

Today I tried to add a new service operation and I cannot get it to work in LinqPad.

My new service operation is different from the others in that it calls a stored procedure (rather than using Linq To Entities).

It looks like this:

[WebGet]publicIQueryable<MySproc_Result>GetTheDataINeed(long id){returnCurrentDataSource.MySproc(id).AsQueryable();}

When I run this in LinqPad like this:

CreateQuery<MySproc_Result>"GetTheDataINeed").AddQueryOption("id","91675L")

I get the following error:

Cannot materialize a collection of a primitives or complex without the type 'LINQPad.User.MySproc_Result' being a collection.

Note: I ran one of my other service operations using this syntax and it worked fine

I decided to see if it would run in a browser (as a url). I plugged both this and a working service operation into Internet Explorer.

The difference was easy to see right away:

Bad

<?xml version="1.0" encoding="UTF-8"?><GetTheDataINeedxmlns:m="namespace removed for brevity"><elementm:type="MyModel.MySproc_Result"><SomeData>Data Goes Here</SomeData><OtherData>Other Data Goes Here</OtherData>
        ...

Good

<?xml version="1.0" encoding="utf-8"?><feedxml:base="http://localhost:26257/MyServiceHere.svc/"Otherxmlnsommited><id>http://localhost:26257/MyServiceHere.svc/ValidServiceOperation</id><titletype="text">ValidServiceOperation</title><updated>2013-07-02T23:24:11Z</updated><linkrel="self"title="ValidServiceOperation"href="ValidServiceOperation"/><entry><id>http://localhost:26257/MyServiceHere.svc/Orders(156L)</id><category ... ommited/><linklotsoflinksommited/><title/><updated>2013-07-02T23:24:11Z</updated><author><name/></author><contenttype="application/xml"><m:properties><d:SomeDatam:type="Edm.Int64">Some Data Here</d:SomeData><d:OtherDatam:type="Edm.DateTime">Other Data Here</d:OtherData>
                ...

The working one seems to have quite a bit of meta data that the non-working one is missing. I am guessing that is why the materializer failed. What I don't know is how to get my service operation that is calling a stored procedure to get that xml format.

Is there a way to materialize service operations that use Entity Framework, but do a stored procedure call?

NOTES:

  • I am running WCF Data Services 5.5.0 on both the server and the client and have install the 5.3.0 tooling.
  • I have tried running in a console app (to be sure that it is not just linqpad)
  • I have tried the following syntax as well, and it does not work:

    Execute<MySproc_Result>(newUri("GetTheDataINeed?id=91675L",UriKind.Relative),"GET",false)

WCF does not generate Begin/End methods, only Async version

$
0
0

As I tried to describe in the title, I don't get the Begin and End methods when I add my service reference. I do get the GetStudentsAsync() method, but I want to be able to await.

The interface is simple:

[ServiceContract]publicinterfaceISchoolLightService{[OperationContract]ObservableCollection<SLUser>GetStudents();[OperationContract]ObservableCollection<SLUser>GetTeachers();}

and GetStudents looks like:

publicObservableCollection<SLUser>GetStudents(){var users =(from u in ent.Userswhere u.UserType=="Student"selectnewSLUser{UserID= u.UserID,...});returnnewObservableCollection<SLUser>(users);}

The client is a Silverlight 5 project, and the server is a .NET 4.5 class library. Shouldn't I get these methods?

Perhaps worth mentioning is that I have to untick the "Always generate message contracts" and "Reuse types in referenced assemblies" of it won't compile.

Looking in the Object Browser, it seems the methods are there, but private! Why? How do I change this behavior?



microsoft office 360

$
0
0
I just had to do a flie recover and now I need to reinstall office programs and I do not have my key nor do I have my disk I let my daughter use It  please help so I can get up and running again

Thread.CurrentPrincipal replaced when using SaveChangesOptions.Batch vs None?

$
0
0

Hello all,

I have a very simple self hosted Service which sets PrincipalPermissionMode = Custom and then I have implementd a ServiceAuthorizationManager which overrides CheckAccessCore(), sets the AuthorizationContext.Properties["Principal"] = a custom Principal and returns true.

           host = new WebServiceHost(typeof(AppService), new Uri[] { hostUri });
            host.Authorization.ServiceAuthorizationManager = new ClaimsTokenAuthorizationManager();
            host.Authorization.PrincipalPermissionMode = PrincipalPermissionMode.Custom;

            host.Opened += HostOpened;
            host.Closing += HostClosing;
            host.Faulted += HostFaulted;
            host.Open();
       protected override bool CheckAccessCore(OperationContext operationContext)
        {
            var properties = operationContext.ServiceSecurityContext.AuthorizationContext.Properties;
            var principal = new ClaimsTokenPrincipal(Id);
            properties["Principal"] = principal;
            return true;
        }

The Thread.CurrentPrincipal is accessed from the Update Interceptors...

On the client side a test app is created using Add Service Reference... When calling DataServiceContext.SaveChanges(SaveChangesOptions.None) the service host Thread.CurrentPrincipal is set as expected with my custom principal, works great!

Now on the client side I just change the options to SaveChangesOptions.Batch and now my principal is replaced by a GenericPrincipal?

I have also tried implementing IAuthorizationPolicy and setting the EvaludationContext.Properties["Principal"] from the Evaluate Method and have gotten the exact same results. Works great with None option and then GenericPrincipal with Batch.

The GenericPrincipal is set to Authenticated false and no user name.

I have Binged until I can no longer Bing... I'm Bonked! Any help would be greatly appreciated!

Thanks,

John

 

 

Viewing all 877 articles
Browse latest View live


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