none
I AM NOT ABLE TO SEND JSON FROM WCF TO JQUERY RRS feed

  • Question

  • This XML file does not appear to have any style information associated with it. The document tree is shown below.
    <Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none">
    <Code>
    <Value>Sender</Value>
    <Subcode>
    <Value xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</Value>
    </Subcode>
    </Code>
    <Reason>
    <Text xml:lang="sv-FI">
    The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
    </Text>
    </Reason>

    </Fault>

    my web.config file , can you please tell me what is needed in this

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

      <configSections>
      </configSections>
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5"/>
      </system.web>
      <system.serviceModel>

        <bindings>
          <webHttpBinding>
            <binding name="default" maxBufferSize="1000000000" maxBufferPoolSize="1000000000" maxReceivedMessageSize="1000000000">
              <readerQuotas maxDepth="32" maxStringContentLength="2097152 "
                maxArrayLength="2097152" maxBytesPerRead="4096" maxNameTableCharCount="16384"  />
            </binding>
          </webHttpBinding>
        </bindings>
        <services>
          <service name="WcfService1.Service1">
            <endpoint address="http://localhost:64767/Service1.svc"
              binding="webHttpBinding"
              contract="WcfService1.IService1"
              behaviorConfiguration="ServiceAspNetAjaxBehavior" />
          </service>
        </services>


        <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehavior">
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>

          <endpointBehaviors>
            <behavior name="ServiceAspNetAjaxBehavior">

            </behavior>
          </endpointBehaviors>
        </behaviors>
        <extensions>
          <behaviorExtensions>
            <add name="matchalladdressfilter" type="Androidyou.TestLib.OverrideAddressFilterModeElement, Androidyou.TestLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
          </behaviorExtensions>
        </extensions>

        <protocolMapping>
            <add binding="basicHttpsBinding" scheme="http" />
        </protocolMapping>    

        <serviceHostingEnvironment minFreeMemoryPercentageToActivateService="0" />
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <!--
            To browse web app root directory during debugging, set the value below to true.
            Set to false before deployment to avoid disclosing web app folder information.
          -->
        <directoryBrowse enabled="true"/>
      </system.webServer>

    </configuration>

    ALL THE PROBLEMS ARE IN THIS WEB.CONFIG FILE , CAN YOU PLEASE HELP ME 

                         
    Thursday, August 28, 2014 9:00 AM

Answers

