data contract break service - wcf

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.

Related

Can't debug MVC4 project

Relatively new to mvc. I have what I consider a strangely architected project that I inherited after someone left my company. There are two "service layers". The main layer is an MVC 4 project which expects a REST query. Here is how it works:
An asp.net page in another project allows the user to enter a REST query. The same asp.net page calls serviceRequest.DownloadString with the REST query that was entered.
This results in a call to a DelegatingHandler in the mvc 4 project. This DelegatingHandler does some validation of the headers sent with the request. If the data is correct, the DelegatingHandler calls base.SendAsync with the same REST query that was passed in to the DelegatingHandler.
This activates the controller in the mvc 4 project that is called by the REST query. If it is working, the mvc 4 project returns xml.
4, To do much of the work the controller calls methods from a wcf project.
What is happening is that this architecture works fine if run inside visual studio. It also runs fine if the two service layers (the mvc 4 and wcf projects) are deployed to IIS applications on my local machine.
The problem occurs when the service layers are deployed to two seperate machines, one in the dmz and one on a macine inside the firewall. It returns a 500.
I used fiddler and fixed one problem that had to do with connection strings. Once that was done I still got the 500 as a result but no other information. In this case running fiddler again only confirmed that I was receiving a 500. I have tried:
puting trace code in the configs of both service layers
using an existing function in the wcf layer to write some debug information to a table from the controller.
I realize that I might not have put in the trace code in the mvc and wcf config files but it does seem to be simply bypassing the mvc 4 project altogether. I also notice some information on being able to use debug.write. Is this a viable option.
None of these two steps has brought me any closer to solving the problem. I am getting the impression that the mvc 4 code is never getting called at all and the error is occuring when the serviceRequest.DownloadString is called to bring up the DelegatingHandler. However I don't know where to look to see if I'm right. Is there a spot in the code (e.g and event) that I could use to follow the code from when it leaves the asp.net page and tries to go to the mvc 4 project?
What is the best way to debug this? Any help would be appreciated.
Thanks,
Fig0000
I'm not quite sure, but looks like the error returned is not shown because you are not running on localhost. And the error might be for some config files wrong or anything actually.
Can you try to run the application isolated (maybe creating a dummy method in each and if that works, make the internal call (fake / mock) so you can see what's the actual problem.
OR
you can try to let mvc to display all error even on remote. You can do this on web.config :
<customErrors mode="Off">
</customErrors>

Add Service Reference "___ is already defined"a

I have a WCF web service that I am working on and I built it and was delighted to find that I could use complex types in it. I added some and then realized that they were still not useable as those types on the client end. This is an internal web service so these types are known on both sides. Anyway, that's not the problem, as I took the complex types out, but I think it may have left some residual issues.
When I then changed my additions to all be base types (string, date, int, etc) then added the web service to the client project, I got a "[enumtype] is already defined" error. It occurred in the reference.cs file so I opened it up. Sure enough there were duplicate enums. Plus there were a bunch of helper (serializing) functions. The duplicate enum was from code that had been in there before I picked this web service up to work on. It had not caused an issue previously.
I opened up the reference.cs for the previous (successful) service reference. It did not have the duplicates or functions and also I noticed a difference between the entries that were in there. The reference.cs that was failing to compile had this additional attribute in several places:
[System.ServiceModel.XmlSerializerFormatAttribute()]
I also see that my new failed code was using string[] and the old was using ArrayOfString. I did not intentionally change this, but must have somehow set something differently in the process.
Does anyone have a few clues?
Thanks!
Have you tried deleting the service reference from the project and re-adding it? You may have to manually remove some (or all) of the serviceModel contents too. If that is the only Service Reference then definitely remove the serviceModel element contents too.
Once its all gone, re-add the Service Reference. If you're still having problems then it may be that the service metadata is generating invalid WSDL causing the duplicate enums.
UPDATE: Just for verifying the WSDL is not valid, you could try creating the service proxy manually using the SvcUtil command line utility. It generates your proxy code like Visual Studio does and may give you more troubleshooting info.
After a lot of experimentation this is what I found out:
Our web service up to this point was using the Request / Response classes for input and output. There were required in 1.0, and were a carry over from that. I attempted to create a simple entry point that sent in a string and returned a string. This compiled ok, but:
Although you can use regular types for input and output, if you are using Request / Response types exchanges for other entry points, then you cannot.
Mixed method of request / response and regular types will compile, but it will not successfully import (at least into Visual Studio 2008). What ends up being created seems to be an attempt to create input and output classes for all of the functions to translate them to their complex types, along with the Request / Response types which creates duplicate entries and will not compile.
This then also means that you cannot send in a request object and return a string (which is how I found out that this was not allowed) – this generated an error in the unit test, which started me down this path.
So if you have a request / response web service, all functions must follow that protocol.

EF4: using Add Service Reference causes issues with STE(self tracking entities) not remember there changes?

I found an issue but it refers to the BETA version of VS 2010. I am interested in knowing if this issue has been fixed in RTM?
Basically it states (saw it via EF 4 Self Tracking Entities does not work as expected )
Make certain to reuse the
Self-Tracking Entity template’s
generated entity code on your client.
If you use proxy code generated by Add
Service Reference in Visual Studio or
some other tool, things look right for
the most part, but you will discover
that the entities don’t actually keep
track of their changes on the client.
I am very used to using Add Service Reference, and its always worked great for me in the past but of course I wasn't using STE (Self tracking entities). Is this problem still apparent with VS 2010 RTM and the STE template?
If I do create the proxy via code instead of add service then all the classes won't be created will they?
This is not an issue and it never was an issue. It is absolutly expected and correct behavior. STEs are classes which contains data and logic (the logic tracks changes).
When adding service reference your client proxy code is generated from service's metadata. Metadata are exposed in form WSDL. WSDL is XML based description of the service which also contains XSD description of transfered data types. XSD can describe only data format but not related logic implemented by the type. By default all unknown data types described in WSDL are generated on the client. So when you generate client proxy with all data types by Add service reference the tracking logic is lost.
To overcome this issue you have to do two things:
Create separate assembly and place all your STEs to this assembly. Then share this assembly among all involved layers (yes you have to use Add reference in your client).
Then you can use Add service reference with "Reuse types in referenced assemblies" checked.

Domain Datasource not updating in Silverlight Project after Changing Entity

I have a Silverlight project that is accessing data via a Domain Service/Entity Framwork. I made a change to the database, I then updated teh EDMX, and then deleted and recreated the Domain Service. I can see the newly added properties in the DomainServiceName.metadata.cs file.
But I cannot for the life of me figure out how to get the data source to refresh in the Silverlight project. I have recompiled, deleted the DomainContext file and regenerated it, but the objects on the Silverlight side to not have the new properties.
I created a temp RIA project and used it to remake the Domain Service and just lifted the code that I needed. Not optimal but it saved me from having to manually type all of the metadata and service methods.

WCF service reference update

Right now we have around 5 service reference added to our projects in a single solution.
I am force to add service reference even for projects having indirect dependencies calling service methods. Is there a way to get around for this situation.
For every single change in the service method, I have to update every single service reference to effect those changes. It is very time consuming too.
I am just wondering, is there any way i cam manage these things globally by making single service reference for the whole solution.
help appreciated.....:)
You should be able to use the svcutil.exe command line utility to generate a single service file (.cs file for example) from multiple service URL's. The nice thing about this is that you can share clinet-side DTO's and message types accross services if they have the same schema.
SvcUtil Reference: http://msdn.microsoft.com/en-us/library/aa347733.aspx
In regards to the requirement of adding the service reference to projects with indirect dependencies. You should probably not consume the service reference and related types directly from your service client. To improve maintainability and adaptability, you should wrap your service reference(s) in a facade. The facade would map between local types and service reference types, and give you much more agility in terms of responding to service changes. You would then only need to have the service references in a single location (preferably an independent project) along with the facade. The facade, which should change infrequently, will buffer you from the issues you are currently having with your service references.
You won't be able to get a single reference if you have multiple service, unfortunately.I stand corrected - see jrista's answer.
What you could do is create and update the service references automatically: instead of adding them manually in Visual Studio using Add Service Reference check out the svcutil.exe command line tool which will basically do the same thing.
Since it's a command line tool, you can have it run as e.g. part of your continuous build and update the necessary proxy client files every time you build the app.
Check out these additional links for tutorials and explanations about the details of using svcutil.exe:
http://msdn.microsoft.com/en-us/library/ms734712.aspx
http://asadsiddiqi.wordpress.com/2008/10/25/how-to-generate-wcf-client-proxy-class-using-svcutilexe/
http://www.xvpj.net/2008/03/08/wcf-step-by-step-tutorial/
Marc