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

妖精的绣舞 提交于 2019-12-21 05:02:48

问题


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)


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/13154726/how-do-you-share-wcf-wsdl-and-xsds-to-a-client-without-access-to-the-service-y

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!