0

I am developing an iPhone app that is using the WCF to return data in json format. But when I am making call to the wcf service then I am getting the Error:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</faultcode><faultstring xml:lang="en-US">The message with Action 'IPhoneDevService/GetConferenceIdByEventUrlName' 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).</faultstring></s:Fault></s:Body></s:Envelope>

Service name : IPhoneDevService.svc there is no interface created for this.Same issue is comin g if I am using the Interface

Function :

[ServiceContract(Namespace = "")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    [ServiceBehaviorAttribute(IncludeExceptionDetailInFaults = true)]
    [DataContractFormat(Style = OperationFormatStyle.Document)]
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "IPhoneDevService" in code, svc and config file together.
    public class IPhoneDevService
    {

 [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Json)]
        [OperationContract]
        public string GetOneUserAuthentication(long confrenceid, string email, string password)
        {

            StringBuilder sbJson = new StringBuilder();


            try
            {
                User[] objuserdetails = new User[1];
                System.Nullable<short> strRet = 0;
                string strRetMsg = string.Empty;

                using (LINQTODBDataContext objDB = new LINQTODBDataContext())
                {
                    objuserdetails = objDB.s_t_UserLoginVerifyClient(email, password, ref strRet, ref strRetMsg).Select(res => new User
                    {
                        UserID = res.UserId,
                        Message = ExceptionMsg.GetMessage(Convert.ToInt32(strRet), strRetMsg)

                    }).ToArray();
                    if (strRet == 2)
                    {
                        new JavaScriptSerializer().Serialize(objuserdetails, sbJson);
                    }
                    else
                    {
                        new JavaScriptSerializer().Serialize(ExceptionMsg.GetMessage(Convert.ToInt32(strRet), strRetMsg), sbJson);
                    }

                }
            }

            catch (Exception ex)
            {
               return "";
            }

            return sbJson.ToString();
        }
}

xcode consumption is:

NSString *soapMessage = [NSString stringWithFormat:@&quot;&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV=\&quot;http://schemas.xmlsoap.org/soap/envelope/\ &lt;http://schemas.xmlsoap.org/soap/envelope/%5C&gt;&quot;&gt;&lt;SOAP-ENV:Body&gt;&lt;GetOneUserAuthentication&gt;&lt;confrenceid&gt;123&lt;/confrenceid&gt;&lt;email&gt;demo@abc.com &lt;mailto:demo@abc.com&gt;&lt;/email&gt;&lt;password&gt;abc&lt;/password&gt;&lt;/GetOneUserAuthentication&gt;&lt;/SOAP-ENV:Body&gt;&lt;/SOAP-ENV:Envelope&gt;&quot;];


NSURL *url = [NSURL URLWithString:@"http://mydomain.com/IPhoneDevService.svc/basic"];

NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@&amp;quot;%d&amp;quot;, [soapMessage length]];

[theRequest addValue: @&amp;quot;text/xml; charset=utf-8&amp;quot; forHTTPHeaderField:@&amp;quot;Content-Type&amp;quot;];
[theRequest addValue:@&amp;quot;IPhoneDevService/GetOneUserAuthentication&amp;quot; forHTTPHeaderField:@&amp;quot;SOAPAction&amp;quot;];
[theRequest addValue: msgLength forHTTPHeaderField:@&amp;quot;Content-Length&amp;quot;];
[theRequest setHTTPMethod:@&amp;quot;POST&amp;quot;];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];

NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

Service Model of WCF webconfig is:

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <bindings>
      <basicHttpBinding>
        <binding name="bhbinding" allowCookies="false">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>
      </basicHttpBinding>

    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviour">
          <!-- 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>
        <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" />
          <serviceThrottling maxConcurrentCalls="400" maxConcurrentInstances="400" maxConcurrentSessions="400" />
        </behavior>
        <behavior name="IphoneServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <useRequestHeadersForMetadataAddress>
            <defaultPorts>
              <add scheme="http" port="8081" />
              <add scheme="https" port="444" />
            </defaultPorts>
          </useRequestHeadersForMetadataAddress>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="Configurator_Service.IPhoneDevService" behaviorConfiguration="IphoneServiceBehaviour">
        <endpoint address="basic" binding="basicHttpBinding" bindingConfiguration="bhbinding" contract="Configurator_Service.IPhoneDevService" />
      </service>
    </services>
  </system.serviceModel>
Dalvir Saini
  • 380
  • 2
  • 11
  • 30
  • possible duplicate of [WCF - ContractFilter mismatch at the EndpointDispatcher exception](http://stackoverflow.com/questions/5487791/wcf-contractfilter-mismatch-at-the-endpointdispatcher-exception) – Pranav Singh Jun 06 '14 at 10:05

1 Answers1

0

It looks like you've configured your endpoint wrong.

In your WCF configuration you have:

<endpoint address="basic"

but in your XCode you specify

http://.../IPhoneDevService.svc

The endpoint address you specified in your configuration is going to look like:

http://.../IPhoneDevService.svc/basic

Typically, you just leave the endpoint address blank unless you need to have more than one (e.g. if you want to expose an MEX endpoint).

Michael Edenfield
  • 28,070
  • 4
  • 86
  • 117
  • I have used the both http://mydomain.com/IPhoneDevService.svc/basic and http://mydomain.com/IPhoneDevService.svc but not working – Dalvir Saini Jun 06 '14 at 13:27