Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more: , +
Hi All,

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<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).

Plz help to fix the issue. Code is given below:


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:@"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\ <http://schemas.xmlsoap.org/soap/envelope/%5C>"><SOAP-ENV:Body><GetOneUserAuthentication><confrenceid>123</confrenceid><email>demo@abc.com <mailto:demo@abc.com></email><password>abc</password></GetOneUserAuthentication></SOAP-ENV:Body></SOAP-ENV:Envelope>"];



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

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

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

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



Service Model of WCF webconfig is:
XML
<pre lang="xml"><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>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900