Besoin d'aide
-
samedi 14 juillet 2012 13:40
Slt ts le monde.
Je suis en train de développer une application qui donnerra des informations sur un jeu.
Tout dabord je poste ici car je suis en train de faire une page web qui recuperera des informations sur les membres.
Mon application sera basé avec des web services. J'utilise windows Azure pour mettre le site ainsi que sa base de donnée en coordination avec le logiciel qui sera sous windows.
Mon probleme est : j'ai créé un mini site en Application Web ASP.NET MVC 3.
L'exemple pour la connection vers le webservice ma été donné en ASP et franchement dit je nage énormément. Je développer en PHP et la se nouveau language je ne le comprend pas très bien. J'ai bien quelques notions en C# mais je ne trouve pas comment faire les changement.
Alors voici le code recu :
''''''''''''''''''''' ' ' Initially the info needed to run the app is sent in a query string to the app ' ' Querystring UID = UserID (Entropia Life User ID of the user) ' Querystring TK = Session Token. This needs to be sent back to Entropia Life in some of the service methods (Store it in a session object!) ' Querystring AppID = This is your App ID (You should know this, but it is sent to you in the initial Querystring) ' ''''''''''''''''''''' userID = Request.QueryString("UID") token = Request.QueryString("TK") AppID = Request.QueryString("AID") ''''''''' ' ' If this is an internal postback then the variables you must use in this app will be empty at this point. ' hence, use the session variables. ' ''''''''' if len(userID) < 1 then userID = session("UID") token = session("TK") AppID = session("AID") end if if len(userID) > 0 then session("UID") = userID session("TK") = token session("AID") = AppID '''''''''''''''''''''''''' ' ' Get the user info for the user making the request. ' '''''''''''''''''''''''''' DataToSend="userID="& userID &"&appID="& AppID &"&appKey=*************" postUrl = "http://entropialife.com/webservices/appservice.asmx/getUser" Set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP") xmlhttp.Open "POST",postUrl,false xmlhttp.setRequestHeader "Content-Type","application/x-www-form-urlencoded" xmlhttp.send DataToSend Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM") xmlDoc.async = False xmlDoc.load (xmlhttp.responseXML) avatarName = xmlDoc.selectSingleNode("//AppUser/AvatarName").text userEmail = xmlDoc.selectSingleNode("//AppUser/Email").text userLocation = xmlDoc.selectSingleNode("//AppUser/currentLocationName").text %>et voici le code que j'ai deja un peu adapter en C# :
<!-- ''''''''''''''''''''' ' ' Initially the info needed to run the app is sent in a query string to the app ' ' Querystring UID = UserID (Entropia Life User ID of the user) ' Querystring TK = Session Token. This needs to be sent back to Entropia Life in some of the service methods (Store it in a session object!) ' Querystring AppID = This is your App ID (You should know this, but it is sent to you in the initial Querystring) ' '''''''''''''''''''''--> @{ var userID = Request.QueryString["UID"]; var token = Request.QueryString["TK"]; var AppID = Request.QueryString["AID"]; } <!--''''''''' ' ' If this is an internal postback then the variables you must use in this app will be empty at this point. ' hence, use the session variables. ' '''''''''--> @{ if (userID == null ){ userID = Session["UID"].ToString(); token = Session["TK"].ToString(); AppID = Session["AID"].ToString(); } else { Session["UID"] = userID; Session["TK"] = token; Session["AID"] = AppID; } } <!--'''''''''''''''''''''''''' ' ' Get the user info for the user making the request. ' ''''''''''''''''''''''''''--> @{ var DataToSend = ""; var postUrl =""; DataToSend="userID=" + userID + "&appID=" + AppID + "&appKey=**********"; postUrl = "http://entropialife.com/webservices/appservice.asmx/getUser"; Set xmlhttp = Server.Createobject("MSXML2.ServerXMLHTTP"); xmlhttp.Open "POST",postUrl,false; xmlhttp.setRequestHeader "Content-Type","application/x-www-form-urlencoded"; xmlhttp.send DataToSend; Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM"); xmlDoc.async = False; xmlDoc.load (xmlhttp.responseXML); avatarName = xmlDoc.selectSingleNode("//AppUser/AvatarName").text; userEmail = xmlDoc.selectSingleNode("//AppUser/Email").text; userLocation = xmlDoc.selectSingleNode("//AppUser/currentLocationName").text;La ou je bute pour transformer le code c'est sur cette partie du code :
var DataToSend = ""; var postUrl =""; DataToSend="userID=" + userID + "&appID=" + AppID + "&appKey=***********"; postUrl = "http://entropialife.com/webservices/appservice.asmx/getUser"; Set xmlhttp = Server.Createobject("MSXML2.ServerXMLHTTP"); xmlhttp.Open "POST",postUrl,false; xmlhttp.setRequestHeader "Content-Type","application/x-www-form-urlencoded"; xmlhttp.send DataToSend; Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM"); xmlDoc.async = False; xmlDoc.load (xmlhttp.responseXML);
Si vous pourriez m'aiguiller sur des solutions je suis preneur.- Modifié Sector4 samedi 14 juillet 2012 18:14
Toutes les réponses
-
dimanche 15 juillet 2012 22:44Modérateur
Bonjour,
Il suffit d'ajouter une référence COM à MSXML2 dans votre projet C#.
Ensuite il suffit de mettre le code suivant :
var DataToSend = ""; var postUrl =""; DataToSend="userID=" + userID + "&appID=" + AppID + "&appKey=***********"; postUrl = "http://entropialife.com/webservices/appservice.asmx/getUser"; var xmlhttp = new MSXML2.ServerXMLHTTP(); xmlhttp.open( "POST",postUrl,false); xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); xmlhttp.send( DataToSend); var xmlDoc = new MSXML2.DOMDocument(); xmlDoc.async = false; xmlDoc.load (xmlhttp.responseXMLCordialement
Gilles TOURREAU - MVP C#
Architecte logiciel/Consultant/Formateur Freelance
Blog : http://gilles.tourreau.fr
- MCPD : Enterprise Developper / Windows Developper 3.5 / ASP .NET 3.5/4.0
- MCITP : SQL Server 2008 Developper
- MCTS : ADO .NET 3.5 / SQL Server 2008 Developper / Windows Forms 3.5 / ASP .NET 3.5/4.0- Marqué comme réponse Sector4 lundi 16 juillet 2012 11:02
-
lundi 16 juillet 2012 11:04
Merci Gille.
Ca fonctionne Nicquel.
Pour info il faut télécharger le MSXML 4 service pack 2 pour pouvoir ajouter la référence a l'adresse suivante :
http://www.microsoft.com/fr-fr/download/details.aspx?id=19662

