我试图在c#中找到这个基于WSDL的服务有什么问题。
WSDL包含大量信息,但与相关方法相关的信息如下所示:
<wsdl:operation name="GetStock">
<wsdl:input message="tns:GetStockRequest"/>
<wsdl:output message="tns:GetStockResponse"/>
</wsdl:operation>
<wsdl:message name="GetStockResponse">
<wsdl:part name="parameters" element="tns:GetStockResponse"/>
</wsdl:message>
<xsd:element name="GetStockResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Items" minOccurs="0" maxOccurs="1" type="tns:ArrayOfItems"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="ArrayOfItems">
<xsd:sequence>
<xsd:element name="Item" minOccurs="0" maxOccurs="unbounded" nillable="true" type="tns:Item"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ArrayOfItems" type="tns:ArrayOfItems"/>
<xsd:complexType name="Item">
<xsd:sequence>
<xsd:element name="ItemNo" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="StoreID" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="NotInERP" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="DeliveryTimeText" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="DeliveryDays" minOccurs="0" maxOccurs="1" type="xsd:integer"/>
<xsd:element name="InStockQty" minOccurs="0" maxOccurs="1" type="xsd:integer"/>
<xsd:element name="InShowRoom" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="Points" minOccurs="0" maxOccurs="1" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Item" type="tns:Item"/>
此服务的已创建Reference.cs如下所示
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="Item", Namespace="http://www.unikum.se/pws")]
[System.SerializableAttribute()]
public partial class Item : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {
[System.NonSerializedAttribute()]
private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private string ItemNoField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private string StoreIDField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private string NotInERPField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private string DeliveryTimeTextField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private long DeliveryDaysField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private long InStockQtyField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private string InShowRoomField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private string PointsField;
[global::System.ComponentModel.BrowsableAttribute(false)]
public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
get {
return this.extensionDataField;
}
set {
this.extensionDataField = value;
}
}
[System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false)]
public string ItemNo {
get {
return this.ItemNoField;
}
set {
if ((object.ReferenceEquals(this.ItemNoField, value) != true)) {
this.ItemNoField = value;
this.RaisePropertyChanged("ItemNo");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false)]
public string StoreID {
get {
return this.StoreIDField;
}
set {
if ((object.ReferenceEquals(this.StoreIDField, value) != true)) {
this.StoreIDField = value;
this.RaisePropertyChanged("StoreID");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=2)]
public string NotInERP {
get {
return this.NotInERPField;
}
set {
if ((object.ReferenceEquals(this.NotInERPField, value) != true)) {
this.NotInERPField = value;
this.RaisePropertyChanged("NotInERP");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=3)]
public string DeliveryTimeText {
get {
return this.DeliveryTimeTextField;
}
set {
if ((object.ReferenceEquals(this.DeliveryTimeTextField, value) != true)) {
this.DeliveryTimeTextField = value;
this.RaisePropertyChanged("DeliveryTimeText");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute(Order=4)]
public long DeliveryDays {
get {
return this.DeliveryDaysField;
}
set {
if ((this.DeliveryDaysField.Equals(value) != true)) {
this.DeliveryDaysField = value;
this.RaisePropertyChanged("DeliveryDays");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute(Order=5)]
public long InStockQty {
get {
return this.InStockQtyField;
}
set {
if ((this.InStockQtyField.Equals(value) != true)) {
this.InStockQtyField = value;
this.RaisePropertyChanged("InStockQty");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=6)]
public string InShowRoom {
get {
return this.InShowRoomField;
}
set {
if ((object.ReferenceEquals(this.InShowRoomField, value) != true)) {
this.InShowRoomField = value;
this.RaisePropertyChanged("InShowRoom");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=7)]
public string Points {
get {
return this.PointsField;
}
set {
if ((object.ReferenceEquals(this.PointsField, value) != true)) {
this.PointsField = value;
this.RaisePropertyChanged("Points");
}
}
}
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propertyName) {
System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
if ((propertyChanged != null)) {
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}
}
}
当要求特定项目时,我在Fiddler
中得到了这个结果<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetStockResponse xmlns="http://www.unikum.se/pws">
<Items>
<Item>
<ItemNo>0000001234</ItemNo>
<DeliveryTimeText>4-6 veckor</DeliveryTimeText>
<DeliveryDays>42</DeliveryDays>
<Points>17</Points>
<StoreID>036</StoreID>
<NotInERP>Nej</NotInERP>
<InStockQty>4</InStockQty>
<InShowRoom>Nej</InShowRoom>
</Item>
</Items>
</GetStockResponse>
</soap:Body>
</soap:Envelope>
所有看起来都很好,对吗? 为什么某些字段在使用该服务的程序中的序列化结果中为空呢? 字段如下所示:
任何人都有任何关于尝试调试时要查找的内容的指示?大多数这些领域以前一直在工作,但一个接一个地停止工作,我认为这与ERP方面的服务变化有关。
由于我对此部分不负责任,因此我试图提供足够的详细信息,说明在C#中使用它时为什么不起作用。我的意思是,因为一些字段工作并且Fiddler中的响应看起来很好,所以似乎是基于WSDL信息在C#中如何创建和配置路由器。
答案 0 :(得分:0)
好的,stuartd的评论提供了有关该问题的更多详细信息,并将此提供给Serviceprovider,导致他们可以在答案中重新排列结构。这解决了问题,所有数据都被正确反序列化。感谢您的投入。