2011-09-28 3 views
0

J'ai le service Web suivant:jQuery demande Ajax dans Sharepoint 2007 (SOAP)

SOAP 1.1 

The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values. 

POST /_vti_bin/QuickLinks.asmx HTTP/1.1 
Host: myintracomm-design.ec.europa.eu 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 
SOAPAction: "http://ec.europa.eu/GetSuggestions" 

<?xml version="1.0" encoding="utf-8"?> 
<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/"> 
    <soap:Body> 
    <GetSuggestions xmlns="http://ec.europa.eu/"> 
     <prefixText>string</prefixText> 
     <count>int</count> 
    </GetSuggestions> 
    </soap:Body> 
</soap:Envelope> 

HTTP/1.1 200 OK 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 

<?xml version="1.0" encoding="utf-8"?> 
<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/"> 
    <soap:Body> 
    <GetSuggestionsResponse xmlns="http://ec.europa.eu/"> 
     <GetSuggestionsResult> 
     <string>string</string> 
     <string>string</string> 
     </GetSuggestionsResult> 
    </GetSuggestionsResponse> 
    </soap:Body> 
</soap:Envelope> 

qui je trouver en naviguant vers une URL comme:

http://www.bla.eu/_vti_bin/QuickLinks.asmx?op=GetSuggestions

J'ai essayé de faire un Ajax demande d'aller chercher le contenu se trouvant derrière, en utilisant ce code:

var productServiceUrl = 'http://myintracomm-design.ec.europa.eu/_vti_bin/QuickLinks.asmx?op=GetSuggestions'; 

function LoadData() { 
    var soapEnv = 
    '<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/"> \ 
      <soap:Body> \ 
       <GetSuggestions xmlns="http://ec.europa.eu/"> \ 
       <prefixText>sys</prefixTest> \ 
       <count>10</count> \ 
       </GetSuggestions> \ 
      </soap:Body> \ 
     </soap:Envelope>'; 

    $jQuery.ajax({ 
     url: productServiceUrl, 
     type: "POST", 
     dataType: "xml", 
     data: soapEnv, 
     complete: OnLinksFetched, 
     contentType: "text/xml; charset=\"utf-8\"" 
    }); 
} 

function OnLinksFetched(xmlHttpRequest, status) 
    { 
    $jQuery(xmlHttpRequest.responseXML) 
     .find('GetSuggestionsResult') 
     .each(function() { 
     var name = $jQuery(this).find('Name').text(); 
     $jQuery("#links").append(name); 
    });} 

et j'ai ajouté un événement onclick simple à un lien (juste à des fins de test). Malheureusement, j'ai une mauvaise erreur de requête. here is the error in action J'ai essayé de nombreuses combinaisons de la demande de savon (car je n'ai aucune expérience dans SOAP) mais sans succès. Décidé de poster ici après 5 jours d'effort. Merci d'avance pour votre aide.

Répondre

0

Vous pouvez essayer d'ajouter un en-tête de demande à votre appel de service Web.

$.ajax({ 
    url: productServiceUrl, 
    beforeSend: function(xhr) { 
     xhr.setRequestHeader("SOAPAction", 
     "http://ec.europa.eu/GetSuggestions" 
    }, 
    type: "POST", 
    dataType: "xml", 
    data: soapEnv, 
    complete: OnLinksFetched, 
    contentType: "text/xml; charset=\"utf-8\"" 
}); 
+0

je reçois un "Uncaught ReferenceError: LoadData n'est pas défini (fonction anonyme)" –