C#でサードパーティのWebサービス(SOAP)を使用するクライアントアプリケーションを開発しています。石鹸は複数の「サプライヤー」ノードで応答します。ただし、c#の配列にはNULL値が含まれています。基本的に変数。
SuppliersType[] Suppliers
要素にNULL値があります。ただし、他の変数(応答コードなど)は入力されます。Supplier配列には、Webサービスによって返されるノードが入力されている必要があります。サービス参照を追加するときにVSが生成するクラスを使用しています。私は以下を使用してクラスを呼び出します:
ServiceReference2.SuppliersType[] Suppliers;
Client.SupploerProfiles(DTStamp,ID, out ResponseCode, out ResponseMessage, out Suppliers);
WSDLのスニペットとVSが生成するクラスを含めました。どんな援助も大歓迎です!前もって感謝します!石鹸の反応:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tpw="http://www.example.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema">
<soapenv:Body>
<tpw:SupplierProfilesResponse>
<DateTimeStamp>2011-01-01 22:22:212</DateTimeStamp>
<ResponseCode>0</ResponseCode>
<ResponseMessage>Success</ResponseMessage>
<Suppliers>
<SupplierName>A</SupplierName>
<SupplierNumber>5559875421</SupplierNumber>
</Suppliers>
<Suppliers>
<SupplierName>B</SupplierName>
<SupplierNumber>5559875421</SupplierNumber>
</Suppliers>
<Suppliers>
<SupplierName>C</SupplierName>
<SupplierNumber>5559875421</SupplierNumber>
</Suppliers>
</tpw:SupplierProfilesResponse>
</soapenv:Body>
</soapenv:Envelope>
WSDLのサプライヤータイプの定義
<xsd:element name="SupplierProfilesResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="DateTimeStamp" type="xsd:dateTime" nillable="true">
</xsd:element>
<xsd:element name="ResponseCode" type="xsd:int" nillable="true">
</xsd:element>
<xsd:element name="ResponseMessage" type="xsd:string" nillable="true">
</xsd:element>
<xsd:element name="Suppliers" type="tns:SuppliersType" minOccurs="0" maxOccurs="7">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="SuppliersType">
<xsd:sequence>
<xsd:element name="SupplierName" type="xsd:string" nillable="true"></xsd:element>
<xsd:element name="SupplierNumber" type="xsd:string" nillable="true"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
VSが生成するクラスのスニペット:
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.example.com")]
public partial class SuppliersType : object, System.ComponentModel.INotifyPropertyChanged
{
private string supplierNameField;
private string supplierNumberField;
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable = true, Order = 0)]
public string SupplierName
{
get
{
return this.supplierNameField;
}
set
{
this.supplierNameField = value;
this.RaisePropertyChanged("SupplierName");
}
}
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable = true, Order = 1)]
public string SupplierNumber
{
get
{
return this.supplierNumberField;
}
set
{
this.supplierNumberField = value;
this.RaisePropertyChanged("SupplierNumber");
}
}
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));
}
}
}