Bonjour,
Comme souvent, je dois reprendre un projet pour faire une évolution et le précédent développeur n'est plus dans la société.
J'ai un service WCF en C# qui appel un autre service WCF en VB. Celui en C# a donc un "Service Reference" vers celui en VB.
Cela marche actuellement en prod et recette, mais je ne comprends pas vraiment comment.
En effet, dans le service C#, nous avons des classDTO et la méthode en entrée est du genre Toto(classDTO1 class1, classDTO2 class2), alors que côté VB c'est du genre Toto(classType1 class1, classType2 class2).
Côté C# j'ai :
Et côté VB:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 [ServiceContract()] public interface IWcfService { [XmlSerializerFormat()] [OperationContract()] responseDTO Toto(classDTO1 class1, classDTO2 class2); } [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] public class WcfService: IWcfService { public reponseDTO Toto(classDTO1 class1, classDTO2 class2) { ... using(WcfServiceVB clientVB = new WcfServiceVB()) { responseDTO rep = clientVB.Toto(class1, class2); clientVB.Close(); } ... } } [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [XmlTypeAttribute(TypeName = "classType1", Namespace = "http://namespace/")] public class classDTO1 { [XmlElementAttribute(ElementName = "Prop1", IsNullable = true)] public string Prop1{ get; set; } } [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [XmlTypeAttribute(TypeName = "classType2", Namespace = "http://namespace/")] public class classDTO2 { [XmlElementAttribute(ElementName = "Prop1", IsNullable = true)] public string Prop1{ get; set; } } public class eligibiliteAOGOut { public DateTime CreaDate { get; set; } public string Message { get; set; } }
Du coup, je ne comprends pas comment il converti mes DTO en Type sans soucis.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 <ServiceContract()> _ Public Interface IWcfServiceVB <XmlSerializerFormat> <OperationContract()> Function Toto(ByVal class1 As classType1, ByVal class2 As classType2) As responseType End Interface Public Class WcfServiceVB Implements IWcfServiceVB Public Function Toto(class1 As classType1, devis As devisType) As eligibiliteAOGOut Implements ILBPNoriaWcfService.eligibiliteAOG ... Dim response as responseType ... End Function End Class <System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.33440"), System.SerializableAttribute(), System.Diagnostics.DebuggerStepThroughAttribute(), System.ComponentModel.DesignerCategoryAttribute("code"), System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://namespace/")> Partial Public Class classType1 <System.Xml.Serialization.XmlElementAttribute(IsNullable:=True)> Public Property Prop1() As String ... End Property End Class <System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.33440"), System.SerializableAttribute(), System.Diagnostics.DebuggerStepThroughAttribute(), System.ComponentModel.DesignerCategoryAttribute("code"), System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://namespace/")> Partial Public Class classType2 <System.Xml.Serialization.XmlElementAttribute(IsNullable:=True)> Public Property Prop1() As String ... End Property End Class Public Class responseType Public Property CreaDate As DateTime Public Property Message As String End Class
Si je met à jour le "Service Reference" en passant par Visual Studio (et en pointant sur le service VB existant en prod ou recette), il me modifie mon fichier Reference.cs (entre autre) et la solution ne compile plus. Il n'arrive plus à convertir le DTO en Type comme avant.
Le soucis étant que maintenant je dois rajouter une nouvelle méthode côté VB, qui sera appelée par une nouvelle méthode côté C#.
Si je met automatiquement à jour la référence, ça ne marche plus et si je modifie à la main le fichier Reference.cs pour lui ajouter ma nouvelle méthode, ça compile mais j'obtiens un message d'erreur à l’exécution:
Le message étant tellement explicite, je suis un peu perduUnexpected error, check with your administrator. Provide the incident number if any.(incident number bfbb876f-98ae-4b29-a405-11fdfe82c872
Description : Une exception non gérée s'est produite au moment de l'exécution de la demande Web actuelle. Contrôlez la trace de la pile pour plus d'informations sur l'erreur et son origine dans le code.
Détails de l'exception: System.ServiceModel.FaultException: Unexpected error, check with your administrator. Provide the incident number if any.(incident number bfbb876f-98ae-4b29-a405-11fdfe82c872
Une idée ?
Merci d'avance.
Partager