Note that there are some explanatory texts on larger screens.

plurals
  1. POsvcutil.exe or testing wcf service JSON ouput?
    primarykey
    data
    text
    <p>this post is off the back of my last <a href="https://stackoverflow.com/questions/7849044/wcf-web-service-that-emits-json-noob-advice">question</a> (thought i'd start a new question).</p> <p>i am trying to create and test a simple (simple to you not me lol) WCF web service that outputs JSON. I beleive (with help) the application is ok but i need to test it and i a not sure how.</p> <p>I'll attach my code below but here is what is happening, if i run the application it loads <a href="http://localhost:52002/" rel="nofollow noreferrer">http://localhost:52002/</a> and i get the welcome to ASP.NET page, if run the application while i am in my .svc it loads <a href="http://localhost:52002/MyTestService.svc" rel="nofollow noreferrer">http://localhost:52002/MyTestService.svc</a> and i get the page:</p> <blockquote> <p>You have created a service.</p> <p>To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:</p> <p>svcutil.exe <a href="http://localhost:52002/MyTestService.svc?wsdl" rel="nofollow noreferrer">http://localhost:52002/MyTestService.svc?wsdl</a></p> </blockquote> <p>I have been told i can <a href="http://localhost:52002/MyTestService.svc/GetResults" rel="nofollow noreferrer">http://localhost:52002/MyTestService.svc/GetResults</a> to see the JSON output (see code below) but all i get is: </p> <blockquote> <p>The webpage cannot be found</p> </blockquote> <p>Any suggestions would be great, i apologies now for being abit new to all this and please ask you to maybe spell things out abit more then you normally would lol</p> <p>Here is my code and tanks very much</p> <p>Person.cs</p> <pre><code>[DataContract] public class Person { [DataMember] public string FirstName { get; set; } [DataMember] public string LastName { get; set; } [DataMember] public int Age { get; set; } public Person(string firstName, string lastName, int age) { this.FirstName = firstName; this.LastName = lastName; this.Age = age; } } </code></pre> <p>MyTestServices.svc.cs</p> <pre><code>[ServiceContract(Namespace = "")] [AspNetCompatibilityRequirements(RequirementsMode = `AspNetCompatibilityRequirementsMode.Allowed)]` public class TestService { [OperationContract] [WebGet(ResponseFormat = WebMessageFormat.Json)] public List&lt;Person&gt; GetResults() { List&lt;Person&gt; results = new List&lt;Person&gt;(); results.Add(new Person("Peyton", "Manning", 35)); results.Add(new Person("Drew", "Brees", 31)); results.Add(new Person("Tony", "Romo", 29)); return results; } </code></pre> <p>MyTestService.svc</p> <pre><code>&lt;%@ ServiceHost Language="C#" Service="TestService.TestService" Factory="System.ServiceModel.Activation.ServiceHostFactory" %&gt; </code></pre> <p>Web.Config</p> <pre><code>&lt;configuration&gt; &lt;connectionStrings&gt; &lt;add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" /&gt; &lt;/connectionStrings&gt; &lt;system.web&gt; &lt;compilation debug="true" targetFramework="4.0" /&gt; &lt;authentication mode="Forms"&gt; &lt;forms loginUrl="~/Account/Login.aspx" timeout="2880" /&gt; &lt;/authentication&gt; &lt;membership&gt; &lt;providers&gt; &lt;clear/&gt; &lt;add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /&gt; &lt;/providers&gt; &lt;/membership&gt; &lt;profile&gt; &lt;providers&gt; &lt;clear/&gt; &lt;add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/&gt; &lt;/providers&gt; &lt;/profile&gt; &lt;roleManager enabled="false"&gt; &lt;providers&gt; &lt;clear/&gt; &lt;add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" /&gt; &lt;add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" /&gt; &lt;/providers&gt; &lt;/roleManager&gt; &lt;/system.web&gt; &lt;system.webServer&gt; &lt;modules runAllManagedModulesForAllRequests="true"/&gt; &lt;/system.webServer&gt; &lt;system.serviceModel&gt; &lt;bindings /&gt; &lt;client /&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name=""&gt; &lt;serviceMetadata httpGetEnabled="true" /&gt; &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt; &lt;/system.serviceModel&gt; &lt;/configuration&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload