سؤال

my iphone app is using soap web-services. I want to know how it would behave if the web-service returns a soap error?

I am using charles (HTTP Proxy) to catch the responses and modify the response before sending it to my iPhone app. What I'm trying to do is to modify a successful soap response, and turn it into a soap fault to see how my application behave.

QUESTION: How does a SOAP error response look like? (With restful all i had to do was to change the responseCode to 504, how can I achieve this with SOAP)?

هل كانت مفيدة؟

المحلول

How does a SOAP error response look like?

Here's an example of how a failed SOAP response might look like:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header />
  <s:Body>
    <s:Fault>
      <faultcode>s:Client</faultcode>
      <faultstring xml:lang="en-US">The creator of this fault did not specify a Reason.</faultstring>
      <detail>
        <MyFault xmlns="http://schemas.datacontract.org/2004/07/ToDD" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
          <MyProperty>some value</MyProperty>
        </MyFault>
      </detail>
    </s:Fault>
  </s:Body>
</s:Envelope>

As you can see there's a special <Fault> node in the body of the SOAP response which could contain any XML describing the SOAP fault. The custom XML should be in the <detail> child node.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top