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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:27:58+00:00 2026-06-12T14:27:58+00:00

I have the following code which works in a Visual Studio 2010 WCF project.

  • 0

I have the following code which works in a Visual Studio 2010 WCF project.
However when I recreated the project in Visual Studio 2008, it did not worked and only gave me the following error StatuesText “Unsupported Media Type”.
Edit:
What i figured out is that the problem is in the Web.config file since it is different between Visual Studio 2010 project and 2008 project. Therefore I’ve added the all Web.config to the Question.

The javascript which calling the WCF service using soap is the following :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
    <script type="text/javascript" src="jQuery/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="jQuery/jquery.xml2json.js"></script>
    <script type="text/javascript" src="jQuery/json2.js"></script>
    <script type="text/javascript">
        function MyRequest() {
            debugger;
            var methodName = "GetData"
            var responseTagName = methodName + "Response";
            var resultTagName = methodName + "Result";
            var sendData = "";
            sendData += '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">';
            sendData += ' <s:Body>';
            sendData += ' <' + methodName + ' xmlns="http://tempuri.org/">';
            sendData += ' <name>Shlomy</name>';
            sendData += ' </' + methodName + '>';
            sendData += ' </s:Body>';
            sendData += '</s:Envelope>';
            var response = $.ajax({
                type: "POST",
                contentType: "text/xml; charset=utf-8",
                methodName: methodName,
                url: "http://localhost:16109/Service1.svc",
                data: sendData,
                async: false,
                beforeSend: function (req, methodName) {
                    var soapActionURI = "http://tempuri.org/IService1/GetData";
                    req.setRequestHeader("SOAPAction", soapActionURI);
                },
                success: function (xml, type, xhr) {
                    var result = $(xml).find(resultTagName);
                    var resultjson = $.xml2json(result);
                    successHandler(xml.text);
                },
                error: function (xmlHttpRequest, textStatus, errorThrown) {
                    alert(xmlHttpRequest.responseText);
                }
            });
        }

        function successHandler(soapResult) {
            alert(soapResult);
        }
    </script>
</head>
<body>
    <input type="button" onclick="MyRequest()" value="Call WCF via AJAX" />
</body>
</html>  

And the WCF Service(HelloWorldWCFService) is the following:
Service1.svc:

<%@ ServiceHost Language="C#" Debug="true" Service="HelloWorldWCFServiceLibrary.Service1" %>
<%@ Assembly Name="HelloWorldWCFServiceLibrary" %>    

WCF Web.Config:

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

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="debug">
          <!-- 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>
    </behaviors>
    <services>
      <service name="HelloWorldWCFServiceLibrary.Service1" behaviorConfiguration="debug" >
        <endpoint address="mex" binding="wsHttpBinding" contract="HelloWorldWCFServiceLibrary.IService1" />
      </service>
    </services>
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

And the WCF Library(HelloWorldWCFServiceLibrary) is the following:
IService.cs:

    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);

        // TODO: Add your service operations here
        [OperationContract]
        string GetData(string name);
    }

Service1.cs:

public class Service1 : IService1
{
    public string GetData(string name)
    {
        return "WCFSoapTest";
    }
}

I’ve tried for several days figuring out what is the difference between the 2008 solution and the 2010 and why only the 2010 project works. but to no avail. any suggestions ?

Thanks.

  • 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-06-12T14:27:59+00:00Added an answer on June 12, 2026 at 2:27 pm

    I was able to get it work after digging the net about it.
    The reason was as I thought – The Web.config file
    The difference was that in Visual Studio 2010 the project was created with .Net4.0 while the Visual Studio 2008 created the project with .Net3.5
    The generated Web.config file in .Net4.0 is different then the one that is generated in .Net3.5
    What I needed was to add to the service an “endpoint” with “basicHttpBinding” in order for the WCF service to work with SOAP.

    <services>
       <service name="HelloWorldWCFServiceLibrary.Service1" behaviorConfiguration="debug2">
            <endpoint address="" binding="basicHttpBinding" contract="HelloWorldWCFServiceLibrary.IService1"/>
       </service>
    </services>
    

    I found this information thanks to this link
    My new Web.config file is the following :

        <?xml version="1.0"?>
    <configuration>
      <configSections>
        <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
            <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
              <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
              <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
              <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
              <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
            </sectionGroup>
          </sectionGroup>
        </sectionGroup>
      </configSections>
      <system.web>
        <compilation debug="true">
          <assemblies>
            <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
          </assemblies>
        </compilation>
        <pages>
          <controls>
            <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
          </controls>
        </pages>
        <httpHandlers>
          <remove verb="*" path="*.asmx"/>
          <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
          <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
          <add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        </httpHandlers>
        <httpModules>
          <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        </httpModules>
      </system.web>
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior name="debug2">
              <!-- 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="HelloWorldWCFService.AjaxAspNetAjaxBehavior"/>
                </endpointBehaviors>-->
        </behaviors>
        <!--<serviceHostingEnvironment aspNetCompatibilityEnabled="false"/>-->
        <services>
          <service name="HelloWorldWCFServiceLibrary.Service1" behaviorConfiguration="debug2">
            <!--<endpoint address="" binding="wsHttpBinding" contract="HelloWorldWCFServiceLibrary.IService1"/>-->
            <endpoint address="" binding="basicHttpBinding" contract="HelloWorldWCFServiceLibrary.IService1"/>
          </service>
        </services>
      </system.serviceModel>
      </configuration>
    

    Thanks for anyone who tried to help !

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

Sidebar

Related Questions

I have the following code which works perfectly fine, however I would like to
I have following code which works for radio buttons but need to be changed
I have the following code which works perfectly, but I want to allow access
I have the following code which works when i put it in any blank
At the moment I have the following code which works fine. label = new
I have trouble to get gluLookAt working. I have the following code which works
I have the following code below which works, but I want to insert values
I have the following PHP code which works out the possible combinations from a
I have the following code for Android which works fine to play a sound
I have the following block of code which works fine; var boughtItemsToday = (from

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.