Un fichier WSDL peut être "éclaté" en plusieurs fichiers grâce aux directives d'import :

  • wsdl:import : importation d'un autre fichier WSDL
  • xsd:import : importation d'un schéma XML.

Certains outils (dont Adélia Studio) n'accepte pas d'inscrire un service web à partir d'un fichier WSDL "éclaté".
Reconstruire un fichier WSDL unique (Flat WSDL) à partir de ces différentes origines/composantes est fastidieux.

Dans le SDK windows (à partir de windows 7), WCF (Windows Communication Fondation) offre un outil, nommé  svcutil.exe, qui permet de traiter cette opération.
La commande est la suivante :

svcutil /t:metadata urlService?singleWSDL
Le fichier est produit dans le répertoire courant.


Exemple :
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin>svcutil /t:metadata https://uat.centiro.com/Universe.Services/TMSBasic/Wcf/c1/i1/TMSBasic/TMSBasic.svc?singleWSDL

Note : Dans certains cas, le fichier WSDL produit, bien qu'unique, est refusé lors de l'inscription du service dans Adélia Studio car non conforme pour son parseur WSDL.
Cela arrive notamment  dans le cas d'un <wsdl:import> avec un targetNamespace différent dans chacun des fichiers WSDL sources.
Le targetNamespace du fichier WDL importé est conservé au détriment du targetNamespace du fichier maître.
Il faut alors, dans l'élément <wsdl:definitions> rétablir le bon targetNamespace et si besoin réaffecter les éléments dont le préfixe ne pointe pas sur le bon namespace.

Dans l'exemple donné, il faut rétablir le targetNamespace à "http://tempuri.org/" et déclarer un préfixe sur ce namespace (xmlns:uio="http://tempuri.org/") :

<wsdl:definitions xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://centiro.com/facade/tmsBasic/1/0/servicecontract" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TMSBasic" targetNamespace="http://tempuri.org/" xmlns:uio="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

Puis réaffecter les éléments qui ne sont pas qualifiés par le bon namespace  :

<wsdl:binding name="BasicHttpBinding_ITMSBasic" type="tns:ITMSBasic">
<wsdl:binding name="BasicHttpBinding_ITMSBasic" type="uio:ITMSBasic">

<wsdl:port name="BasicHttpBinding_ITMSBasic" binding="tns:BasicHttpBinding_ITMSBasic">
<wsdl:port name="BasicHttpBinding_ITMSBasic" binding="uio:BasicHttpBinding_ITMSBasic">

Pour requalifier correctement ces 2 éléments, le préfixe tns: ("http://centiro.com/facade/tmsBasic/1/0/servicecontract") est substitué par le nouveau préfixe uio:("http://tempuri.org/").






  • Aucune étiquette