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

  • Home
  • SEARCH
  • 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 7536389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:33:39+00:00 2026-05-30T06:33:39+00:00

I have a simple WCF web service I tried to connect with jquery and

  • 0

I have a simple WCF web service I tried to connect with jquery and SOAP-XML ( dataType: “xml” ) .but when i send my request i get “BAD REQUEST Error 400” from my server.
here is my SOAP-XML:

var soapMessage =
            '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> \
             <soap:Header> \
             <Action soap:mustUnderstand=\"1\" xmlns=\"http://schemas.microsoft.com/ws/2005/05/addressing/none\">http://tempuri.org/IService/HelloWorld</Action> \
            </soap:Header> \
            <soap:Body> \
            <HelloWorld xmlns="http://tempuri.org/"> \
            </HelloWorld> \
            </soap:Body> \
            </soap:Envelope>';

and this is my $.Ajax :

var productServiceUrl = 'http://localhost:3523/Service.svc/HelloWorld';
    $.ajax({
                url: productServiceUrl,
                type: "POST",
                dataType: "xml",
                data: soapMessage,
                complete: endSaveProduct,
                contentType: "text/xml; charset=\"utf-8\"",
                async: true,
                error: function (xhr, textStatus, errorThrown) {
                    alert(errorThrown);

                }

            });

and here is Detail of Request and Responce (I trace this in Google Chrome):

Request Hedear

POST /Service.svc/HelloWorld HTTP/1.1

Host: localhost:3523

Connection: keep-alive

Content-Length: 550

Origin: http://localhost:3523

X-Requested-With: XMLHttpRequest

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.15 Safari/535.2

Content-Type: text/xml; charset="UTF-8"

Accept: application/xml, text/xml, */*; q=0.01

Referer: http://localhost:3523/WcfService.htm

Accept-Encoding: gzip,deflate,sdch

Accept-Language: en-US,en;q=0.8

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

and my Response Header

    HTTP/1.1 400 Bad Request

    Server: ASP.NET Development Server/10.0.0.0

    Date: Wed, 04 Jan 2012 14:56:06 GMT

    X-AspNet-Version: 4.0.30319

    Cache-Control: private

    Content-Length: 0

    Connection: Close

Request payload:

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">                  <soap:Header><Action soap:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/IService/HelloWorld</Action>                 </soap:Header><soap:Body><HelloWorld xmlns="http://tempuri.org/"></HelloWorld></soap:Body> </soap:Envelope>

and this if my WCF web service:

[OperationContract]
    [WebInvoke(Method = "POST",
                 BodyStyle = WebMessageBodyStyle.Wrapped,
                 ResponseFormat = WebMessageFormat.Xml,
                 RequestFormat = WebMessageFormat.Xml)]
    String HelloWorld();
  • 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-30T06:33:40+00:00Added an answer on May 30, 2026 at 6:33 am

    I found the way. I use this solution :
    this is my Web Service interface :

    public interface IService
    {
        [OperationContract]
        //[WebGet(UriTemplate = "/data?id={value}", ResponseFormat = WebMessageFormat.Json)]
        [WebGet(ResponseFormat = WebMessageFormat.Json)]
        string GetData(int value);
    
    }
    

    this is my impliment of this function in Web service :

    public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }
    

    and here is the Script to connect to WCF Web servise:

    <script type="text/javascript">
    
    
    
        $(document).ready(function () {
            var bhRequest = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
                "<s:Body>" +
                "<GetData xmlns=\"http://tempuri.org/\">" +
                "<value>10</value>" +
                "</GetData>" +
                "</s:Body>" +
            "</s:Envelope>";
            $("#btnWCFBasicHttp").click(function () {
                $.ajax({
                    type: "POST",
                    url: "Service.svc",
                    data: bhRequest,
                    timeout: 10000,
                    contentType: "text/xml",
                    dataType: "xml",
                    beforeSend: function (xhr) {
                        xhr.setRequestHeader("SOAPAction", "http://tempuri.org/IService/GetData");
                    },
                    success: function (data) {
                        $(data).find("GetDataResponse").each(function () {
                            alert($(this).find("GetDataResult").text());
                        });
                    },
                    error: function (xhr, status, error) {
                        alert(error);
    
                    }
                });
            });
        });
    
    
    </script>
    

    remember the WCF (url: "Service.svc") is near my html Page.

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

Sidebar

Related Questions

I have a simple WCF Web service. It's hosted on IIS under the default
i have a simple xml file in a wcf service that i am trying
I have written a simple WCF web service in C# which returns records from
We have a simple ASP.Net WCF Ajax enabled web service which is called via
I have created an Ajax enabled WCF web service that contains this simple method:
I have created a simple WCF web service. How can I view it's response
I have created a simple Northwind's Product REST Web Service in WCF at /Northwind/Product
I have a simple WCF web service on my machine which I have developed
I have a simple WCF service hosted in IIS7 using the HTTP protocol. The
I have a simple WCF Data Services service and I want to expose a

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.