Use WCF DataService in application - wcf

I have an MVC 3 application and create my own WCF data service. I imported in application as service references and service.edmx was automatically created. But when I try to open it, I only see a generic page:
The entity data model designer is unable to display in the file you requested.
I push right click on the page and try “Add Code Generation Item...”, it gives me an error:
Command 'Project.AddNewItem' is not available.
Can I generate .tt files in some other way?

I found the anser: Is not posible.
And if someone whant to use WCF DataSource, an inportant thing: You can't use a lot of reserved word in linq : like JOIN, GROUP, etc...

Related

AX 2009 AIF Schema error: SalesOrder:AxdEnum_Timezone' is not declared, or is not a simple type

I've been changing the SalesOrderService document service. Initially I'd added the new datasource at the wrong level, deployed the service, and later corrected it. The new datasource I've added is Address and now it hangs off of CreditCardCust datasource.
I've updated the document service using the wizard (checked the boxes for regenerating the document and AxBC class) and deployed the service again.
When I try to test the service using the XML file adapter, I get the following error: Type 'http://schemas.microsoft.com/dynamics/2008/01/documents/SalesOrder:AxdEnum_Timezone' is not declared, or is not a simple type.
I can reproduce the error by navigating to EndPoints, selecting the sales order inbound endpoint, Action policies, Parameter schema, View schema. Clearly, the schema is messed up.
I tried to regenerate the schema using the GenerateXSDSchema_AxdSalesOrder to no avail.
Is there a way for me to clear the schema and regenerate again?
Thank you.
I took out the Address datasource on the query and updated the service. That got rid of the problem and restored the service to a good state.
Looking through the list of available services, I found DirAddress service. That indicates to me that I cannot add address directly in SalesOrder service, but have to make a separate call to add the address.

data contract break service

I have created a service that has several void/bool methods() and when I refresh the service reference on the client I can see those methods.
The issue is when I add a method with a custom type and supply it with all the correct tags datacontract/datamember, when I update the service reference again on the client nothing gets built not even the existing methods. No errors are spit out and I'm stuck with no clues on where to turn.
I also tried pulling in the service1 that is created as an example in to my client and it didn't get the composite type either.
The client is MVC4. The entire stack .net 4.
EDIT
After further review and testing, the problem is not with the service project or any of the data contracts. It is with the mvc project generating the reference.cS file. It is not generating the file or reporting an error on why it's not creating it. I proved this by opening a brand new empty mvc project and added the service reference and it generated everything perfectly.

Dynamically create json using WCF service to feed MTDialog application

I wish to create a MonoTouch MTDialog-based app that upon launching adds a single element to the MonoTouch Dialog and then render the screen. This single element will be a JsonElement similar to this -
var je = new JsonElement ("Dynamic Data", "http://tirania.org/tmp/demo.json");
as shown in the sample application. However, instead of referencing a pre-built json file on a server, I wish to have the url point at a WCF OData service which will dynamically build the json data.
I am not sure what is the easiest way to do this. I am a bit lost after reading over the documentation. Is there some library I can include in my server-side C# app which I can then use to build out the elements and return as a json string of information?
I already have a WCF application up and running and just need to add an entry point which will call the method to create some simple json data for MonoTouch dialog to consume.
Any examples or suggestions are greatly appreciated as I am trying to get a simple solution completed by this weekend.
You're looking for a C# JSON library? How about JSON.NET http://james.newtonking.com/pages/json-net.aspx
You might also look at ServiceStack.NET -- they have a MonoTouch client.

WCF Exception Handaling

I have five separate services where each one corresponds to a different database table such as Product, User, Orders etc.
I am trying to send my custom exceptions across WCF. I have browsed the internet and i have wrapped my custom exceptions inside a fault exception:
interface
[FaultContract(typeof(NoSuchInstanceException))]
cs
throw new FaultException<NoSuchInstanceException>(e, new FaultReason(e.Message), newFaultCode("UserFault"));
The problem is when i update the service the client proxy disappears. I browsed the internet and found the following solution which says to add a mapping to the service reference SVCMAP file. http://travisspencer.com/blog/2007/11/
<NamespaceMapping
TargetNamespace="http://schemas.datacontract.org/2004/07/MyCompany.MyProject.Exceptions" ClrNamespace="MyCompany.MyProject.Exceptions" />
</NamespaceMappings>
My problem is that every service needs the custom exceptions adding to the mapping but when i do this. An error is displayed saying the exception is already defined in one of the other services. Do i merge the services into one service? Any help is really appreciated. Thanks
I can think of two options:
Merge the services into one - having multiple services sharing the same data types gives this problem on the client.
Move the shared data types into a separate dll (class library project). Then reference that shared data type library from both your server and client. When you create the services reference, choose the option to reuse data types.

Automatic serialization

I want to download xsd specifications from a web service and automatic converting (serialize) these schemas to classes (visual studio - vb.net). If the organization that is responsible for the xsd schemas alter them in a way that only my class corresponding to the xsd have to be altered (not the rest of my code) I would like to automatic update my xsd corresponding class. Is this possible? If so, can somebody tell me how to do it?
Thanks!
I use vs2010. What I want to do is: call a web service where I can send in an input parameter to the service which specifies the xsd I want to retrieve (the service is GetShemaDefenition and returns an object with the schema specification in a string property of the object). I den have to read the xsd string from the string property and convert this to a class representation of this xsd specification. Is it possible to do this automatically? I have done this manually by using xsd.exe. If the owner organization of the xsd has altered the xsd specification, I have to test if there is a new specification, and if there is I have to build a new class representation of this xsd? Is it possible to do what I want? And how would I know if it has been a big change in the xsd which also affect other parts of my code, not just the class representation of the xsd?
Tanks a lot for your reply! So what you are saying, if I understand you correct, is that there is not a good solution for automating this functionality because if the xsd change I most likely (in some occasions’) have to change my code manually? So I have to choose, either in my application or in my intermediate service? But what is the purpose for providing the xsd in a web service? What can I use the web service for? I just wondering, maybe it is clear but I am new to web services and is eager to learn more.
Update:
Thanks! But can you explain a little bit more. What I have to do is: I use one web service where one of the properties is a string. The string is an XML inside a CDATA block. The organization which provides the web service will not pares the xml inside the CDATA block but instead forward this to another organization that will use the xml data. The organization which uses the xml data specifies the xsd schem that I have to follow to generate my xml correct. This is the xsd schema I can get from another web service. I don’t really understand what I can do with this xsd file from the web service. What can I do with it and why do I want to download it from the web service, when I can’t use it automatically? Because I have to manually do the changes when the xsd changes I can easily download the xsd schema from the organization’s home page and make the new class with xsd.exe. I understand there is something I don’t understand :o), can you pleas clarify?
What visual studio version you are using?, Normally you can click on the project's references and Add Web service. In this case Visual studio creates automatically the objects required to consume the service. you can update it any time by a right click on the reference.
However if it is very likely to change often, One solution is to implement an adapter class. use create an interface that provides the same functionality and call the actual web service. In your application you use only the proxy class and not the Web Service. Later when the web service interface changes all you have to do is to change the internals of this intermediate class.
Update:
you can use this tool to create you object model in code. Then you can compile your new object model and use it in you application. There are many complications in what you want to do and the bottom line is; when the object model changes, your code will fail. There is absolutely no way to imagine how the interface will change so while you can do all that automatically there is nothing to do if the name of a function changes.
However the answer to your situation is indirection. If you can't guaranty the stability of a external service. Why not create a stable intermediate service that calls the actual one? this way in future you don't need to touch you application. All you have to do is to modify the intermediate service while keeping it's interface compatible.