我们有一个与iPhone应用程序对话的.NET WCF服务。我使用wsdl2objc来生成所有SOAP魔术所需的objc代码。SoapUI能够添加此服务的wsdl并正确发送请求。但wsdl2objc生成的请求对此提出了抱怨:
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body>
<s:Fault>
<s:Code>
<s:Value>s:Sender</s:Value>
<s:Subcode>
<s:Value xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</s:Value>
</s:Subcode>
</s:Code>
<s:Reason>
<s:Text xml:lang="en-US">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).
</s:Text>
</s:Reason>
</s:Fault>
</s:Body>
</s:Envelope>但是,如果我对SoapUI使用相同的s:Envelope,则请求可以正常工作。据我所知,这两个请求之间唯一的区别是wsdl2objc生成以下内容的头部分:
SOAPAction:http://xx/AuthenticateDevice
但是soapUI会生成:
Content-Type: application/soap+xml;charset=UTF-8;action="http://xx/AuthenticateDevice"
我尝试更改wsdl2objc生成的代码,并替换为:
[request setValue:soapAction forHTTPHeaderField:@"SOAPAction"];
NSString *contentType = [NSString stringWithFormat:@"application/soap+xml; charset=utf-8;"];
[request setValue:contentType forHTTPHeaderField:@"Content-Type"];有了这个:
[request setValue:soapAction forHTTPHeaderField:@"action"];
NSString *contentType = [NSString stringWithFormat:@"application/soap+xml; charset=utf-8;"];
[request setValue:contentType forHTTPHeaderField:@"Content-Type"];但是,我现在只得到了一个400错误。任何帮助都是非常感谢的!
谢谢,
太好了。
发布于 2013-08-01 10:30:18
我也遇到过类似的问题,通过更改wsdl2objc输出中的信封模式URL修复了这个问题
我改变了这个
xmlNsPtr soapEnvelopeNs = xmlNewNs(root, (const xmlChar*)"http://www.w3.org/2003/05/soap-envelope", (const xmlChar*)"soap");要这样做:
xmlNsPtr soapEnvelopeNs = xmlNewNs(root, (const xmlChar*)"http://schemas.xmlsoap.org/soap/envelope/", (const xmlChar*)"soap");它似乎修复了来自iOS的WCF服务调用。
我认为这意味着我的wsdl2objc版本输出SOAP1.1信封,而WCF服务器似乎需要SOAP1.2
还有没有人注意到这一点?有没有其他方法可以配置它,而不是在生成代码后进行更改?
发布于 2012-03-28 03:04:13
似乎我缺少导致此问题的操作值周围的开始引号和结束引号标记。下面是适用于我的代码,但我不喜欢将action设置为http content-type头的一部分。因此,如果有人能想出更好的解决方案,我很乐意给予肯定:
NSString *contentType = [NSString stringWithFormat:@"application/soap+xml; charset=utf-8; action=\"%@\"", soapAction];
[request setValue:contentType forHTTPHeaderField:@"Content-Type"];发布于 2012-03-28 21:24:14
在我使用过的WCF服务中,我只是在Content-Type标头中传递了值"text/xml",然后在一个单独的SOAPAction标头中传递了正确的soap操作值(类似于wsdl2objc的方式)。
以下是需要检查的几件事:
WCF
<ServiceNamespace>\<WCFInterfaceName>\<MethodName>构建的
https://stackoverflow.com/questions/9894563
复制相似问题