I’m using UnityEngine.WWW to talk to a SOAP-based service that returns HTTP status code 500 along with the fault exception in the body. The behavior I’m seeing is that it does not return the body (i.e. WWW.text property) when it sees status code 500. I verified that the service does return the fault in the body via Fiddler (web debugging proxy). Is this expected behavior? Any workaround for it?
This is what I have:
var serviceUrl = "http://localhost/service/service.asmx";
var requestPayload = @"<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"">
<soapenv:Header/>
<soapenv:Body>
...
</soapenv:Body>
</soapenv:Envelope>";
var postData = Encoding.UTF8.GetBytes(requestPayload);
var headers = new System.Collections.Hashtable();
headers ["Content-Type"] = "text/xml;charset=UTF-8";
headers ["SOAPAction"] = "http://...";
WWW www = new WWW(serviceUrl, postData, headers);
_context.StartCoroutine(WaitForRequest(www));
IEnumerator WaitForRequest(WWW www)
{
yield return www;
// empty if http status cod 500
Debug.Log("WWW: " + www.text);
}
Thanks!