在我创建的WSDL上运行wsdl.exe时,出现此错误:
错误:无法从命名空间'SomeNS'导入绑定'SomeBinding'。
- 无法导入操作'someOperation'。
- 这些成员可能不是派生的。
我正在使用文档 - 文字样式,据我所知,我遵守所有规则。
总结一下,我有一个有效的WSDL,但该工具不喜欢它。
我正在寻找的是,如果有人对wsdl.exe工具有很多经验,并且知道一些我不知道的秘密问题。
我遇到了同样的错误消息。 挖了一会儿后,发现除了wsdl文件之外还可以提供xsd文件。 因此,除了wsdl命令末尾的.wsdl之外,还包括/导入.xsd文件,如下所示:
wsdl.exe myWebService.wsdl myXsd1.xsd myType1.xsd myXsd2.xsd ...
Wsdl给出了一些警告,但确实创建了一个ok服务界面。
有时你必须改变你的代码。 消息部分名称不应该相同;)
<wsdl:message name="AnfrageRisikoAnfrageL">
<wsdl:part name="parameters" element="his1_0:typeIn"/>
</wsdl:message>
<wsdl:message name="AnfrageRisikoAntwortL">
<wsdl:part name="parameters" element="his1_0:typeOut"/>
</wsdl:message>
对此:
<wsdl:message name="AnfrageRisikoAnfrageL">
<wsdl:part name="in" element="his1_0:typeIn"/>
</wsdl:message>
<wsdl:message name="AnfrageRisikoAntwortL">
<wsdl:part name="out" element="his1_0:typeOut"/>
</wsdl:message>
@thehhv解决方案是正确的。 有一些解决方法,不需要您手动添加xsd
。
转到你的服务,而不是去?wsdl
转到?singleWsdl
(截图如下)
然后将页面保存为.wsdl
文件(它将提供.svc
以便更改它)
然后打开Visual studio command prompt
你可以在(Win 7)开始 - >所有程序 - > Visual Studio 2013 - > Visual Studio工具 - > VS2013 x64 Native Tools命令提示符(可能是某些东西)中找到它
然后在Visual studio command prompt
运行以下命令(而不是C:\\ WebPricingService.wsdl是保存wsdl的地方,除非我们认为非常相似并且选择相同的文件名和位置令人担忧)
wsdl.exe C:\WebPricingService.wsdl
它会给你一些警告,如@thehhv所说,但仍然在C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\bin\\amd64\\WebPricingService.cs
生成客户端(或者将它放在你的机器上的任何地方 - 检查控制台输出,其中显示“写入文件”)
希望这能为您节省一些时间。
在我的情况下,问题是不同的, 这里有很好的描述:
每当部件名称为“参数”时,使用.Net假定doc / lit / wrapped并相应地生成代理。 即使使用“参数”一词,wsdl也不是doc / lit / wrapped(如上例所示).Net可能会给我们一些错误。 哪个错误? 你猜对了:“这些成员可能不是派生的”。 现在我们可以理解错误的含义:.Net尝试省略根元素,因为它认为使用了doc / lit / wrapped。 但是这个元素不能被删除,因为它不是虚拟的 - 它应该由用户从一些派生类型中主动选择。
修复如下,并为我完美工作:
修复它的方法是在文本编辑器中打开wsdl并将部件名称从“parameters”更改为“parameters1” 。 现在.Net将知道生成doc / lit / bare代理。 这意味着新的包装类将作为代理中的根参数出现。 虽然这可能是一个更乏味的api,但这不会对有线格式产生任何影响,代理也可以完全互操作。
(我强调)
如果有人碰到这堵墙,这就是造成我案件错误的原因:
我有一个手术:
<wsdl:operation name="FormatReport">
<wsdl:documentation>Runs a report, which is returned as the response</wsdl:documentation>
<wsdl:input message="FormatReportRequest" />
<wsdl:output message="FormatReportResponse" />
</wsdl:operation>
需要输入:
<wsdl:message name="FormatReportRequest">
<wsdl:part name="parameters" element="reporting:FormatReportInput" />
</wsdl:message>
和另一个操作:
<wsdl:operation name="FormatReportAsync">
<wsdl:documentation>Creates and submits an Async Report Job to be executed asynchronously by the Async Report Windows Service.</wsdl:documentation>
<wsdl:input message="FormatReportAsyncRequest" />
<wsdl:output message="FormatReportAsyncResponse" />
</wsdl:operation>
接受输入:
<wsdl:message name="FormatReportAsyncRequest">
<wsdl:part name="parameters" element="reporting:FormatReportInputAsync" />
</wsdl:message>
输入元素是两种类型的实例:
<xsd:element name="FormatReportInput" type="reporting:FormatReportInputType"/>
<xsd:element name="FormatReportInputAsync" type="reporting:FormatReportAsyncInputType"/>
以下是catch - reporting:FormatReportAsyncInputType
类型扩展(派生自) reporting:FormatReportInputType
类型。 这似乎混淆了工具并导致“这些成员可能无法派生”。 错误。 您可以在接受的答案中解决以下建议。
如果您使用UPS Shipping wsdl执行此操作,并且您希望在为不同区域(debug,dev,prod)等构建时将dev交换为prod URL。您可以使用以下命令从中生成vb或C#文件Ship.wsdl然后覆盖此情况下Ship.vb文件中的值。
WSDL /Language:VB /out:"C:\wsdl\Ship.vb" "C:\wsdl\Ship.wsdl" C:\wsdl\UPSSecurity.xsd C:\wsdl\ShipWebServiceSchema.xsd C:\wsdl\IFWS.xsd C:\wsdl\common.xsd