How do you share WCF WSDL and XSD's to a client without access to the service (yet)?

19,437

First browse to your wsdl by running your service.

Then browse to all the xsd's in the WSDL seperately and save them as xsd files.

Update your wsdl with the new xsd relative path.. just replace the entire link for xsd by its name.

Replace http://localhost:xxxx/MyService.svc?xsd=xsd0 with respective FileName

<xsd:schema targetNamespace="namespace">
<xsd:import schemaLocation="Messages.xsd" namespace="namespace"/>
<xsd:import schemaLocation="DomainTypes.xsd" namespace="namespace"/>
<xsd:import schemaLocation="StreamBody.xsd" namespace="namespace"/>
</xsd:schema>

Updated : How to generate proxy files

svcutil  -noconfig -namespace:*,ServiceNameSpace -serializer:datacontractserializer  "Service.wsdl" "DomainTypes.xsd" "Messages.xsd" "StreamBody.xsd"

All files should be in the same folder.

Share:
19,437
lko
Author by

lko

Updated on June 11, 2022

Comments

  • lko
    lko almost 2 years

    I tried to generate the WSDL and then each XSD found within the WSDL manually with a client. The service is only on my localhost at the moment, and hasn't been published yet.

    The client is getting the following errors:

    The document was understood, but it could not be processed. The WSDL document contains links that could not be resolved. There was an error downloading 'http://localhost:xxxx/MyService.svc?xsd=xsd0'. Unable to connect to the remote server No connection could be made because the target machine actively refused it 127.0.0.1:xxxx

    How should the services WSDL and XSD's be generated and shared so they can begin coding the client (without accessing the service atm?

    Edit The issues relate to these in the WSDL/XSD

    WSDL

    <xsd:schema targetNamespace="http://tempuri.org/Imports">
        <xsd:import schemaLocation="http://localhost:xxxx/MyService.svc?xsd=xsd0" 
               namespace="http://tempuri.org/"/>
        <xsd:import schemaLocation="http://localhost:xxxx/MyService.svc?xsd=xsd1"  
               namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
        <xsd:import schemaLocation="http://localhost:xxxx/MyService.svc?xsd=xsd2" 
               namespace="**MYNAMESPACE**"/>
    </xsd:schema>
    

    XSD

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

    Edit 2: Thanks to @The Indian Programmmer I was able to generate a proxy class to program against with this command:

    "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\svcutil.exe" -noconfig -namespace:*,SERVICE.INTERFACE.NAMESPACE -serializer:datacontractserializer https://My-PC/SvrLocation/MyService.svc?wsdl (hosted in local IIS)

  • lko
    lko over 11 years
    Should the resultant .cs file contain the datacontracts? With WSDL.exe the .cs has all the XSDs (DataContract classes) and the Service (ServiceContract) which can be programmed against. When I tried this (svcutil) it only gave the ServiceContract, if you were to use this .cs then how would you program the DataContract classes (they are only in the XSDs)? Did something go wrong with the svcutil call.
  • Kishore Kumar
    Kishore Kumar over 11 years
    Have you addeded all your xsd files to svcutil and thier link should presnet in wsdl also
  • lko
    lko over 11 years
    First I tried with the changed WSDL with these changes. <xsd:import schemaLocation="Messages.xsd" namespace="namespace"/> That didn't include the DataContract classes in the proxy, so then I tried the svcutil with the other parameters above directly against the service. This generated a proxy class as expected. (still need to test it) "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\svcutil.exe" -noconfig -namespace:*,SERVICE.INTERFACE.NAMESPACE -serializer:datacontractserializer https://My-PC/SvrLocation/MyService.svc?wsdl (hosted in local IIS)
  • JabberwockyDecompiler
    JabberwockyDecompiler over 9 years
    This seems to be what I need but I am unable to figure out how to change the url/filename in my autogenerated WSDL file. How are you modifying the schemaLocation attribute?
  • Kishore Kumar
    Kishore Kumar over 9 years
    @JabberwockyDecompiler You have to download the WSDL file to your location machine using Save As menu from the browser.