Appel d'un web service en local avec html
Fermé
amateur_gadget
Messages postés
29
Date d'inscription
vendredi 1 juillet 2011
Statut
Membre
Dernière intervention
8 février 2012
-
3 juil. 2011 à 13:14
amateur_gadget Messages postés 29 Date d'inscription vendredi 1 juillet 2011 Statut Membre Dernière intervention 8 février 2012 - 3 juil. 2011 à 13:31
amateur_gadget Messages postés 29 Date d'inscription vendredi 1 juillet 2011 Statut Membre Dernière intervention 8 février 2012 - 3 juil. 2011 à 13:31
Bonjour tout le monde,
J'essaie depuis 2 jours de faire un appel à mon web service en local en utilisant html et ajax mais j'arrive jamais je sais pas c'est quoi le problème pouvez vous m'aider en me donnant un exemple pour l'appel du helloworld service ? Mercii d'avance
J'essaie depuis 2 jours de faire un appel à mon web service en local en utilisant html et ajax mais j'arrive jamais je sais pas c'est quoi le problème pouvez vous m'aider en me donnant un exemple pour l'appel du helloworld service ? Mercii d'avance
A voir également:
- Appel d'un web service en local avec html
- Appdata local - Guide
- Web office - Guide
- Nommez une application d'appel vidéo ou de visioconférence - Guide
- Appel inconnu - Guide
- Service spouleur - Guide
1 réponse
amateur_gadget
Messages postés
29
Date d'inscription
vendredi 1 juillet 2011
Statut
Membre
Dernière intervention
8 février 2012
4
3 juil. 2011 à 13:31
3 juil. 2011 à 13:31
Ok bien sur supposons que mon web service helloworld a comme adresse http://localhost:2049/HelloWorld/hello.asmx et sa réponse est sur l'adresse http://localhost:2049/HelloWorld/hello.asmx/HelloWorld mon code est :
<html>
<head>
<script>
function submitForm()
{
var xhr;
try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); }
catch (e)
{
try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); }
catch (e2)
{
try { xhr = new XMLHttpRequest(); }
catch (e3) { xhr = false; }
}
}
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4)
{ var doc = xhr.responseXML;
var element = doc.getElementsByTagName('root').item(0);
if(xhr.status == 200)
document.ajax.dyn.value= element.firstChild.data;
else
document.ajax.dyn.value= element.firstChild.data;
}
};
xhr.open( GET", "http://localhost:2049/HelloWorld/hello.asmx/HelloWorld", true);
xhr.send(null);
}
</script>
</head>
<body>
<FORM method="POST" name="ajax" action="http://localhost:2049/HelloWorld/hello.asmx">
<INPUT type="BUTTON" value="Submit" ONCLICK="submitForm()">
<INPUT type="text" name="dyn" value="">
</FORM>
</body>
</html>
<html>
<head>
<script>
function submitForm()
{
var xhr;
try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); }
catch (e)
{
try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); }
catch (e2)
{
try { xhr = new XMLHttpRequest(); }
catch (e3) { xhr = false; }
}
}
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4)
{ var doc = xhr.responseXML;
var element = doc.getElementsByTagName('root').item(0);
if(xhr.status == 200)
document.ajax.dyn.value= element.firstChild.data;
else
document.ajax.dyn.value= element.firstChild.data;
}
};
xhr.open( GET", "http://localhost:2049/HelloWorld/hello.asmx/HelloWorld", true);
xhr.send(null);
}
</script>
</head>
<body>
<FORM method="POST" name="ajax" action="http://localhost:2049/HelloWorld/hello.asmx">
<INPUT type="BUTTON" value="Submit" ONCLICK="submitForm()">
<INPUT type="text" name="dyn" value="">
</FORM>
</body>
</html>