Question

Je développe mon premier widget Dashboard et essayez d'appeler un webservice. Mais je continue à obtenir le statut XMLHTTPRequest 0.

Voici le code

    var soapHeader = '<?xml version=\"1.0\" encoding=\"utf-8\"?>\n'
                             +'<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n'

                             +'<soap:Body>\n'
                             +'<UsersOnline xmlns=\"http://wsSync\" />\n'
                             +'</soap:Body>\n'
                             +'</soap:Envelope>';


var destinationURI = 'http://ws.storan.com/webservicesformraiphone/wssync.asmx';

var actionURI = 'http://wsSync/UsersOnline';
function callWebService() {
  try{
       SOAPObject = new XMLHttpRequest();
       SOAPObject.onreadystatechange = function() {fetchEnd(SOAPObject);}
       SOAPObject.open('POST', destinationURI, true);


       SOAPObject.setRequestHeader('SOAPAction', actionURI);
       SOAPObject.setRequestHeader('Content-Length', soapHeader.length);
       SOAPObject.setRequestHeader('Content-Type', 'text/xml; charset=utf-8');
       var requestBody = soapHeader;
       SOAPObject.send(requestBody);


  } catch (E)
  {
     alert('callWebService exception: ' + E);
  }
}

function fetchEnd(obj)
{

   if(obj.readyState == 4){ 

        if(obj.status==200)
        {
            alert("Yahooooooo");
        }
   }
}

Toutes les idées?

Était-ce utile?

La solution

Avez-vous ajouté

<key>AllowNetworkAccess</key>
<true/>

à la plist? sinon le monde extérieur ne sera pas disponible.

Vous pouvez également rencontrer des problèmes si vous essayez de domaines croisés.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top