简体   繁体   中英

wsdl2objc: ContractFilter mismatch at the EndpointDispatcher

We have a .NET WCF Service talking to an iPhone app. I'm using wsdl2objc to generate the objc code required for all the SOAP magic. SoapUI is able to add this service's wsdl and send requests correctly. But the request generated by wsdl2objc complains about this:

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

However, If I use the same s:Envelope with SoapUI, the request works correctly. The only difference between the two requests as far as I can see is the header section where wsdl2objc generates this:

SOAPAction:http://xx/AuthenticateDevice

but soapUI generates:

Content-Type: application/soap+xml;charset=UTF-8;action="http://xx/AuthenticateDevice"

I tried to change the code that wsdl2objc generated and replaced this:

[request setValue:soapAction forHTTPHeaderField:@"SOAPAction"];
NSString *contentType = [NSString stringWithFormat:@"application/soap+xml; charset=utf-8;"];
[request setValue:contentType forHTTPHeaderField:@"Content-Type"];

with this:

[request setValue:soapAction forHTTPHeaderField:@"action"];
NSString *contentType = [NSString stringWithFormat:@"application/soap+xml; charset=utf-8;"];
[request setValue:contentType forHTTPHeaderField:@"Content-Type"];

But, I just get a 400 error now. Any help is much appreciated!

Thanks,
Teja.

I had a similar issue that was fixed by changing the envelope schema URL in the wsdl2objc output

I changed this

xmlNsPtr soapEnvelopeNs = xmlNewNs(root, (const      xmlChar*)"http://www.w3.org/2003/05/soap-envelope", (const xmlChar*)"soap");

to This:

xmlNsPtr soapEnvelopeNs = xmlNewNs(root, (const xmlChar*)"http://schemas.xmlsoap.org/soap/envelope/", (const xmlChar*)"soap");

and it seemed to fix my WCF web-service calls from iOS.

What I think this means is that my version of wsdl2objc is outputting a SOAP 1.1 envelope when the WCF server seems to want SOAP 1.2

Has anyone else noticed this? Is there another way to configure this rather than change after generating the code?

It appears that I was missing begin quote and end quote tags around the action value which was causing this. Here's the code that worked for me, but I'm not happy with setting the action as a part of the http content-type header. So if someone can come up with a better solution, I'd be happy to give credit:

NSString *contentType = [NSString stringWithFormat:@"application/soap+xml; charset=utf-8; action=\"%@\"", soapAction];
[request setValue:contentType forHTTPHeaderField:@"Content-Type"];

In the WCF services I've worked with I've just passed the value "text/xml" in the Content-Type header and then passed the correct soap action value in a separate SOAPAction header (similiar to the way wsdl2objc was doing it).

Here are a couple things to check:

  1. Is your WCF service using basicHttpBinding - or something else. (I seem to remember reading that bindings other than basicHttpBinding don't work well (or at all) with iOS - but I'm not certain)
  2. What is the correct SOAP action value for this service? In the services I work with it's built using <ServiceNamespace>\\<WCFInterfaceName>\\<MethodName>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM