Bonjour!
Un petit casse-tête d'appel de web service pour bien commencer la journée.
Je dois appeler le service suivant : https://ec.europa.eu/ws/sanco/xmlgatev2/acceptance?WSDL
En créant le proxy, (ou en examinant le WSDL) on se rend compte que la description est minimaliste. On a quatres methodes qui acceptent toutes un type "system.object" difficile de faire plus vague.
J'ai également recu avec la doc un exemple d'enveloppe soap :
Si on appelle le service avec soapui, ca marche, on a une réponse.
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 <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> <soapenv:Header> <sanco-xmlgate:Security xmlns:sanco-xmlgate="http://sasbos.ws.in.xmlgatev2.sanco.cec.eu"> <UsernameToken> <Username></Username> <Password></Password> </UsernameToken> </sanco-xmlgate:Security> </soapenv:Header> <soapenv:Body> <sanco-xmlgate:callServices xmlns:sanco-xmlgate="http://sasbos.ws.in.xmlgatev2.sanco.cec.eu"> <sanco-xmlgate:report document_key="05-part-671064" PDF_version="1" document_version="1" country="EU" xmlns:sanco-xmlgate="http://sawes.ws.in.xmlgatev2.sanco.cec.eu"> <sanco-xmlgate:xmlgate> <sanco-xmlgate:project id="172"/> <sanco-xmlgate:service name="CreateEntryService" method="createXMLEntry"/> <sanco-xmlgate:complex_validation method="createXMLEntry" name="CreateEntryService"/> </sanco-xmlgate:xmlgate> <sanco-xmlgate:consumerComplaints user_id="sam" month="05" part_id="part-671064" organisation_id="EU-0-txQ"> <sanco-xmlgate:complaint date="2011-05-11" id="A68321A0-945E-44C8-8323-74669871769F-0" reference="1727691-0"> <sanco-xmlgate:consumer_country>AT</sanco-xmlgate:consumer_country> <sanco-xmlgate:organisation_id>EU-0-txQ</sanco-xmlgate:organisation_id> <sanco-xmlgate:distinction>Complaint</sanco-xmlgate:distinction> <sanco-xmlgate:trader_country>BE</sanco-xmlgate:trader_country> <sanco-xmlgate:selling_method>Face-to-face</sanco-xmlgate:selling_method> <sanco-xmlgate:advertising_method>Phone call</sanco-xmlgate:advertising_method> <sanco-xmlgate:sector>Consumer Goods</sanco-xmlgate:sector> <sanco-xmlgate:market>Food - Meat</sanco-xmlgate:market> <sanco-xmlgate:classification_level_1>Redress</sanco-xmlgate:classification_level_1> </sanco-xmlgate:complaint> <sanco-xmlgate:complaint date="2011-05-11" id="EEC9EC3E-0A65-4946-8232-0128107DD74E-0" reference="2294140-0"> <sanco-xmlgate:consumer_country>BG</sanco-xmlgate:consumer_country> <sanco-xmlgate:organisation_id>EU-0-txQ</sanco-xmlgate:organisation_id> <sanco-xmlgate:distinction>Enquiry</sanco-xmlgate:distinction> <sanco-xmlgate:trader_country>BG</sanco-xmlgate:trader_country> <sanco-xmlgate:selling_method>Face-to-face: Discount store</sanco-xmlgate:selling_method> <sanco-xmlgate:advertising_method>Audiovisual (TV, etc.)</sanco-xmlgate:advertising_method> <sanco-xmlgate:sector>Financial Services</sanco-xmlgate:sector> <sanco-xmlgate:market>Financial Services - Credit (excluding mortgage/home loans)</sanco-xmlgate:market> <sanco-xmlgate:classification_level_1>Delivery of goods/ Provision of services</sanco-xmlgate:classification_level_1> </sanco-xmlgate:complaint> </sanco-xmlgate:consumerComplaints> </sanco-xmlgate:report> </sanco-xmlgate:callServices> </soapenv:Body> </soapenv:Envelope>
ce qui est normal car j'ai pas encore recu mes identifiants.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> <soapenv:Body> <ns:callServicesResponse xmlns:ns="http://sasbos.ws.in.xmlgatev2.sanco.cec.eu"> <ns:return> <sanco-xmlgate:response xmlns:sanco-xmlgate="http://sasbos.ws.in.xmlgatev2.sanco.cec.eu"> <sanco-xmlgate:message code="[SXG-005]">Your are not authenticated. Please send an email to <a href="mailto:sanco-xmlgate@ec.europa.eu">sanco-xmlgate@ec.europa.eu</a> with this error code.</sanco-xmlgate:message> <sanco-xmlgate:AuthenticationResponseValue>false</sanco-xmlgate:AuthenticationResponseValue> </sanco-xmlgate:response> </ns:return> </ns:callServicesResponse> </soapenv:Body> </soapenv:Envelope>
En C#, j'ai essayé ca :
où test.xml contient l'exemple ci-dessous. Ca donne rien du tout. J'ai une erreur comme quoi ce n'est pas une enveloppe valable.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 SASBOServiceSoap11Binding tmp = new SASBOServiceSoap11Binding(); tmp.Url = "https://ec.europa.eu/ws/sanco/xmlgatev2/acceptance?WSDL"; string test = File.ReadAllText("test.xml"); tmp.callServices(test);
Est-ce que quelqu'un saurait me dire comment on est sensé invoquer un tel service en .NET ?
Merci d'avance.
Partager