I have been trying to get a WCF Data Service server working for a few days now.
I finally backed off today and just tried to do exactly what the quick-start shows.. nothing else.. and in completely fresh project. Surely that would work.
But it didn't.. it failed the same way as my other tests.
I am just following along with this example. Using Visual Studio 2013 for Web express and the hosting is using IIS Express.
I have installed the WCF Tools version 5.6 such that Visual Studio has the WFC Data Service 5.6 template.
The gist of it is
create an ASP.Net Application Select MVC type, adding no folders for anything other than MVC and no unit tests, individual account authenticaion.
Add an ADO.Net Entity Data Model for the NorthWind database, called NorthwindEntities in web.config, importing all tables.
Add WCF Data Service 5.6 item, call it NorthWind.svc.
Change the NorthWind.svc.cs backing code to the following.
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 StackOverflowApp
{
public class NorthWindService : DataService<NorthwindEntities>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
config.UseVerboseErrors = true;
config.SetEntitySetAccessRule("Orders", EntitySetRights.AllRead | EntitySetRights.WriteMerge | EntitySetRights.WriteReplace );
config.SetEntitySetAccessRule("Order_Details", EntitySetRights.AllRead| EntitySetRights.AllWrite);
config.SetEntitySetAccessRule("Customers", EntitySetRights.AllRead);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
}
}
}
Now it is ready to build and run.. it should work.. yes?
I run it, and navigate to the service.. I am greeted with the following complaint.
<div id="content">
<p class="heading1">Request Error</p>
<p>The server encountered an error processing the request. See server logs for more details.</p>
</div>
How am I to debug that?
This is not the typical response when navigating to a page which generates an error in the application or to a page that does not exist. I get the feeling that the data.service system is generating this response.. that it actually started to process the request.. but failed for some obtuse reason.
I followed the instructions to a tee I thought, but apparently I missed something.
I've been through the process step by step several times now to try to find what I might have skipped to no avail.
Update:
Aha.. under another similar question, they recommended adding verbose messages using config.UserVerboseErrors = true. This didn't make any difference to me.. but the alternative method of using attributes sure did! Decorating the class with [ServiceBehavior(IncludeExceptionDetailInFaults = true)], now yields this more descriptive error.
The server encountered an error processing the request. The exception
message is 'Expression of type
'System.Data.Entity.Core.Objects.ObjectContext' cannot be used for
return type 'System.Data.Objects.ObjectContext''. See server logs for
more details. The exception stack trace is: blahblah
It sounds like you're using Entity Framework 6 which hasn't been out for all that long. You need to perform some additional steps to get WCF Data Services 5.6 and EF 6 to behave together nicely.
You need to add the additional WCF Data Services Entity Framework Provider Nuget package and then instead of inheriting your service from DataService<T>, you inherit from EntityFrameworkDataService<T>.
Full steps are on the data services blog here: http://blogs.msdn.com/b/astoriateam/archive/2013/10/02/using-wcf-data-services-5-6-0-with-entity-framework-6.aspx
Yes Thanks. Your answer is correct Chris. I was able to find the problem at last after I enabled the decorated version of verbose messaging, and got that extra detail regarding linking to objects being the problem.
So I found the problem and fixed it, or at least I can make it work using the quick-start guide now. Working with my own database is a little squirley still.. returns an empty set when I know I have items in the database.. but at least I now have working exhibit-A to compare against to find the issue. (Aha! found the problem there also, I had forgotten to add the entitie connection to web.config for my non-northwind database -- so its all workin' now!)
Anyway, the first decent clue was following the error message (that wasn't shown until after I enabled verbose messaging with the class attribute), found this note about the problem actually being with WCF's interface with EntityFramework 6. (had I not upgraded to version 6 I likely would not have had the problem)
https://entityframework.codeplex.com/workitem/896
Then, I searched for issues with WCF 5.6 and EntityFramework6. and whalla.. there is an alpha version of WCF which addresses the issue.
Note that if you follow the instructions here verbatim, there is still a problem (or was for me). Get alpha2 instead of alpha1 as it fixes a linking error. i.e.
Install-Package Microsoft.OData.EntityFrameworkProvider -Version 1.0.0-alpha2 -Pre
http://blogs.msdn.com/b/astoriateam/archive/2013/10/02/using-wcf-data-services-5-6-0-with-entity-framework-6.aspx
To install alpha2 today 6/7/2014 "Install-Package Microsoft.OData.EntityFrameworkProvider -Pre". Also the Microsoft.Data.Services version must be 5.6.0.0.
Related
I have attached the ExampleAssistantV1.cs script to a character in Unity and obtained my services credentials (API key and service URL) from the Assistant I have created.
From my dialog page, I can only see/get my Assistant Name and Assistant ID, but nothing like Workspace ID. I have searched around my bluemix pages and account details for the Assistant service, but cannot seem to find anything about Workspace. Where is this?
The version date when I used Tone Analyzer in Unity worked with the current date (yesterday) so I wonder if the same applies to Assistant? In the code comments, there is no explanation of what this date actually is...
When I run Unity, I get the following error. I could only find two threads on this; both are closed now on GitHub. Could someone please help me understand what I am missing?
[RESTConnector.ProcessRequestQueue()][ERROR] URL: https://gateway-lon.watsonplatform.net/assistant/api/v1/workspaces//message?version=2018-12-27, ErrorCode: 400, Error: 400 Bad Request, Response: {"error":"URL workspaceid parameter 'message' is not a valid GUID.","code":400}
After running in Unity, when I look at my service page, I see a new instance created with a unity-sdk-example-workspace-deleteUpdated message. How did I cause this? Have I done something wrong that this appears new?
If you click the three dots in the image above next to conversation assistant you can click View API Details. You should be able to see your Workspace ID there.
You supply the version date to select the version of the service you want to use in your application. You will be using the last service release on or before the version date supplied. If you use today's date you will be using the latest release of the service.
The issue with the the call is there is no workspaceId supplied. Ideally there should be a null check for this param. I've created an issue for this: https://github.com/watson-developer-cloud/unity-sdk/issues/490
As for the unity-sdk-example-workspace-deleteUpdated it look like you ran the AssistantV1 example. The example runs through each operation in the service and attempts to invoke it. In this case it looks like it failed to delete the workspace or the example was stopped before it was deleted. It is safe to delete this workspace/skill.
I try to get certificates hash from web-site bindings(IIS) using official Microsoft Library Microsoft Web Administration.I stack with one interesting problem.When I try to complete this trivial operation:
foreach (Binding binding in site.Bindings)
{
binding.CertificateHash;
binding.CertificateStoreName;
}
I get this exception: Method or operation is not implemented
The most strange and curious thing that when I create another test project and did same things everything work's fine.This situation blows my mind!I compared the versions of the library.They are equal.(Version 7.0.0)
Of course, I try many other solutions and answers:
1)Got an error while using WorkerProcess.GetRequests method from Microsoft.Web.Administration.dll IIS 8.5
2)State property of Site throwing "NotImplementedException" in IIS Express
3)The method or operation is not implemented. while stopping IIS website in C#
but nothing had happened.So that way I here.
Thanks for your attention!
I'm developing a cloud service using Azure Mobile Services, and in order to test it quickly and debug it, I want to deploy it in my local computer. I select the project, hit F5, got it running in IIS express in my local PC. I execute the cliente against my local URI address of the IIS service and when I try to insert a value, this exception appears if I try to retrieve or insert a new object:
An exception of type 'System.ArgumentException' occurred in EntityFramework.SqlServer.dll but was not handled in user code
Additional information: The database name 'TR_MyTrip_Server_ExtraData_Service]_Persons_InsertUpdateDelete' is invalid. Database names must be of the form [<schema_name>.]<object_name>.
I debugged the Initialization of the controller and found out that mobile services deploys a LocalDb instance with this connection info on the DataBase property of the ServiceContext object:
Data Source=(localdb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-MyTrip.Server.ExtraData.Service-20140731060708.mdf;Initial Catalog=aspnet-TestProject.Server.ExtraData.Service-20140731060708;Integrated Security=True;MultipleActiveResultSets=True
It is not able to find this DataBase if I try to connect with this connection string to the LocalDB via the SQL Management Studio
I'm able to access to the LocalDb instance with the SQL management studio running this command on CMD and retrieving the Connection for the LocalDB
SqlLocalDB.exe info v11.0
Eitherway, on the SQL Management Studio I'm not able to see any DataBase relating my controller of the Mobile Services. I searched on google and the only related link I found was this but is not working... Does anybody know what's happening?
Thank you so much
This is a problem when you have a project name with periods in it. Like TestProject.Server.ExtraData.Service.
To fix this, go into the web.config and edit the appsetting named "MS_MobileServiceName" taking out the periods. This is the value used as the SQL schema name for your mobile service tables in the database. It can't have periods or other special characters in it.
I generally try to make this the same as the name of the mobile service I'll deploy to, but it's not technically required.
For whatever reason, I couldn't get this working using the accepted answer. I assume this has something to do with the disclaimer in web.config which states:
After publishing to Mobile Services, these settings will be overridden by the values specified in the portal.
However, I did find another work around in the MobileServiceContext file where I replaced this line:
string schema = ServiceSettingsDictionary.GetSchemaName();
if (!string.IsNullOrEmpty(schema))
{
modelBuilder.HasDefaultSchema(schema);
}
with a simple string value modelBuilder.HasDefaultSchema('mySchema');
I imagine there's a way to influence the output of GetSchemaName() but, considering how much effort it took to resolve this problem, I am perfectly content with this solution for now.
If you've changed the MS_MobileServiceName in config to remove the periods, and you're still getting the error, you'll need to re-run the scaffolding for the Initial migration in the package manager console:
Add-Migration Initial -Force
From what I could see, the scaffolding generates an embedded .resx that still has your old schema name (DefaultSchema), and a snapshot (Target) that is referenced in the designer code. Just changing the DefaultSchema didn't solve the issue for me, but re-running the scaffolding did.
I also added Table annotations to my models, but I don't think that was the issue. And probably isn't ideal if your service is already live.
In order to follow this tutorial (http://msdn.microsoft.com/en-us/library/gg695790.aspx) I need to generate some early bound types. I cannot get the tool to work.
I've downloaded the latest CRM 2013 SDK
I've got a CRM2013 online trial account.
the URL I use is the one I got from the CRM2013->Settings->Customizations->Developer recources->organisation service.
the credential i use the default user (admin) from the CRM2013 online trial.
lets say it's John360
So the URL for CRM is like https://john360.crm4.dynamics.com/
user: john#john360.onmicrosoft.com
pwd: pass
organisationService: https://john360.api.crm4.dynamics.com/XRMServices/2011/Organization.svc
when I try the command like:
CrmSvcUtil.exe /codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration" /out:Xrm\Xrm.cs /url:https://john360.api.crm4.dynamics.com/XRMServices/2011/Organization.svc /username:john /domain:john360.onmicrosoft.com /password:pass /namespace:Xrm /serviceContextName:XrmServiceContext
i get
value cannot be null. Parameter name: identityProvider
I also tried some Obvious other with or without quotes, with the 'domain' appended to the username, nothing works. I added the program to the firewall.
I also tried this tool https://xrmearlyboundgenerator.codeplex.com/
It also has problems connecting to the server. I tried with the latest version and with these connection settings: use CRM online and selected the crm4.dynamics.com
Login: john#john360.onmicrosoft.com, password: pass.
If I select 'Get Orgs.' I get the error
'an unsecured or incorrectly secured fault was received from the other party'
I've now also tried this route: http://code.msdn.microsoft.com/SdkSoapjs-Entity-Class-14ca830f
The program gives the same error as the other generator.
edit:
I actually got a bit further... with this command:
CrmSvcUtil.exe /codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration" /out:Xrm.cs /url:"https://john360.api.crm4.dynamics.com/XRMServices/2011/Organization.svc" /username:"john#john360.onmicrosoft.com" /password:"pass" /namespace:Xrm /serviceContextName:XrmServiceContext /serviceContextPrefix:
it resultet in error:
Metadata contains a reference that cannot be resolved.
I didn't do any customization changes to my trail, so I'm not sure what this is about. Any suggestions are welcome.
Using the XrmToolBox as a method of connecting to CRM, I've created a GUI front end wrapper over the CrmSvcUtil.exe. It adds a lot of additional features, but most importantly for you, it creates the commandline required to generate the entities for you. Download it from the plugin store within the Xrm Tool Box, and never have this problem again!
I have a simple web service that looks something like this:
[WebMethod]
public OrderForecastItem GetOrderForecast(int shipTo, string catalogName, bool showPricing)
{
return OrderForecastManager.GetOrderForecast(shipTo, catalogName, showPricing);
}
I'm calling it from another place in a fairly simple way:
using (OrderForecastWS.OrderForecastWS service = new OurSite.Web.Reporting.OrderForecastWS.OrderForecastWS())
{
OrderForecastItem orderForecastItems = service.GetOrderForecast(2585432, "DENTAL", false);
}
After some gymnastics to get the systems to understand that I'm talking about the same type of objects on the client and server sides (I had to open the Reference.cs file inside my Web References, delete the generated OrderForecastItem and add a link to our real OrderForecastItem), the system runs and attempts to get the item.
Unfortunately, it now bombs during the service call, claiming:
Exception There is an error in XML document (1, 1113).(InvalidOperationException)
I can go to the web service in a browser, put in the same values, and I get a seemingly valid XML response. (It looks okay to me, and I ran it through the XML parser at W3Schools, and it cleared it.)
I think the numbers in the error are supposed to be the line and character number...but the browser seems to reformat the xml document, so I can't easily see what the original (1, 1113) location is.
I don't see an easy way to intercept the response and examine it, since it seems to be blowing up as soon as it gets it.
How can I debug this?
If you control the service, you can step into it. If it is a part of your solution and hosted in VS WebDev on your local box, just F11 from Visual Studio, if service is hosted remotely (eg by IIS on other computer) run remote debugging tool on service host msdn, and then you will be able to step in to the service remotely.
By the way, you can tell Visual Studio to re-use objects from referenced libraries for types from the service: just pick configure Service Reference from service context menu and tell which libraries to re-use.
On second thought this error may happen if returned XML could not be deserialized into your business object. May happen when class is changed on either side, or you are trying to use different version of business library than service is using.
If you use Firefox, I'd recommend Firebug. You'll be able to easily view the response from the website in its original format, which might get you closer to the line and position you're looking for.