简体   繁体   中英

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

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)

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM