Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7591671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:42:31+00:00 2026-05-30T20:42:31+00:00

I’m messing about with my first WCF service and I am having problems passing

  • 0

I’m messing about with my first WCF service and I am having problems passing parameters.

My jQuery ajax call looks like this…

$.ajax({
    type    : 'POST',
    async   : true,
    url     : 'Service2.svc/GetStats',
    contentType: 'application/json; charset=utf-8',
    data    : '{ i : 12 }',
    dataType: 'json',
    success : function(result) {
        //success routine...
    }
});

add my service code is like…

<OperationContract()> _
<WebInvoke(ResponseFormat:=WebMessageFormat.Json, RequestFormat:=WebMessageFormat.Json)> _
Public Function GetStats(ByVal i As Integer) As Results
    Dim returnValue As New Results
    returnValue.iValue1 = 10
    returnValue.iValue2 = 20
    returnValue.sMessage = "You executed " + "sdfsd"
    Return returnValue
End Function

Results class is a really simple holder class, two Integers and a String.

This service works fine if I remove the parameters from GetStats and remove the corresponding data property from my $.ajax object – I can access the three returned values on the client.

When the parameter i is included I get an Internal Server Error status:500.

I’m guessing I’m missing an attribute or something from my service Function?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:42:33+00:00Added an answer on May 30, 2026 at 8:42 pm

    Thanks for the responses.

    I spent a while wrestling with this one and all I needed to do was…

            data    : '{"i" : 12}' ,  //Object name i in double-quotes
    

    So contrary to some of the other suggestions i do want to pass the JSON as a string. (I suppose one should really use a library such as Crockford’s JSON for this)

    However I could only discover this after finding what the actual error was. I did this by throwing this snippet into my web.config file…

    <system.diagnostics>
      <sources>
        <source name="System.ServiceModel" switchValue="Warning, ActivityTracing"
          propagateActivity="true">
          <listeners>
            <add type="System.Diagnostics.DefaultTraceListener" name="Default">
              <filter type="" />
            </add>
            <add name="ServiceModelTraceListener">
              <filter type="" />
            </add>
          </listeners>
        </source>
      </sources>
      <sharedListeners>
        <add initializeData="app_tracelog.svclog"
          type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, 
            Culture=neutral, PublicKeyToken=b77a5c561934e089"
            name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
          <filter type="" />
        </add>
      </sharedListeners>
    </system.diagnostics>
    

    I got this from mkdot.net and it should really be generated using SvcConfigEditor.exe – which I couldn’t find on my locked down machine. But just pasting that in seemed to work – and gave me a log file in my development folder – this actually told me the nature of the error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
I would like to run a str_replace or preg_replace which looks for certain words
I have a jquery bug and I've been looking for hours now, I can't
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.