在我创建的WSDL上运行wsdl.exe时,出现此错误:
错误:无法从命名空间'SomeNS'导入绑定'SomeBinding'。
- 无法导入操作'someOperation'。
- 这些成员可能不是派生的。
我正在使用文档 - 文字样式,据我所知,我遵循所有规则。
总结一下,我有一个有效的WSDL,但该工具不喜欢它。
我正在寻找的是,如果有人对wsdl.exe工具有很多经验,并且知道一些我不知道的秘密问题。
答案 0 :(得分:47)
我遇到了同样的错误消息。挖了一会儿后,发现除了wsdl文件之外还可以提供xsd文件。因此,除了wsdl命令末尾的.wsdl之外,还包含/导入.xsd文件,如下所示:
wsdl.exe myWebService.wsdl myXsd1.xsd myType1.xsd myXsd2.xsd ...
Wsdl给出了一些警告,但确实创建了一个ok服务界面。
答案 1 :(得分:8)
有时你必须改变你的代码。 消息部分名称不应该相同;)
<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>
答案 2 :(得分:4)
@thehhv解决方案是正确的。有一种解决方法,不需要您手动添加xsd
。
转到您的服务然后转到?wsdl
转到?singleWsdl
(下面的屏幕截图)
然后将页面保存为.wsdl
文件(它将提供.svc
以进行更改)
然后打开Visual studio command prompt
你可以在(Win 7)开始 - &gt;中找到它所有程序 - &gt; Visual Studio 2013 - &gt; Visual Studio工具 - &gt; VS2013 x64原生工具命令提示符(可能是类似的东西)
然后在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
生成客户端(或者将它放在你的机器上的任何地方 - 检查控制台输出,其中它写着'写文件')
希望这可以节省你一些时间。
答案 3 :(得分:3)
就我而言,问题是不同的,并且有很好的描述here:
每当零件的名称是&#34;参数&#34;使用.Net假定doc / lit / wrapped并相应地生成代理。即使单词&#34;参数&#34;使用wsdl不是doc / lit / wrapped(如上例所示).Net可能会给我们一些错误。哪个错误?你猜错了:&#34;这些成员可能不是派生的&#34;。现在我们可以理解错误的含义:.Net尝试省略根元素,因为它认为使用了doc / lit / wrapped。但是这个元素不能被删除,因为它不是虚拟的 - 它应该由用户从一些派生类型中主动选择。
修复方法如下,对我来说非常合适:
修复它的方法是在文本编辑器中打开wsdl并将部件名称从&#34;参数&#34; 更改为&#34; parameters1&#34; < / strong>即可。现在.Net将知道生成doc / lit / bare代理。这意味着新的包装类将作为代理中的根参数出现。虽然这可能是一个更乏味的api,但这不会对有线格式产生任何影响,代理也可以完全互操作。
(我强调)
答案 4 :(得分:0)
如果有人碰到这堵墙,这就是造成我错误的原因:
我有一个手术:
<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
类型。这似乎使工具混淆并导致&#34;这些成员可能无法派生。&#34;错误。您可以在接受的答案中找到以下建议。
答案 5 :(得分:0)
如果要使用UPS Shipping wsdl进行此操作,并且要在为不同区域(调试,dev,prod)等进行构建时希望将dev交换为产品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