wcf xml response

Below jquery returns success status but I can't see the value which is just a text. ("HI I love jquery").

Can you help me? Thanks

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace WcfService2
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService" in both code and config file together.
    public interface IService
        [WebInvoke(Method = "GET",
               BodyStyle = WebMessageBodyStyle.Wrapped,              
               ResponseFormat = WebMessageFormat.Xml)]
        string DoWork2();      

namespace WcfService2
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service" in code, svc and config file together.
    // NOTE: In order to launch WCF Test Client for testing this service, please select Service.svc or Service.svc.cs at the Solution Explorer and start debugging.
    public class Service : IService
        public string DoWork2()
            return "HI I love jquery";

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
     <script type="text/javascript">        
         function CallMyService2() {
                 type: "GET",
                 url: "Service.svc?wsdl/DoWork2",
                 dataType: "xml", //response format
                 contentType: "text/plain", // content type sent to server
                 success: ServiceSucceeded,
                 error: ServiceFailed

         // ---- WCF Service call backs -------------------
         function ServiceFailed(result) {
             Log('Service call failed: ' + result.status + '  ' + result.statusText);
         function ServiceSucceeded(result) {
             var resultObject = result.MyFunctionResult;

         // ---- Log ----------------------------------------
         // utility function to output messages
         function Log(msg) {
             $("#logdiv").append(msg + "<br />");
</head> <body onload="CallMyService2()">
    <div id="logdiv"></div>  <!--For messages-->  
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Calling URL format: Service.svc?wsdl/DoWork2
- Do not include WSDL
- Do not  include ? in your URL, otherwise the rest of the URL is treated as a querystring parameter not name of function called DoWork2
- It should be Service.svc/DoWork2

Decorate Service with:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

Also add a "using System.ServiceModel.Activation;"

Simpliy this
Just perhaps rather take out BodyStlye and ResponseFormat for now
 [WebInvoke(Method = "GET",
               BodyStyle = WebMessageBodyStyle.Wrapped,              
               ResponseFormat = WebMessageFormat.Xml)]

You also need to configure your service to be accessible from scripts. Follow this example: http://www.codeproject.com/Articles/275279/Developing-WCF-Restful-Services-with-GET-and-POST , http://www.c-sharpcorner.com/UploadFile/0c1bb2/ajax-enabled-wcf-service/

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.