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>
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.
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.
BBird40
0 Points
8 Posts
Run a REST WCF Service with Fiddler or Visual Studio Debug --- Read & Reconstruct XML Data
Feb 05, 2013 09:07 PM|LINK
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:
Any help is better than no help. Thanks for your time.
BB
kushalrdalal
Contributor
7130 Points
1272 Posts
Re: Run a REST WCF Service with Fiddler or Visual Studio Debug --- Read & Reconstruct XML Data
Feb 06, 2013 02:02 PM|LINK
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
My Blog
LinkedIn Profile
BBird40
0 Points
8 Posts
Re: Run a REST WCF Service with Fiddler or Visual Studio Debug --- Read & Reconstruct XML Data
Feb 06, 2013 06:17 PM|LINK
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.
kushalrdalal
Contributor
7130 Points
1272 Posts
Re: Run a REST WCF Service with Fiddler or Visual Studio Debug --- Read & Reconstruct XML Data
Feb 06, 2013 07:57 PM|LINK
Post some code here how you try to read the xml and where you are getting issues.
My Blog
LinkedIn Profile
BBird40
0 Points
8 Posts
Re: Run a REST WCF Service with Fiddler or Visual Studio Debug --- Read & Reconstruct XML Data
Feb 07, 2013 03:04 PM|LINK
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 showsForDayAll 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
BBird40
0 Points
8 Posts
Re: Run a REST WCF Service with Fiddler or Visual Studio Debug --- Read & Reconstruct XML Data
Feb 08, 2013 07:31 PM|LINK
This is resolved.