gpt4 book ai didi

c# - 无法添加网络引用

转载 作者:行者123 更新时间:2023-11-30 17:51:30 24 4
gpt4 key购买 nike

我正在尝试使用 C# 在 Visual Studio 2010 中使用 soap 服务。我去广告尝试新的服务引用,但我总是得到那个错误

Custom tool error: Failed to generate code for the service reference'easyZM'. Please check other error and warning messages fordetails. path\Service References\serviceTest\Reference.svcmap

那些警告:

Warning 13 Custom tool warning: Cannot import wsdl:portType

Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter

Error: Cannot find definition for http://schemas.xmlsoap.org/wsdl/:putDkm. Service Description with namespace http://schemas.xmlsoap.org/wsdl/ is missing.

Parameter name: name

XPath to Error Source: //wsdl:definitions[@targetNamespace='urn:Easy']/wsdl:portType[@name='EasyPort'] path\Service References\serviceTest\Reference.svcmap

我不知道该怎么办。我看过那个问题What does this WCF error mean: "Custom tool warning: Cannot import wsdl:portType"但那里提供的解决方案都不适合我。

wsdl 路径:https://ews.zav-mb.si/easy/wsdl/easy.wsdl

有什么想法吗?

其他人可以尝试报告他的结果吗?

我发现问题可能出在 wsdl 文件本身。但我不知道如何修复它。

<definitions xmlns:tns="urn:Easy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" name="Easy" targetNamespace="urn:Easy">
<types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Hello">
<xsd:element name="fileName" type="xsd:string"/>
<xsd:element name="fileContent" type="xsd:string"/>
<xsd:element name="fileSize" type="xsd:int"/>
<xsd:element name="easyDocRef" type="xsd:string"/>
<xsd:element name="message" type="xsd:string"/>
<xsd:element name="result" type="xsd:boolean"/>
</xsd:schema>
</types>

<message name="putDkm">
<part name="fileName" type="tns:fileName"/>
<part name="fileContentBase64Encoded" type="tns:fileContent"/>
<part name="fileSize" type="tns:fileSize"/>
</message>
<message name="putDkmResponse">
<part name="result" type="tns:result"/>
<part name="message" type="tns:message"/>
<part name="easyDocref" type="tns:easyDocRef"/>
</message>
<!-- get stuff -->
<message name="get">
<part name="easyDocRef" type="tns:getEasyDocRef"/>
</message>
<message name="getResponse">
<part name="result" type="tns:result"/>
<part name="message" type="tns:message"/>
<part name="fileContentBase64Encoded" type="tns:fileContent"/>
<part name="fileName" type="tns:fileName"/>
</message>
<portType name="EasyPort">
<operation name="putDkm">
<input message="putDkm"/>
<output message="tns:putDkmResponse"/>
</operation>
<operation name="get">
<input message="get"/>
<output message="tns:getResponse"/>
</operation>
</portType>
<binding name="EasyBinding" type="tns:EasyPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="putDkm">
<soap:operation soapAction="urn:putDkmAction"/>
<input>
<soap:body use="encoded" namespace="urn:Easy" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:Easy" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="get">
<soap:operation soapAction="urn:getAction"/>
<input>
<soap:body use="encoded" namespace="urn:Easy" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:Easy" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="EasyService">
<port name="EasyPort" binding="tns:EasyBinding">
<soap:address location="https://ews.zav-mb.si/easy/index.php"/>
</port>
</service>
</definitions>

最佳答案

WSDL 肯定有问题。我有同样的警告。然后我变了

<portType name="EasyPort">
<operation name="putDkm">
<input message="putDkm"/>
<output message="tns:putDkmResponse"/>
</operation>
<operation name="get">
<input message="get"/>
<output message="tns:getResponse"/>
</operation>
</portType>

<portType name="EasyPort">
<operation name="putDkm">
<input message="tns:putDkm"/>
<output message="tns:putDkmResponse"/>
</operation>
<operation name="get">
<input message="tns:get"/>
<output message="tns:getResponse"/>
</operation>
</portType>

(见命名空间)之后构建成功,但是没有生成客户端代码。我不打算修复所有问题,但我建议您首先创建一个具有相同接口(interface)的服务原型(prototype),生成它的 WSDL 并将结果与​​您目前的结果进行比较。

关于c# - 无法添加网络引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19318793/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com