begin process at 2010 07 31 05:08:37
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

ASP.Net

 > RECHERCHER LES VILLES SUIVANT LE CODEPOSTAL VIA UN WEBSERVICE

RECHERCHER LES VILLES SUIVANT LE CODEPOSTAL VIA UN WEBSERVICE


 Information sur la source

Note :
3 / 10 - par 2 personnes
3,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :ASP.Net Source .NET ( DotNet ) Classé sous :codepostal, postalcode, webservice, serviceweb, webservice Niveau :Initié Date de création :05/04/2004 Vu / téléchargé :16 827 / 423

Auteur : jesusonline

Ecrire un message privé
Site perso
Ce membre participe au partage de revenus publicitaires
Commentaire sur cette source (1)
Ajouter un commentaire et/ou une note


 Description

Ce code permet de trouver les villes en fonctions du code postal. Ce code fonctionne en France.

Le webservice utilisé se situe ici : http://www.e-naxos.com/scripts/enwscp.dll/wsdl/IOD CODESPOSTAUX

Je vous ai fait une petite classe et une dll qui permet de s'en servir tres facilement.

pour s'en servir il faut tout simplement mettre la dll dans votre dossier bin.

Voici un exemple :

Dim LesVilles As New Cyril.Utility.CodePostal(_CodePostal)
_Villes = LesVilles.GetVille

_villes sera un tableau de string contenant toutes les villes du code postal

j'ai fait une gestion des erreurs il reste surement qq bugs.

J'utilise dans le code une autre de mes classe : la classe validation pour valider le code postal vous trouverez le code ici : http://www.aspfr.com/code.aspx?ID=21651

Dans la dll il y a d'autre chose, ce qui nous interesse et la classe CodePostal qui se situe dans le Namespace Cyril.Utility

Je me sers également du namespace Cyril.Utility.Webservice et de sa classe IODCODESPOSTAUXservice qui est automatiquement généré par VS.net



Source

  • Namespace Cyril.Utility
  • ''' -----------------------------------------------------------------------------
  • ''' Project : Cyril
  • ''' Class : Utility.CodePostal
  • '''
  • ''' -----------------------------------------------------------------------------
  • ''' <summary>
  • ''' Cette classe met en relation le webservice
  • ''' http://www.e-naxos.com/scripts/enwscp.dll/wsdl/IODCODESPOSTAUX
  • ''' pour asp.net
  • '''
  • ''' </summary>
  • ''' <remarks>
  • ''' </remarks>
  • ''' <history>
  • ''' [DURAND Cyril] 02/04/2004 Created
  • ''' </history>
  • ''' -----------------------------------------------------------------------------
  • Public Class CodePostal
  • Private _CP As String
  • #Region "Exception"
  • Private Class NotValidCodePostalException
  • Inherits ArgumentException
  • Public Overrides ReadOnly Property Message() As String
  • Get
  • Return "Le code postal demandé était invalide"
  • End Get
  • End Property
  • End Class
  • Private Class NotFoundCodePostalException
  • Inherits ArgumentException
  • Public Overrides ReadOnly Property Message() As String
  • Get
  • Return "Le code postal demandé est introuvable"
  • End Get
  • End Property
  • End Class
  • #End Region
  • ''' -----------------------------------------------------------------------------
  • ''' <summary>
  • '''
  • ''' </summary>
  • ''' <param name="CP"> Code Postal de la ville recherché </param>
  • ''' <remarks>
  • ''' </remarks>
  • ''' <history>
  • ''' [DURAND Cyril] 31/03/2004 Created
  • ''' </history>
  • ''' -----------------------------------------------------------------------------
  • Public Sub New(ByVal CP As String)
  • _CP = CP
  • End Sub
  • Public ReadOnly Property GetVille() As String()
  • Get
  • Try
  • Dim Valid As New Cyril.Utility.Validation.StringValidation
  • If Valid.isCodePostal(_CP) Then
  • Dim LesVilles As New Webservice.IODCODESPOSTAUXservice
  • Dim sGetVille As String
  • sGetVille = LesVilles.GetTownForZip(_CP.ToString, "|")
  • sGetVille = Replace(sGetVille, _CP.ToString & "=", "")
  • GetVille = sGetVille.Split("|")
  • LesVilles.Dispose()
  • Else
  • Throw New NotValidCodePostalException
  • End If
  • Catch ex As NotValidCodePostalException
  • Throw New NotValidCodePostalException
  • Catch ex As Exception
  • Throw New NotFoundCodePostalException
  • End Try
  • End Get
  • End Property
  • Public ReadOnly Property GetPrefecture() As String
  • Get
  • Try
  • Dim Valid As New Cyril.Utility.Validation.StringValidation
  • If Valid.isCodePostal(_CP) Then
  • Dim LesVilles As New Webservice.IODCODESPOSTAUXservice
  • GetPrefecture = LesVilles.GetDepartmentAdminCenterForCode(GetDepartementNumber)
  • LesVilles.Dispose()
  • Else
  • Throw New NotValidCodePostalException
  • End If
  • Catch ex As NotValidCodePostalException
  • Throw New NotValidCodePostalException
  • Catch ex As Exception
  • Throw New NotFoundCodePostalException
  • End Try
  • End Get
  • End Property
  • Public ReadOnly Property GetDepartementNumber() As String
  • Get
  • Dim Valid As New Cyril.Utility.Validation.StringValidation
  • If Valid.isCodePostal(_CP) Then
  • Return Left(_CP, 2)
  • Else
  • Throw New NotValidCodePostalException
  • End If
  • End Get
  • End Property
  • Public ReadOnly Property GetDepartement() As String
  • Get
  • Try
  • Dim Valid As New Cyril.Utility.Validation.StringValidation
  • If Valid.isCodePostal(_CP) Then
  • Dim LesVilles As New Webservice.IODCODESPOSTAUXservice
  • GetDepartement = LesVilles.GetDepartmentForCode(GetDepartementNumber)
  • LesVilles.Dispose()
  • Else
  • Throw New NotValidCodePostalException
  • End If
  • Catch ex As NotValidCodePostalException
  • Throw New NotValidCodePostalException
  • Catch ex As Exception
  • Throw New NotFoundCodePostalException
  • End Try
  • End Get
  • End Property
  • End Class
  • End Namespace
Namespace Cyril.Utility

    ''' -----------------------------------------------------------------------------
    ''' Project	 : Cyril
    ''' Class	 : Utility.CodePostal
    ''' 
    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Cette classe met en relation le webservice 
    ''' http://www.e-naxos.com/scripts/enwscp.dll/wsdl/IODCODESPOSTAUX
    ''' pour asp.net
    ''' 
    ''' </summary>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	[DURAND Cyril]	02/04/2004	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public Class CodePostal

        Private _CP As String

#Region "Exception"
        Private Class NotValidCodePostalException
            Inherits ArgumentException

            Public Overrides ReadOnly Property Message() As String
                Get
                    Return "Le code postal demandé était invalide"
                End Get
            End Property
        End Class
        Private Class NotFoundCodePostalException
            Inherits ArgumentException

            Public Overrides ReadOnly Property Message() As String
                Get
                    Return "Le code postal demandé est introuvable"
                End Get
            End Property
        End Class
#End Region

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' 
        ''' </summary>
        ''' <param name="CP"> Code Postal de la ville recherché </param>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        ''' 	[DURAND Cyril]	31/03/2004	Created
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Public Sub New(ByVal CP As String)

            _CP = CP
        End Sub

        Public ReadOnly Property GetVille() As String()
            Get
                Try
                    Dim Valid As New Cyril.Utility.Validation.StringValidation
                    If Valid.isCodePostal(_CP) Then

                        Dim LesVilles As New Webservice.IODCODESPOSTAUXservice

                        Dim sGetVille As String
                        sGetVille = LesVilles.GetTownForZip(_CP.ToString, "|")
                        sGetVille = Replace(sGetVille, _CP.ToString & "=", "")

                        GetVille = sGetVille.Split("|")
                        LesVilles.Dispose()

                    Else
                        Throw New NotValidCodePostalException
                    End If

                Catch ex As NotValidCodePostalException
                    Throw New NotValidCodePostalException

                Catch ex As Exception
                    Throw New NotFoundCodePostalException

                End Try

            End Get
        End Property

        Public ReadOnly Property GetPrefecture() As String
            Get
                Try
                    Dim Valid As New Cyril.Utility.Validation.StringValidation
                    If Valid.isCodePostal(_CP) Then

                        Dim LesVilles As New Webservice.IODCODESPOSTAUXservice

                        GetPrefecture = LesVilles.GetDepartmentAdminCenterForCode(GetDepartementNumber)
                        LesVilles.Dispose()

                    Else
                        Throw New NotValidCodePostalException
                    End If

                Catch ex As NotValidCodePostalException
                    Throw New NotValidCodePostalException

                Catch ex As Exception
                    Throw New NotFoundCodePostalException

                End Try

            End Get
        End Property
        Public ReadOnly Property GetDepartementNumber() As String
            Get
                Dim Valid As New Cyril.Utility.Validation.StringValidation
                If Valid.isCodePostal(_CP) Then

                    Return Left(_CP, 2)

                Else
                    Throw New NotValidCodePostalException
                End If

            End Get
        End Property
        Public ReadOnly Property GetDepartement() As String
            Get
                Try
                    Dim Valid As New Cyril.Utility.Validation.StringValidation
                    If Valid.isCodePostal(_CP) Then

                        Dim LesVilles As New Webservice.IODCODESPOSTAUXservice

                        GetDepartement = LesVilles.GetDepartmentForCode(GetDepartementNumber)
                        LesVilles.Dispose()

                    Else
                        Throw New NotValidCodePostalException
                    End If

                Catch ex As NotValidCodePostalException
                    Throw New NotValidCodePostalException

                Catch ex As Exception
                    Throw New NotFoundCodePostalException

                End Try
            End Get
        End Property


    End Class

End Namespace

 Conclusion

J'ai encore pas vu de bug mais je suis pas sur à 100%

Je vais bientot mettre un composant qui sera composé d'un textbox et d'un dropdownlist mais en cours de finalisation donc patience

Vous pouvez trouver la version de la dll la plus recente ici : http://jesusonline.free.fr/Cyril/

Dans le zip il y a la dll les commentaires generé automatiquement pas VS.net et les fichiers de code

 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Sources du même auteur

Source avec Zip Source .NET (Dotnet) UTILISATION DE LA MÉTHODE SORT ET SORTDIRECTION AVEC UN GRID...
Source .NET (Dotnet) RESPONSE.FILTER : MANIPULATION DU STREAM DE SORTIE ASP.NET
Source avec Zip Source .NET (Dotnet) OPTIMISATION DE LA SERIALISATION JSON POUR LES LIST<T>
Source avec Zip Source .NET (Dotnet) CRAWLABLELINKBUTTON : UPDATEPANEL ET RÉFÉRENCEMENT
Source .NET (Dotnet) POSTBACKCONTROL - COMMUNICATION CLIENT/SERVEUR AVEC LES UPDA...

 Sources de la même categorie

Source avec Zip Source avec une capture Source .NET (Dotnet) GRIDVIEW WITH TREEVIEW AND CALLBACK par fredzool
Source avec Zip APPELLER UN WEBSERVICE DEPUIS JAVASCRIPT par fredzool
Source avec Zip Source .NET (Dotnet) MONEY TEXTBOX WITH EMBEDED JAVASCRIPT par fredzool
Source avec Zip Source .NET (Dotnet) UTILISATION DE LA MÉTHODE SORT ET SORTDIRECTION AVEC UN GRID... par jesusonline
Source avec Zip Source .NET (Dotnet) CUSTOM DATEPIKER DÉRIVANT DE COMPOSITECONTROL par fredzool

 Sources en rapport avec celle ci

Source avec Zip APPELLER UN WEBSERVICE DEPUIS JAVASCRIPT par fredzool
Source avec Zip Source avec une capture Source .NET (Dotnet) SERVICE WEB par bellow
Source avec Zip Source .NET (Dotnet) MODULE D'AUTHENTIFICATION POUR LES WEBSERVICES AJAX par jesusonline
Source avec Zip Source .NET (Dotnet) LIBRAIRIE DE TRADUCTION par tikrimi
Source avec Zip Source .NET (Dotnet) CONSOMMER UN SERVICE WEB par jesusonline

Commentaires et avis

Commentaire de arcollet le 05/04/2004 22:10:36

Merci pour vos codes

Denis

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

[Asp.Net][WebService] Consultation d'objet à distance [ par flagadda ] Bonjour,Un nouveau probleme se pose a moi, maintenant que j'arrive a rendre disponible, aux utilisateurs de mon ServiceWeb, les objets dont ils ont be Message d'attente de réponse webservice. [ par Randol ] Bonjour, j'utilise des composants clients et je souhaiterais pouvoir faire apparaître un message d'attente ou un gif animé pendant qu'un webservi passage de parametre entre siteweb et un webservice [ par Cisaks ] Bonjour j'ai un probleme lors de ma compilation de mon siteweb et de webservice il me met le message suivant:Une erreur s'est produite lors du télécha Télécharger un fichier zip [ par TTMan ] Bonjour,Je vous expose mon problème:Je consomme un webservice qui me permet de récupérer le lien vers un fichier zip contenant un xml que j'intègre da Gridview Webservice [ par cbu ] Bonjour,j'ai un gridview qui va être bindé sur un dataset.. Ce dataset m'est retourné par un Webservice.Si je veux faire les Editions et Suppressions Récupérer le WebService [ par Laurent_BGC ] Bonjour ,j'ai créé un webservice sur notre serveur "Server1" (WebService1.asmx)  et un autre sur mon c: (Webservice2.asmx) . Via un nouveau site créé récupérer un certificat x509 dans un webservice [ par zserge ] Bonjour,    J'appelle une méthode d'un webservice depuis une page aspx, mais je dois m'authentifier avec un certificat x509. J'instancie mon webservic utilisation d'un webservice ! [ par jimmy69 ] Bonjour,Je suis debutant sous c# 1.1 avec visualt studio 2003 et j'essayes d'utiliser un web service se trouvant ici :<font color="#22229c" Probleme AJAX Webservice [ par fredspv ] Bonjour,j'essaie d'appeler un webservice avec  asp:ScriptManager  mais j'ai tout le temps une erreur Java ajax+basede bonnée+autocomplétion [ par Shany ] Bonsoir,Dans le cadre d'une application, je souhaiterais réaliser une autocomplétion.J'utilise VS2005, je code en asp.net C# avec ajax en plus.J'ai vu


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Juillet 2010
LMMJVSD
   1234
567891011
12131415161718
19202122232425
262728293031 

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,232 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales