如何在目标c中使用WCF

时间:2012-04-16 08:41:55

标签: iphone objective-c wcf ios5 wsdl

我正在尝试通过目标c使用WCF“/www.xxxxx.net/xxxx.svc”,我按照以下链接中的步骤操作 Consume WCF Web Service using Objective-C on iPhone

我收到以下错误

<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 'http://tempuri.org/IService1/GetMembers' 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>

请在这方面帮助我, 提前致谢

1 个答案:

答案 0 :(得分:0)

目前尚不清楚您是否按原样复制ObjectiveC代码。问题可能是SO中的代码回答您引用硬编码无效字符串,该字符串是要发送到WCF服务的soap XML。如果您按原样复制代码,则需要发送对您的服务有效的soap XML。

如果您已为您的WCF服务捕获了soap XML并且它无法正常工作,则问题仍然是格式不正确的soap消息。在任何一种情况下,我都会首先捕获成功调用WCF服务的消息,以确定正确的soap XML应该是什么样子,并将其与您正在创建的soap XML进行比较,以查看问题所在。

如果可能的话,考虑将webHttpBinding添加到您的WCF服务,这样您就可以使用更简单的XML来处理您的消息。查看webHttpBinding上的这个four part walkthrough,了解它需要做些什么。