wcf - 如何让 WCF 与此 Web 服务对话?

标签 wcf web-services wsdl svcutil.exe

这是 this question 的后续内容.

按照建议by @Benjamin here ,我现在尝试为我的 wsdl 添加服务引用(而不是 Web 引用)。以下是相关 wsdl 的 url:

https://eu.link.fiatauto.com/tsi/DDUWsAut.php?wsdl

问题是 Visual Studio 生成了一个空代码文件:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.3603
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace test.ServiceReference1 {

}

当我尝试使用 svcutil 手动生成代码时,我得到以下信息:

C:\temp>svcutil https://eu.link.fiatauto.com/tsi/DDUWsAut.php?wsdl
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.2152]
Copyright (c) Microsoft Corporation.  All rights reserved.

Attempting to download metadata from 'https://eu.link.fiatauto.com/tsi/DDUWsAut.
php?wsdl' using WS-Metadata Exchange or DISCO.
Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.Se
rviceModel.Description.XmlSerializerMessageContractImporter
Error: The ' ' character, hexadecimal value 0x20, cannot be included in a name.
Parameter name: name
XPath to Error Source: //wsdl:definitions[@targetNamespace='urn:ddu']/wsdl:portT
ype[@name='dduPortType']


Error: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is de
pendent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='urn:ddu']/wsdl:port
Type[@name='dduPortType']
XPath to Error Source: //wsdl:definitions[@targetNamespace='urn:ddu']/wsdl:bindi
ng[@name='dduBinding']


Error: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is depend
ent on.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='urn:ddu']/wsdl:bindi
ng[@name='dduBinding']
XPath to Error Source: //wsdl:definitions[@targetNamespace='urn:ddu']/wsdl:servi
ce[@name='ddu']/wsdl:port[@name='dduPort']


Generating files...
Warning: No code was generated.
If you were trying to generate a client, this could be because the metadata docu
ments did not contain any valid contracts or services
or because all contracts/services were discovered to exist in /reference assembl
ies. Verify that you passed all the metadata documents to the tool.

Warning: If you would like to generate data contracts from schemas make sure to
use the /dataContractOnly option.

也许这也与尝试通过添加 Web 引用而不是服务引用来使用该服务时出现问题有关(请参阅我的 other question )?

我猜那个 wsdl 有问题,但我找不到到底是什么问题。

由于这是一个已经被其他人使用的第三方服务,我认为他们不会愿意更改他们的服务,那么有没有任何解决方法可以让 .NET 与该 Web 服务对话?

最佳答案

WSDL 中存在错误。 dduAbortRequest 消息的最后部分在名称末尾有一个空格。这可能只是一个错误。告诉他们这个问题,他们会修复它,他们会感谢您告诉他们。

WSDL 本身就是无效的。

<message name="dduAbortRequest">
    <part name="Ticket" type="xsd:string"/>
    <part name="ServiceId" type="xsd:string"/>
    <part name="LoginId" type="xsd:string"/>
    <part name="DocId " type="xsd:string"/> <!-- Should be "DocId" -->
</message>

关于wcf - 如何让 WCF 与此 Web 服务对话?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1954805/

相关文章:

java - 如何使用 JBOSS 调用 Java Web 服务

web-services - maven jax-ws 插件不会从 wsdl 生成客户端类

wcf - SoapUI wsdl wcf net.tcp 缺少导入程序

c# - 无法启动 IIS Express

wcf - WCF 中的另一个应用程序正在使用的端口

web-services - Cyber​​Source 没有 WS-Security header 问题

soap - WildFly 8.2.0,使用反向代理的 JBossWS 生成不正确的 httpssoap :address

c# - 无法将类型 System.Collections.ObjectModel.ObservableCollection<> 隐式转换为 System.Collections.Generic.List<>

c# - 如何在 C# 中从 Windows/wcf 服务获得最佳性能?

asp.net - 是什么限制了我的 ASP.NET 应用程序可以与 Web 服务建立的同时连接数?