Answered by:
Run a REST WCF Service with Fiddler or Visual Studio Debug --- Read & Reconstruct XML Data

Question
-
User764773883 posted
All,
I am attempting to create a service that'll produce XML from HTTP GET. However, when I go to debug the service I receive the error "Failed to add a service. Service metadata may not be accessible." When I attempt the debug off another file and local host becomes active, I use fiddler to see if I can GET from my localhost address with the certain parameters of my service. However, when I do this I get the standard 404 error.
I don't think it is my code (I have created two version so far -- using XmlSerialization and DataContract) and I still receive the error. I am guessing it has to be my Web.config file or the markup on my .svc file.
Here is what I got for Web.config:
<?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <services> <service name="ShowtimeService.ScheduleService" behaviorConfiguration="ServiceBehavior"> <!--Service Endpoints--> <!--<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />--> <endpoint address="" binding="webHttpBinding" contract="ShowtimeService.ISchedule" behaviorConfiguration="REST" /> </service> </services> <behaviors> <serviceBehaviors> <behavior name="ServiceBehavior"> <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> <serviceMetadata httpGetEnabled="true"/> <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> <serviceDebug includeExceptionDetailInFaults="true"/> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="REST"> <webHttp/> </behavior> </endpointBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration>
Here is what I got for my ScheduleService.svc:<%@ ServiceHost Language="C#" Debug="true" Service="ShowtimeService.Schedule" CodeBehind="ScheduleService.svc.cs" %>
Any help is better than no help. Thanks for your time.
BB
Tuesday, February 5, 2013 5:07 PM
Answers
-
User764773883 posted
This is resolved.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, February 8, 2013 3:31 PM
All replies
-
User-1662538993 posted
Check this link for how to test the rest service with fiddler -
http://blogs.msdn.com/b/alikl/archive/2010/06/04/walkthrough-build-host-and-test-simple-restful-wcf-service.aspx
Wednesday, February 6, 2013 10:02 AM -
User764773883 posted
Check this link for how to test the rest service with fiddler -
http://blogs.msdn.com/b/alikl/archive/2010/06/04/walkthrough-build-host-and-test-simple-restful-wcf-service.aspx
Kushalrdalal,
I have referenced this link. this is a very good walkthrough. I have figured out why I was unable to add my service. Now I am going through debugging one method of my service. Right now, I am having issues getting my service to read an XML file for parsing.
Wednesday, February 6, 2013 2:17 PM -
User-1662538993 posted
Post some code here how you try to read the xml and where you are getting issues.
Wednesday, February 6, 2013 3:57 PM -
User764773883 posted
Sorry about the late reply Kushalrdalal. For some reason, I am not getting emails about replies.
So I am reading the xml file fine now. Now I have to create my own XML from this XML. Essentially, I am only pulling out data that I need to create a new XML file.
I am experiencing a weird issue now though.
Here is a snippet of what I am trying to do:
Performance show; Schedule showsForDay = new Schedule(); IEnumerable<XElement> performancesPerShow = from XElement ppf in show.Descendants("performance") select ppf; //obtain each performance for the selected show foreach (XElement performance in performancesPerShow)//for each performance obtained in the LINQ query above { shows.Add(performance.Attribute("showTime").Value.ToString()); roomLocations.Add(Convert.ToInt32(performance.Attribute("roomLocation").Value.ToString())); } showPerformances = new Performance(Convert.ToInt32(film.Attribute("code").Value.ToString()), shows, roomLocations); showsForDay.Add(showPerformances); } return showsForDay
All in all, the Schedule class is a List of Performances (aka List<Perfomances>). So, if I leave my code like it is the lists -- shows and roomLocations -- will contain old data from a previous performance. This will create false data within the new XML I have to create. As a result, I tried to use the Clear() method of List after I add the performance object to showsForDay. However, when I do this it clears all of my list data in showsForDay. I have some more ideas that I am going to try but you all may know what mistake I am making.
Thanks,
BB
Thursday, February 7, 2013 11:04 AM -
User764773883 posted
This is resolved.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, February 8, 2013 3:31 PM