5

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
  • 8,161
  • 9
  • 45
  • 62
  • 1
    http://stackoverflow.com/questions/985320/wcf-how-to-generate-a-single-wsdl-document-without-wsdlimport might help – indiPy Oct 31 '12 at 09:42
  • 2
    Thanks, .NET 4.5 looks pretty handy with the inbuilt ?singleWsdl instead of ?wsdl – lko Oct 31 '12 at 09:57
  • I don't know how to choose the "answer". I used both @The Indian Programmer and @Kristof's answers to get a .cs file which can be programmed against (contains the service contracts and the DataContracts). I change the `schemaLocation="localfile.xsd"` and then used `wsdl.exe file.wsdl localfile.xsd localfile2.xsd localfile3.xsd` so basically they both helped me solve this. – lko Oct 31 '12 at 12:45
  • 2
    Dont use wsdl.exe, use svcutil.exe for generating proxy files – Kishore Kumar Nov 01 '12 at 06:59

2 Answers2

7

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.

Kishore Kumar
  • 12,675
  • 27
  • 97
  • 154
  • 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. – lko Nov 01 '12 at 07:29
  • Have you addeded all your xsd files to svcutil and thier link should presnet in wsdl also – Kishore Kumar Nov 01 '12 at 15:58
  • First I tried with the changed WSDL with these changes. `` 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) – lko Nov 02 '12 at 07:28
  • 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? – JabberwockyDecompiler Oct 27 '14 at 21:46
  • @JabberwockyDecompiler You have to download the WSDL file to your location machine using Save As menu from the browser. – Kishore Kumar Oct 28 '14 at 06:35
0

You could download the wsdl file from your localhost. To do this you can go to "http://localhost:xxx/MyService.svc?wsdl"
Based on this wsdl you can use the wsdl tool to generate a service proxy.
For more info on how to generate the proxy see this question

Community
  • 1
  • 1
Kristof
  • 3,267
  • 1
  • 20
  • 30