All replies

  •  <OperationContract()> _
          <WebInvoke(Method:="GET",
                     ResponseFormat:=WebMessageFormat.Json
                     )> _
        Function GetA() As String

        Public Function GetA() As String Implements IService1.GetA

            Dim json1 As String = "miskeen jatoi"
            Return json1
        End Function

    FUNCION RESPONSE IN BROWSER :

    {"d":"miskeen jatoi"}

    CALLING IN JQUERY

     

       function displayText()
            { $.ajax({
        type: 'GET',
        url: 'http://localhost:64767/Service1.svc/web/GetA',
        contentType: "application/json; charset=utf-8",
        dataType: 'json',

        success: function (response) {
                   var result=JSON.stringify(response);
                    alert(result); },   
                     error: function (textStatus) {
            alert(textStatus);
        } 
    });

    }

    gettting an error undefined ? help me i am stuck in it from 7 days

    my WEB:CONFIG FILE looks like this,

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

      <configSections>
      </configSections>
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5"/>
      </system.web>
      <system.serviceModel>

        <bindings>
          <basicHttpBinding>
            <binding maxBufferSize="1000000000" maxBufferPoolSize="1000000000" maxReceivedMessageSize="1000000000">
              <readerQuotas maxDepth="32" maxStringContentLength="2097152 "
                maxArrayLength="2097152" maxBytesPerRead="4096" maxNameTableCharCount="16384"  />
            </binding>
          </basicHttpBinding>
        </bindings>
        <services>
          <service name="WcfService1.Service1">
            <endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1" />
            <endpoint address="web" behaviorConfiguration="WebBehaviour" binding="webHttpBinding" name="WebEndPoint" contract="WcfService1.IService1" />
          </service>
        </services>
        <behaviors>
          
          <endpointBehaviors>
            <behavior name="WebBehaviour" >
              
              <enableWebScript />
            </behavior>
          </endpointBehaviors>
          <serviceBehaviors>
            <behavior name="DefaultBehaviour">
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <protocolMapping>
            <add binding="basicHttpsBinding" scheme="http" />
        </protocolMapping>    
      
        <serviceHostingEnvironment minFreeMemoryPercentageToActivateService="0" />
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <!--
            To browse web app root directory during debugging, set the value below to true.
            Set to false before deployment to avoid disclosing web app folder information.
          -->
        <directoryBrowse enabled="true"/>
      </system.webServer>

    </configuration>


    Tuesday, August 26, 2014 12:39 PM
  • Hi,

    I see that you have used the following URI:
    http://localhost:64767/Service1.svc/web/GetA

    But you do not defined the GetA as the UriTemplate, then you can not use it, please try to modify the following code:

    <OperationContract()> _
           <WebInvoke(Method:="GET",
                      ResponseFormat:=WebMessageFormat.Json
                      )> _
         Function GetA() As String

    To the following code:

    <OperationContract()> _
           <WebInvoke(UriTemplate:="GetA",Method:="GET",
                      ResponseFormat:=WebMessageFormat.Json
                      )> _
         Function GetA() As String

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    Wednesday, August 27, 2014 5:35 AM
    Moderator
  •    

    <OperationContract()> _
       <WebInvoke(Method:="GET", UriTemplate:="/GetA",
                            RequestFormat:=WebMessageFormat.Json,
                          ResponseFormat:=WebMessageFormat.Json, BodyStyle:=WebMessageBodyStyle.Wrapped)> _

        Public Function GetA() As String Implements IService1.GetA

            Dim json1 As String = "miskeen jatoi"
            Return json1
     End Function

    I GOT THE OUTPUT IN THE BROWSER

    {"GetAResult":"miskeen jatoi"}

    when i am calling this function, it gives me output 'UNDEFINED', please help me what should i do?

        function displayText()
            {
         
                $.ajax({
        type: 'GET',
        url: 'http://localhost:64767/Service1.svc/GetA',
        contentType: "application/json; charset=utf-8",
        dataType: 'json',
        data: "{}",
     
        success: function (GetAResult) {
                
                    alert(JSON.stringify(GetAResult));
                      
                    },   
                     error: function (textStatus) {
            alert(textStatus);
        } 
      
    });
    }


    Wednesday, August 27, 2014 6:58 AM
  • <OperationContract()> _
       <WebInvoke(Method:="GET", UriTemplate:="/GetA",
                            RequestFormat:=WebMessageFormat.Json,
                          ResponseFormat:=WebMessageFormat.Json, BodyStyle:=WebMessageBodyStyle.Wrapped)> _

        Public Function GetA() As String Implements IService1.GetA

            Dim json1 As String = "miskeen jatoi"
            Return json1
     End Function

    I GOT THE OUTPUT IN THE BROWSER

    {"GetAResult":"miskeen jatoi"}

    when i am calling this function, it gives me output 'UNDEFINED', please help me what should i do?

        function displayText()
            {
         
                $.ajax({
        type: 'GET',
        url: 'http://localhost:64767/Service1.svc/GetA',
        contentType: "application/json; charset=utf-8",
        dataType: 'json',
        data: "{}",
     
        success: function (GetAResult) {
                
                    alert(JSON.stringify(GetAResult));
                      
                    },   
                     error: function (textStatus) {
            alert(textStatus);
        } 
      
    });
    }
    Wednesday, August 27, 2014 11:31 AM
  • Are you using 

    <AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)>

    on your service class?

    Also worth double checking the config as advised at 

    http://social.msdn.microsoft.com/Forums/en-US/5062e96c-481a-49a6-af80-4930898256e1/call-wcf-service-from-jquery?forum=wcf

    Also you could consider sending the response in a Message as shown below:

    <OperationContract()> _
       <WebInvoke(Method:="GET", UriTemplate:="/GetA",
                            RequestFormat:=WebMessageFormat.Json,
                          ResponseFormat:=WebMessageFormat.Json, BodyStyle:=WebMessageBodyStyle.Wrapped)> _
    
        Public Function GetA() As System.ServiceModel.Channels.Message Implements IService1.GetA
    	Dim context = WebOperationContext.Current
            Dim json1 As String = "miskeen jatoi"
    context.OutgoingResponse.StatusCode = HttpStatusCode.OK
            Return context.CreateTextResponse(json, "application/json; charset=utf-8", Encoding.UTF8)
     End Function



    Wednesday, August 27, 2014 12:23 PM
  • jquery is giving the same error [object Object] it means undefined.

    thanks for your reply by please help me , i am stuck in this from two weeks.

    Wednesday, August 27, 2014 1:08 PM
  • If your service is working fine then please simplify your jquery ( no need to send data when your operation is not taking any parameters)

    Try

     $.get('http://localhost:64767/Service1.svc/GetA',function (msg) {
                                    alert(msg);
                                })

    Also if you are using it n a browser, worth checking ( posting screenshot) of request and response using the developer tools.


    Wednesday, August 27, 2014 1:23 PM
  • Refer the below URL,

    http://aspsnippets.com/Articles/Make-AJAX-JSON-call-to-ASP.Net-WCF-Service-using-jQuery-and-Javascript.aspx

    I think, you missed something in the configuration section especially in behavior section.. Cross very it with you project.


    prabakaran.M

    Wednesday, August 27, 2014 8:11 PM
  • This XML file does not appear to have any style information associated with it. The document tree is shown below.
    <Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none">
    <Code>
    <Value>Sender</Value>
    <Subcode>
    <Value xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</Value>
    </Subcode>
    </Code>
    <Reason>
    <Text xml:lang="sv-FI">
    The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
    </Text>
    </Reason>

    </Fault>

    my web.config file , can you please tell me what is needed in this

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

      <configSections>
      </configSections>
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5"/>
      </system.web>
      <system.serviceModel>

        <bindings>
          <webHttpBinding>
            <binding name="default" maxBufferSize="1000000000" maxBufferPoolSize="1000000000" maxReceivedMessageSize="1000000000">
              <readerQuotas maxDepth="32" maxStringContentLength="2097152 "
                maxArrayLength="2097152" maxBytesPerRead="4096" maxNameTableCharCount="16384"  />
            </binding>
          </webHttpBinding>
        </bindings>
        <services>
          <service name="WcfService1.Service1">
            <endpoint address="http://localhost:64767/Service1.svc"
              binding="webHttpBinding"
              contract="WcfService1.IService1"
              behaviorConfiguration="ServiceAspNetAjaxBehavior" />
          </service>
        </services>
        

        <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehavior">
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
         
          <endpointBehaviors>
            <behavior name="ServiceAspNetAjaxBehavior">
              
            </behavior>
          </endpointBehaviors>
        </behaviors>
        <extensions>
          <behaviorExtensions>
            <add name="matchalladdressfilter" type="Androidyou.TestLib.OverrideAddressFilterModeElement, Androidyou.TestLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
          </behaviorExtensions>
        </extensions>

        <protocolMapping>
            <add binding="basicHttpsBinding" scheme="http" />
        </protocolMapping>    
      
        <serviceHostingEnvironment minFreeMemoryPercentageToActivateService="0" />
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <!--
            To browse web app root directory during debugging, set the value below to true.
            Set to false before deployment to avoid disclosing web app folder information.
          -->
        <directoryBrowse enabled="true"/>
      </system.webServer>

    </configuration>

    Thursday, August 28, 2014 7:32 AM
  • This XML file does not appear to have any style information associated with it. The document tree is shown below.
    <Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none">
    <Code>
    <Value>Sender</Value>
    <Subcode>
    <Value xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</Value>
    </Subcode>
    </Code>
    <Reason>
    <Text xml:lang="sv-FI">
    The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
    </Text>
    </Reason>

    </Fault>

    my web.config file , can you please tell me what is needed in this

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

      <configSections>
      </configSections>
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5"/>
      </system.web>
      <system.serviceModel>

        <bindings>
          <webHttpBinding>
            <binding name="default" maxBufferSize="1000000000" maxBufferPoolSize="1000000000" maxReceivedMessageSize="1000000000">
              <readerQuotas maxDepth="32" maxStringContentLength="2097152 "
                maxArrayLength="2097152" maxBytesPerRead="4096" maxNameTableCharCount="16384"  />
            </binding>
          </webHttpBinding>
        </bindings>
        <services>
          <service name="WcfService1.Service1">
            <endpoint address="http://localhost:64767/Service1.svc"
              binding="webHttpBinding"
              contract="WcfService1.IService1"
              behaviorConfiguration="ServiceAspNetAjaxBehavior" />
          </service>
        </services>
        

        <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehavior">
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
         
          <endpointBehaviors>
            <behavior name="ServiceAspNetAjaxBehavior">
              
            </behavior>
          </endpointBehaviors>
        </behaviors>
        <extensions>
          <behaviorExtensions>
            <add name="matchalladdressfilter" type="Androidyou.TestLib.OverrideAddressFilterModeElement, Androidyou.TestLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
          </behaviorExtensions>
        </extensions>

        <protocolMapping>
            <add binding="basicHttpsBinding" scheme="http" />
        </protocolMapping>    
      
        <serviceHostingEnvironment minFreeMemoryPercentageToActivateService="0" />
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <!--
            To browse web app root directory during debugging, set the value below to true.
            Set to false before deployment to avoid disclosing web app folder information.
          -->
        <directoryBrowse enabled="true"/>
      </system.webServer>

    </configuration>
    Thursday, August 28, 2014 7:32 AM
  • Hi,

    Please try to modify the following:

        <endpointBehaviors>
             <behavior name="ServiceAspNetAjaxBehavior">
             </behavior>
         </endpointBehaviors>


    To the following:

        <endpointBehaviors>
             <behavior name="ServiceAspNetAjaxBehavior">
               <webHttp/>
             </behavior>
          </endpointBehaviors>

    Besides, please also try to check the following article:
    #Calling WCF Services using jQuery:
    http://www.codeproject.com/Articles/132809/Calling-WCF-Services-using-jQuery .

    Best Regards,
    Amy Peng



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, August 29, 2014 5:11 AM
    Moderator