我们有一个与 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>
但是,如果我将其s:Envelope与 SoapUI 一起使用,则请求可以正常工作。据我所知,这两个请求之间的唯一区别是 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 错误。任何帮助深表感谢!
谢谢,
泰加。