<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Calling a Web Service Using XmlHttpRequest</title>
<script type="text/javascript" language="javascript">
var xmlhttp;
var XMLContent='<XML ID="Transaction"><Transaction>'+
'<LoginDetails>'+
'<Email>artur</Email>'+
'<Password>demos2</Password>'+
'</LoginDetails>'+
'<JobDetails>'+
'<JobId>40170978</JobId>'+
'<JobRefNo>prod84</JobRefNo>'+
'<JobTitle>'+
'<![CDATA[ Director of R&D Software product (Multimedia)]]>'+
'</JobTitle>'+
'<JobExpiry>30</JobExpiry>'+
'<JobContactName>'+
'<![CDATA[ Brian Mc Fadden]]>'+
'</JobContactName>'+
'<JobContactEmail>[email protected]</JobContactEmail>'+
'<JobShortDesc>'+
'<![CDATA[ Director of R&D Software product concepts Multimedia Web 2.0]]> '+
'</JobShortDesc>'+
'<JobDetDesc><![CDATA[ <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><STRONG>Director of R&D Software product concepts to</STRONG> build a the new prototyping team and processes from the ground up, utilizing an agile development model, manage the R&D team develop a strong vision and be able to clearly articulate the direction the group will take in terms of methodologies and tools in technologies such as J2EE, .NET, Flash, AJAX, DHTML, JavaScript, take marketing requirements from the principal investigators and write functional requirement documents, manage budget for R&D development, manage the projects developed by the internal team and vendors. </P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto">To get this new role you will have a degree in IT/Software and over 5 years plus doing cutting edge development in R&D/ prototyping and leading cutting edge development teams in a software production/product environment, project management and process management skills (AGILE) and demonstrated experience working on product innovation and releases. You may be working in educational gaming, social networking, Web 2.0 applications, mobile technologies, learning management systems, online courseware or shareware. </P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"> </P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt">The package is to €105K + Bonus + VHI + Pension + relocation package where applicable + stock options may be negotiated. There are great career advancement opportunities. To discuss this and other opportunities please send an up-to-date resume to <A href="mailto:[email protected]">[email protected]</A> or call +353 1 6489113 in confidence. Your details will not be sent to any third party without your consent. </P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"> </P>]]>'+
'</JobDetDesc>'+
'<JobSalary>90000</JobSalary>'+
'<JobSalaryMax>105000</JobSalaryMax>'+
'<JobQues1><![CDATA[ ]]>'+
'</JobQues1>'+
'<JobQues2><![CDATA[ ]]>'+
'</JobQues2>'+
'<JobQues3><![CDATA[ ]]>'+
'</JobQues3>'+
'<JobType>0|0</JobType>'+
'<JobAddnlBens>17,14,23,1,5,9,12,10</JobAddnlBens>'+
'<JobLocations>96,98,97</JobLocations>'+
'<JobEducations>8</JobEducations>'+
'<JobExperiences>10</JobExperiences>'+
'<JobCategories>1043,1050</JobCategories>'+
'<JobSubcategories>69896,69869</JobSubcategories>'+
'</JobDetails>'+
'</Transaction>'+
'</XML>';
function on_click()
{
if(window.ActiveXObject)
{
try
{
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
}
catch (ex)
{
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
}
else if (window.XMLHttpRequest)
{
xmlhttp = new window.XMLHttpRequest();
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
}
var xmlToSend = '<?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>'+
'<InsertXML xmlns="http://recpushdata.cyndigo.com/">'+
'<Jobs>'+XMLContent+'</Jobs>'+
'</InsertXML>'+
'</soap:Body>'+
'</soap:Envelope>';
var szUrl;
szUrl = 'http://recpushdata.cyndigo.com/Jobs.asmx?op=InsertXML';
xmlhttp.onreadystatechange = state_Change;
xmlhttp.open("Post", szUrl, true);
xmlhttp.setRequestHeader ("SOAPAction", "http://recpushdata.cyndigo.com/InsertXML");
xmlhttp.setRequestHeader ("Content-Type", "text/xml");
xmlhttp.send(xmlToSend);
}
function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
{
// if "OK"
if (xmlhttp.status==200)
{
alert("OK"+xmlhttp.responseText);
}
else
{
alert("Problem retrieving XML data "+xmlhttp.responseText);
}
}
}
</script>
</head>
<body>
<div>
<h1>
Click the button to call the web service</h1>
<input type="button" onclick="return on_click();" value="OK" />
</div>
<div id="responseDiv">
</div>
</body>
</html>
1
A
Répondre
6
XmlHttpRequest peut uniquement être utilisé pour appeler les services locaux au domaine/serveur à partir duquel la page est diffusée.
Ainsi, si vous servez une page:
http://www.example.com/page1
Vous ne pouvez pas faire un XMLHttpRequest pour:
http://www.sample.com/webservice
0
Depuis que vous configurez Content-type
, vous devez également définir ce paramètre à utilisez UTF-8
. Et je pense que c'est censé être application/xml
(source).
xmlhttp.setRequestHeader("Content-Type", "application/xml; charset=utf-8");
Sinon, avez-vous vérifié que le format XML est correctement formaté? Essayez de l'enregistrer en tant que fichier XML complet et ouvrez-le dans votre navigateur.
0
Questions connexes
- 1. OpentextFile Autorisation refusée Erreur
- 2. Autorisation refusée erreur appelant fopen
- 3. Erreur RunTime '70' Autorisation refusée dans VB6
- 4. Suppression des erreurs "autorisation refusée" en Javascript
- 5. Autorisation Jquery refusée - nom de domaine différent
- 6. Le semget échoue avec "Autorisation refusée"
- 7. Autorisation refusée pour obtenir la propriété HTMLDocument.body
- 8. Autorisation Linux refusée après chmod a = rwx
- 9. Ajax erreur - "permission refusée"
- 10. Composant Firefox XPCOM - Autorisation refusée pour appeler la méthode UnnamedClass
- 11. Erreur jQuery XMLHttpRequest
- 12. Erreur de messagerie PHP ... n'a pas réussi à ouvrir le flux: autorisation refusée
- 13. Autorisation Erreur refusée dans IE6 Début de la balise JavaScript dans .aspx
- 14. Erreur de test de l'unité Iphone: autorisation refusée avec google toolBox
- 15. Ajouter un utilisateur à SQL Server 2008 - autorisation refusée
- 16. Rails Autorisation erreur
- 17. Javascript "permission refusée" Erreur dans IE.x
- 18. Autorisation Vista refusée pour l'utilitaire de ligne de commande s'exécutant dans Program Files
- 19. svn: Impossible de créer le répertoire '/subversion/main/db/transactions/0-1.txn': Autorisation refusée
- 20. JDBC- postgres, connexion refusée
- 21. Timeout XMLHttpRequest
- 22. XMLHttpRequest problème
- 23. [erreur ADO.NET]: autorisation CREATE DATABASE refusée dans la base de données "maître". Une tentative de joindre une base de données nommée automatiquement pour le fichier HelloWorld.mdf a échoué
- 24. XMLHttpRequest et erreurs de certificat
- 25. Autorisation sp_helptext
- 26. Hadoop DFS Erreur d'autorisation
- 27. CreateObject ("WXZ.Agent.1", "RemoteServerName") Autorisation refusée. Comment un nom d'utilisateur et un mot de passe peuvent-ils être fournis?
- 28. Javascript XmlHttpRequest Problèmes
- 29. conversion XMLHttpRequest pour jsonp
- 30. Gérer XMLHttpRequest .NET
J'ai vérifié le fichier XML et même la réponse est venue bien quand je suis accès au fichier de mon Comme FileSystem locale C: /CallWebService.html – user42070