Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

wsdl

wcf

xsd

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)

like image 573
lko Avatar asked Oct 31 '12 09:10

lko


1 Answers

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.

like image 127
Kishore Kumar Avatar answered Nov 15 '22 00:11

Kishore Kumar