您如何将 WCF WSDL 和 XSD 共享给没有访问服务的客户端(还)? [英] How do you share WCF WSDL and XSD's to a client without access to the service (yet)?

查看:15
本文介绍了您如何将 WCF WSDL 和 XSD 共享给没有访问服务的客户端(还)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试生成 WSDL,然后使用客户端手动生成在 WSDL 中找到的每个 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.

客户端收到以下错误:

文档已被理解,但无法处理.WSDL 文档包含无法解析的链接.下载http://localhost:xxxx/MyService.svc?xsd=xsd0"时出错.无法连接到远程服务器 无法建立连接,因为目标机器主动拒绝 127.0.0.1:xxxx

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

应该如何生成和共享服务 WSDL 和 XSD,以便它们可以开始编写客户端代码(无需访问服务 atm?

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

编辑WSDL/XSD 中与这些相关的问题

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/"/>

编辑 2:感谢 @The Indian Programmmer 我能够生成一个代理类来使用这个命令进行编程:

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(托管在本地 IIS 中)

"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)

推荐答案

首先通过运行您的服务浏览到您的 wsdl.

First browse to your wsdl by running your service.

然后分别浏览到 WSDL 中的所有 xsd 并将它们保存为 xsd 文件.

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

使用新的 xsd 相对路径更新您的 wsdl.. 只需将 xsd 的整个链接替换为其名称即可.

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

用相应的文件名替换 http://localhost:xxxx/MyService.svc?xsd=xsd0

<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>

更新:如何生成代理文件

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

所有文件都应该在同一个文件夹中.

All files should be in the same folder.

这篇关于您如何将 WCF WSDL 和 XSD 共享给没有访问服务的客户端(还)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