C# 使用复杂节点自动生成的WSDL与服务请求不匹配
我有这个WSDLC# 使用复杂节点自动生成的WSDL与服务请求不匹配,c#,xml,web-services,wsdl,asmx,C#,Xml,Web Services,Wsdl,Asmx,我有这个WSDL <s:element name="IncidentCreated"> <s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="IncidentCreatedStc" type="tns:IncidentCreatedStc" /> </s:seq
<s:element name="IncidentCreated">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="IncidentCreatedStc" type="tns:IncidentCreatedStc" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="IncidentCreatedStc">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="CreationDate" type="s:dateTime" />
<s:element minOccurs="1" maxOccurs="1" name="DangerFlag" nillable="true" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="DeadDeviceAlias" nillable="true" type="s:string" />
</s:sequence>
</s:complexType>
我在c#中自动生成服务引用(WSDL),如下所示:
<wsdl:definitions targetNamespace="ENMAC/TCS" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="ENMAC/TCS" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="ENMAC/TCS">
<s:element name="IncidentCreated">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="CreationDate" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="DangerFlag" nillable="true" type="s:int"/>
<s:element minOccurs="0" maxOccurs="1" name="DeadDeviceAlias" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
节点IncidentCreatedStc从未被创建过,我实际上并不认为它会被创建,问题是当我从服务接收到XML时,它看起来是这样的
<IncidentCreated>
<IncidentCreatedStr>
<CreationDate></CreationDate>
<DangerFlag></DangerFlag>
<DeadDeviceAlias></DeadDeviceAlias>
</IncidentCreatedStr>
</IncidentCreated>
我的问题是如何使我的soap服务符合最后一种格式?ASMX是一种遗留技术,不应用于新的开发。WCF或ASP.NET Web API应用于Web服务客户端和服务器的所有新开发。一个提示:微软已经取消了MSDN上的WSDL。你到底是如何“自动生成”这个WSDL的?您是如何基于原始WSDL创建类的?我在c#中使用了“添加服务引用”,并指向我收到的WSDL,我无法从我的机器访问服务来指向它。我将尽快将服务更新到WCF,不幸的是,当我第一次开发应用程序时,我只是基于我在这里找到的旧服务。但是谢谢你的提示。