Monday, June 20, 2011

OSB WCF WSDL

When you export the WS resources from WCF you get these files:

results.discomap
PippoService.disco
PippoService.wsdl
PippoService.xsd
PippoService.zip
PippoService0.wsdl
PippoService0.xsd
PippoService1.xsd
PippoService2.xsd

The problem is that internally the WSDL and XSD don't refer to these filenames, but to the (horrible) syntax

<xsd:import schemaLocation="PippoService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />


Luckily they give you a MAP:

the content of PippoService.disco:

<?xml version="1.0" encoding="utf-8"?>
<DiscoveryClientResultsFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <Results>
   <DiscoveryClientResult referenceType="System.Web.Services.Discovery.SchemaReference" url="http://localhost:3720/PippoService.svc?xsd=xsd0" filename="PippoService.xsd" />
   <DiscoveryClientResult referenceType="System.Web.Services.Discovery.SchemaReference" url="http://localhost:3720/PippoService.svc?xsd=xsd2" filename="PippoService0.xsd" />
   <DiscoveryClientResult referenceType="System.Web.Services.Discovery.SchemaReference" url="http://localhost:3720/PippoService.svc?xsd=xsd3" filename="PippoService1.xsd" />
   <DiscoveryClientResult referenceType="System.Web.Services.Discovery.DiscoveryDocumentReference" url="http://localhost:3720/PippoService.svc?disco" filename="PippoService.disco" />
   <DiscoveryClientResult referenceType="System.Web.Services.Discovery.ContractReference" url="http://localhost:3720/PippoService.svc?wsdl" filename="PippoService.wsdl" />
   <DiscoveryClientResult referenceType="System.Web.Services.Discovery.ContractReference" url="http://localhost:3720/PippoService.svc?wsdl=wsdl0" filename="PippoService0.wsdl" />
   <DiscoveryClientResult referenceType="System.Web.Services.Discovery.SchemaReference" url="http://localhost:3720/PippoService.svc?xsd=xsd1" filename="PippoService2.xsd" />
 </Results>
</DiscoveryClientResultsFile>



so, for referenceType:
System.Web.Services.Discovery.ContractReference=WSDL
System.Web.Services.Discovery.SchemaReference=XSD
you build a map, then you must replace the schemaLocation with the filename in ALL our WSDL and XSDs.


For instance in the WSDL I have:

<wsdl:import namespace="http://ACME/Bla" location="PippoService.svc?wsdl=wsdl0"/>

this should become

<wsdl:import namespace="http://ACME/Bla" location="PippoService0.wsdl"/>



This is not all:
in PippoService0.wsdl we have:

 <wsdl:types>
   <xsd:schema targetNamespace="http://ACME/Bla">
     <xsd:import namespace="http://ACME/Mumble"/>
     <xsd:import namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
     <xsd:import namespace="http://ACME/Snort"/>
     <xsd:import namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
   </xsd:schema>
 </wsdl:types>


without any schemaLocation; To discover what to put as schemaLocation you must determine the targetNamespace for each XSD,
and add schemaLocation="PippoServiceX.xsd"  where X depends on the mentioned targetNamespace mapping.


All this can be (easily?) scripted, as we don't want to do this crap manually - we are no monkeys :o)





1 comment:

yvesT said...

I think overall, IT is still trying to espace its huge need for identifiers, and other domains do it much better, a bit ironic when its main purpose is processing them. Why not "restart" IT as a kind of "lisp world" with "administrative" IDs ISBN kind used as "memory locations" ?
More on this below :
http://iiscn.wordpress.com/about/
Or :
http://groups.google.com/group/fr.comp.lang.lisp/topics