Partage
  • Partager sur Facebook
  • Partager sur Twitter

[C#] Utilisation d'un wsdl

Wsdl / C# - Retour null

    23 juin 2011 à 10:12:19

    Hello les zéros,

    Je tiens à signaler que je connait très peu le C# mais je souhaite juster tester si le wsdl que j'ai crée est fonctionnel.

    J'ai donc dans un premier temps généré la class en utilisant la commande wsdl. Je vous passe les détails de la ré-écriture du wsdl en "litéral", bref la génération se passe correctement et sans erreurs !

    J'importe dans Visual Studio, j'appelle ma méthode seulement je n'ai aucun retour (du moins le résultat est "vide")

    J'ai ajouté une fonction de "log" dans mon fichier php (qui est appelé par le wsdl) et hormis le fait qu'un objet au lieu d'un array soit envoyé les paramètres sont correctes. Mais en aucun cas j'arrive a récupérer en c# le return de ma fonction...

    Pour info j'ai testé pas mal de méthodes et j'ai passé beaucoup de temps sur le sujet mais vraiment impossible de trouver...

    L'adresse du wsdl est la suivante : http://api.sms-pas-cher.com/api-dtw-1.0.wsdl

    La classe générée via le wsdl.exe :

    //------------------------------------------------------------------------------
    // <auto-generated>
    //     Ce code a été généré par un outil.
    //     Version du runtime :2.0.50727.3620
    //
    //     Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
    //     le code est régénéré.
    // </auto-generated>
    //------------------------------------------------------------------------------
    
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Xml.Serialization;
    
    // 
    // Ce code source a été automatiquement généré par wsdl, Version=2.0.50727.3038.
    // 
    
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="smspascherBiding", Namespace="http://api.sms-pas-cher.com/api-dtw-1.0.wsdl")]
    public partial class smspascherService : System.Web.Services.Protocols.SoapHttpClientProtocol {
        
        private System.Threading.SendOrPostCallback getApiKeyOperationCompleted;
        
        private System.Threading.SendOrPostCallback loginOperationCompleted;
        
        /// <remarks/>
        public smspascherService() {
            this.Url = "http://api.sms-pas-cher.com/api-dtw-1.0.php";
        }
        
        /// <remarks/>
        public event getApiKeyCompletedEventHandler getApiKeyCompleted;
        
        /// <remarks/>
        public event loginCompletedEventHandler loginCompleted;
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="http://api.sms-pas-cher.com/api-dtw-1.0.wsdl", ResponseNamespace="http://api.sms-pas-cher.com/api-dtw-1.0.wsdl", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        [return: System.Xml.Serialization.XmlElementAttribute("return")]
        public string getApiKey([System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string identifiant, [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string password) {
            object[] results = this.Invoke("getApiKey", new object[] {
                        identifiant,
                        password});
            return ((string)(results[0]));
        }
        
        /// <remarks/>
        public System.IAsyncResult BegingetApiKey(string identifiant, string password, System.AsyncCallback callback, object asyncState) {
            return this.BeginInvoke("getApiKey", new object[] {
                        identifiant,
                        password}, callback, asyncState);
        }
        
        /// <remarks/>
        public string EndgetApiKey(System.IAsyncResult asyncResult) {
            object[] results = this.EndInvoke(asyncResult);
            return ((string)(results[0]));
        }
        
        /// <remarks/>
        public void getApiKeyAsync(string identifiant, string password) {
            this.getApiKeyAsync(identifiant, password, null);
        }
        
        /// <remarks/>
        public void getApiKeyAsync(string identifiant, string password, object userState) {
            if ((this.getApiKeyOperationCompleted == null)) {
                this.getApiKeyOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetApiKeyOperationCompleted);
            }
            this.InvokeAsync("getApiKey", new object[] {
                        identifiant,
                        password}, this.getApiKeyOperationCompleted, userState);
        }
        
        private void OngetApiKeyOperationCompleted(object arg) {
            if ((this.getApiKeyCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.getApiKeyCompleted(this, new getApiKeyCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="http://api.sms-pas-cher.com/api-dtw-1.0.wsdl", ResponseNamespace="http://api.sms-pas-cher.com/api-dtw-1.0.wsdl", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        [return: System.Xml.Serialization.XmlElementAttribute("loginReturn")]
        public string login([System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string key) {
            object[] results = this.Invoke("login", new object[] {
                        key});
            return ((string)(results[0]));
        }
        
        /// <remarks/>
        public System.IAsyncResult Beginlogin(string key, System.AsyncCallback callback, object asyncState) {
            return this.BeginInvoke("login", new object[] {
                        key}, callback, asyncState);
        }
        
        /// <remarks/>
        public string Endlogin(System.IAsyncResult asyncResult) {
            object[] results = this.EndInvoke(asyncResult);
            return ((string)(results[0]));
        }
        
        /// <remarks/>
        public void loginAsync(string key) {
            this.loginAsync(key, null);
        }
        
        /// <remarks/>
        public void loginAsync(string key, object userState) {
            if ((this.loginOperationCompleted == null)) {
                this.loginOperationCompleted = new System.Threading.SendOrPostCallback(this.OnloginOperationCompleted);
            }
            this.InvokeAsync("login", new object[] {
                        key}, this.loginOperationCompleted, userState);
        }
        
        private void OnloginOperationCompleted(object arg) {
            if ((this.loginCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.loginCompleted(this, new loginCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }
        
        /// <remarks/>
        public new void CancelAsync(object userState) {
            base.CancelAsync(userState);
        }
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
    public delegate void getApiKeyCompletedEventHandler(object sender, getApiKeyCompletedEventArgs e);
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    public partial class getApiKeyCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        internal getApiKeyCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        /// <remarks/>
        public string Result {
            get {
                this.RaiseExceptionIfNecessary();
                return ((string)(this.results[0]));
            }
        }
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
    public delegate void loginCompletedEventHandler(object sender, loginCompletedEventArgs e);
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    public partial class loginCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        internal loginCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        /// <remarks/>
        public string Result {
            get {
                this.RaiseExceptionIfNecessary();
                return ((string)(this.results[0]));
            }
        }
    }
    


    Et mon program.cs :

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
    
                smspascherService soapi = new smspascherService();
    
                string aze = soapi.login("test");
    
                Console.WriteLine("'" + aze + "'");
    
                Console.ReadLine();
                 
            }
        }
    }
    


    Merci beaucoup de votre aide !

    PS : le wsdl en question a été généré "a la main", j'ai testé avec zend et même soucis. ;)
    • Partager sur Facebook
    • Partager sur Twitter
    Recherche des annonceurs incentive pour diffuser sur http://www.envoyer-sms-gratuit.net - Contactez-moi !

    [C#] Utilisation d'un wsdl

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown