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 7171357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:23:56+00:00 2026-05-28T15:23:56+00:00

I created a WCF Webservice method that receives two parameters, string, and return an

  • 0

I created a WCF Webservice method that receives two parameters, string, and return an XmlElement.

I have an ASP.NET page with a JQuery AJAX call to that method. It is not working and the documentation online is just getting me more confused by the minute. Some aspects to keep in mind is that right now we are sending the parameters as url-encoded.

I wouldn’t mind at this point to make the whole thing into JSON. I just need to get this working.

My webservice works perfect when I use the WCF Test client (Visual Studio 2010). But I just can’t get JQuery AJAX to talk to it. I get a Bad Request error.

If you need more details, don’t hesitate to ask.

Here is my WSDL for the webservice:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
      xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"
      xmlns:wsa10="http://www.w3.org/2005/08/addressing" 
      xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" 
      xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" 
      xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" 
      xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" 
      xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
      xmlns:tns="http://tempuri.org/" 
      xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
      xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
      targetNamespace="http://tempuri.org/" 
      name="AddressVerification">
  <wsdl:types>
    <xsd:schema targetNamespace="http://tempuri.org/Imports">
      <xsd:import namespace="http://tempuri.org/" 
           schemaLocation="http://localhost:16859/AddressVerification.svc?xsd=xsd0"/>
      <xsd:import namespace="http://schemas.microsoft.com/2003/10/Serialization/" 
           schemaLocation="http://localhost:16859/AddressVerification.svc?xsd=xsd1"/>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="IAddressVerification_DoWork_InputMessage">
    <wsdl:part name="parameters" element="tns:DoWork"/>
  </wsdl:message>
  <wsdl:message name="IAddressVerification_DoWork_OutputMessage">
    <wsdl:part name="parameters" element="tns:DoWorkResponse"/>
  </wsdl:message>
  <wsdl:message name="IAddressVerification_VerifyAddress_InputMessage">
    <wsdl:part name="parameters" element="tns:VerifyAddress"/>
  </wsdl:message>
  <wsdl:message name="IAddressVerification_VerifyAddress_OutputMessage">
    <wsdl:part name="parameters" element="tns:VerifyAddressResponse"/>
  </wsdl:message>
  <wsdl:portType name="IAddressVerification">
    <wsdl:operation name="DoWork">
      <wsdl:input message="tns:IAddressVerification_DoWork_InputMessage" 
            wsaw:Action="http://tempuri.org/IAddressVerification/DoWork"/>
      <wsdl:output message="tns:IAddressVerification_DoWork_OutputMessage" 
            wsaw:Action="http://tempuri.org/IAddressVerification/DoWorkResponse"/>
    </wsdl:operation>
    <wsdl:operation name="VerifyAddress">
      <wsdl:input message="tns:IAddressVerification_VerifyAddress_InputMessage" 
            wsaw:Action="http://tempuri.org/IAddressVerification/VerifyAddress"/>
      <wsdl:output message="tns:IAddressVerification_VerifyAddress_OutputMessage"
            wsaw:Action="http://tempuri.org/IAddressVerification/VerifyAddressResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="BasicHttpBinding_IAddressVerification" 
        type="tns:IAddressVerification">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="DoWork">
      <soap:operation style="document" 
            soapAction="http://tempuri.org/IAddressVerification/DoWork"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="VerifyAddress">
      <soap:operation style="document" 
            soapAction="http://tempuri.org/IAddressVerification/VerifyAddress"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="AddressVerification">
    <wsdl:port name="BasicHttpBinding_IAddressVerification" 
          binding="tns:BasicHttpBinding_IAddressVerification">
      <soap:address location="http://localhost:16859/AddressVerification.svc"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

Here is my JQuery:

$(document).ready(function () {

    $("#btnSubmit").click(function (e) {
        e.preventDefault();
        var address1 = $("#txtAddress1").val();
        var address2 = $("#txtAddress2").val();
        var city = $("#txtCity").val();
        var state = $("#txtState").val();
        var zipcode = $("#txtZipcode").val();

        var dataToSend = "address=" + address1 + "&city=" + city + "&state=" + state + "&zip=" + zipcode;

        $.ajax(
        {
            method: "POST",
            url: "http://localhost:16859/AddressVerification.svc/AddressVerification",
            data: dataToSend,
            success: function (dataReturned) {
                alert("YAY!!!!!!!");
            },
            error: function (dataReturned, status, errorT) {
                alert('error thrown: ' + errorT);
                alert('status: ' + status);
                alert('dataReturned: ' + dataReturned.toString());
            },
            cache: false
        });
    });
});

Here is my web.config

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
        <behavior>
          <!-- 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="false"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="EndpBehavior">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="ServiceBehavior" name="Service">
        <endpoint address="" binding="webHttpBinding"
            contract="IAddressVerification" behaviorConfiguration="EndpBehavior"/>
      </service>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>
  • 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-28T15:23:57+00:00Added an answer on May 28, 2026 at 3:23 pm

    Which bindings are your WCF endpoints configured to use?

    Looking at your WSDL, it looks like you are using a binding which uses SOAP — this will not work with how you are attempting to submit your data via jQuery.

    Take a look at using the webHttpBinding. This will enable the service to respond to simple web requests.

    http://msdn.microsoft.com/en-us/library/bb412176.aspx

    EDIT: You’ll also want to decorate your AddressVerification OperationContract with the following attribute:

    [WebInvoke(BodyStyle = WebMessageBodyStyle.WrappedRequest,
        ResponseFormat = WebMessageFormat.Json,
        UriTemplate = "AddressVerification ")]
    

    This will expose the method at the address “http://localhost:16859/AddressVerification.svc/AddressVerification” and return a JSON response.

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

Sidebar

Related Questions

I have created an Ajax enabled WCF web service that contains this simple method:
I created a simple WCF web service that has one method: SubmitTicket(flightticket ft, string
I created a REST webservice in WCF that originally used POST to perform any
I created a WCF service (.NET 3.5) that grabs data from a db and
I have a WCF service method that returns a big byte[] array around 2
In my WCF service I have method with 'int' parameter: [OperationContract] PublishResult PublishEnrollmentProfile( string
I have a WCF web service that defines IInterface interface. This interface declares two
Knowing so little about WCF, ASP.Net and Authentication/Authorization that I'm having a hard time
I am trying to create a WCF Streaming Service. I have two requirements that
I have a WCF web service called Palladium that is created as a project

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.