![](/img/trans.png)
[英]Scraping KnownType attributes during SvcUtil and WSDL Code generation
[英]svcutil fails to generate code from wsdl file
我工作的一家公司正在開發自己的內部解決方案,需要讓他們的客戶繼續使用 SOAP 服務的各種版本。
使用svcutil /sc *.wsdl *.xsd
出現錯誤;
svcutil /sc *.wsdl *.xsd
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 4.8.3928.0]
Copyright (c) Microsoft Corporation. All rights reserved.
Error: All parts of message in operation must either contain type or element.
Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.XmlSerializerMessageContractImporter
Error: Referenced type 'http://schemas.xmlsoap.org/soap/encoding/:Array' is only valid for encoded SOAP.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.xxxxxxxxxx.uk/myapp/']/wsdl:portType[@name='ProposalPortType']
Error: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://www.xxxxxxxxxx.uk/myapp/']/wsdl:portType[@name='ProposalPortType']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.xxxxxxxxxx.uk/myapp/']/wsdl:binding[@name='ProposalBinding']
Error: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://www.xxxxxxxxxx.uk/myapp/']/wsdl:binding[@name='ProposalBinding']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.xxxxxxxxxx.uk/myapp/']/wsdl:service[@name='Proposal-service']/wsdl:port[@name='ProposalPort']
Generating files...
Warning: No code was generated.
如果我從消息中刪除它
<part name="attachment" type="oneapp:ArrayOfBinary"/>
完整的信息
<message name="ProposalOutput">
<!-- This is the main message content which describes the Proposal -->
<part name="out" element="xsd1:Proposal"/>
<!-- There may be zero to many attachment parts -->
<!--<part name="attachment" type="oneapp:ArrayOfBinary"/>-->
</message>`
然后生成代碼,但是通過顯式刪除這些項目,我不完全確定我刪除了什么或它將對需要創建的新服務產生什么影響。
我的問題是,為什么這兩個項目會導致代碼生成失敗,我該怎么做才能修復它?
您的 WSDL 文檔是關於 Java WebService 的嗎?如果是,使用的 svcutil 命令應該如下所示:
svcutil *.wsdl *.xsd /language:C#
根據您提供的信息,我發現您沒有添加語言,可能會導致這個問題。
有關 svcutil 的更多信息,請參考以下鏈接:
https://docs.microsoft.com/en-us/dotnet/framework/wcf/servicemodel-metadata-utility-tool-svcutil-exe
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.