我正在尝试在Visual Studio 2010中使用C#的SOAP服务。我尝试了新建服务引用,但总是出现以下错误:
自定义工具错误:无法为服务引用“easyZM”生成代码。请检查其他错误和警告消息以获取详细信息。路径\Service References\serviceTest\Reference.svcmap
并伴随着以下警告:
警告13:自定义工具警告:无法导入wsdl:portType
详情:运行WSDL导入扩展时抛出了异常:System.ServiceModel.Description.DataContractSerializerMessageContractImporter
错误:找不到http://schemas.xmlsoap.org/wsdl/:putDkm的定义。缺少命名空间为http://schemas.xmlsoap.org/wsdl/的服务描述。
参数名称:名称
错误源XPath://wsdl:definitions[@targetNamespace='urn:Easy']/wsdl:portType[@name='EasyPort'] 路径\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>