gpt4 book ai didi

c# - 在 C# 中读取 SOAP 数组

转载 作者:行者123 更新时间:2023-12-03 20:15:57 26 4
gpt4 key购买 nike

我正在使用来自第三方网站的网络服务。我在 wsdl 文件中有名为 GetItemAvailable 的类型和方法。当我使用并执行该服务时,它返回一个 SOAP 数组(在 wsdl 中定义为 ItemsArray)。问题是,我不确定需要使用什么类型来获取信息。这是我的代码:

GetItemAvailable.GetItemAvailable gia = new GetItemAvailable.GetItemAvailable();
ItemsArray ia = new ItemsArray();
ia = (gia.CallGetItemAvailable("1088507721", "9780842387491"));
string sttest = ia.id[1].ToString();

错误总是说 ia.id 为 null

我做错了什么?我对 SOAP 不是很熟悉。这是 wsdl:

<wsdl:definitions>
<wsdl:types>
<xsd:complexType name="Items">
<xsd:all>
<xsd:element name="item_id" type="xsd:string" />
<xsd:element name="tn_onhand" type="xsd:int" />
<xsd:element name="tn_onorder" type="xsd:string" />
<xsd:element name="tn_onorder_eta" type="xsd:string" />
<xsd:element name="nv_onhand" type="xsd:int" />
<xsd:element name="nv_onorder" type="xsd:string" />
<xsd:element name="nv_onorder_eta" type="xsd:string" />
<xsd:element name="error" type="xsd:string" />
</xsd:all>
</xsd:complexType>
<xsd:complexType name="ItemsArray">
<xsd:complexContent mixed="false">
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute wsdl:arrayType="tns:Items[]" ref="SOAP-ENC:arrayType" />
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="GetItemAvailableRequestType">
<xsd:all>
<xsd:element name="api_key" type="xsd:string" />
<xsd:element name="Items" type="xsd:string" />
</xsd:all>
</xsd:complexType>
<xsd:complexType name="GetItemAvailableResponseType">
<xsd:all>
<xsd:element name="GetItemAvailableResult" type="tns:ItemsArray" />
</xsd:all>
</xsd:complexType>
<xsd:element name="GetItemAvailable" type="tns:GetItemAvailableRequestType" />
<xsd:element name="GetItemAvailableResponse" type="tns:GetItemAvailableResponseType" />
</xsd:schema>
</wsdl:types>
<wsdl:message name="GetItemAvailableRequest">
<wsdl:part name="parameters" element="tns:GetItemAvailable" />
</wsdl:message>
<wsdl:message name="GetItemAvailableResponse">
<wsdl:part name="parameters" element="tns:GetItemAvailableResponse" />
</wsdl:message>
<wsdl:portType name="GetItemAvailablePortType">
<wsdl:operation name="GetItemAvailable">
<documentation>Returns quantity available and on order for list of products seperated by comma (example: 9780877840756,9780446691093)</documentation>
<wsdl:input message="tns:GetItemAvailableRequest" />
<wsdl:output message="tns:GetItemAvailableResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="GetItemAvailableBinding" type="tns:GetItemAvailablePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="GetItemAvailable">
<soap:operation soapAction="http://www.stl-distribution.com/GetItemAvailable" style="document" />
<wsdl:input>
<soap:body use="literal" namespace="http://www.stl-distribution.com" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" namespace="http://www.stl-distribution.com" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="GetItemAvailable">
<wsdl:port name="GetItemAvailablePort" binding="tns:GetItemAvailableBinding">
<soap:address location="http://www.stl-distribution.com/webservices/soap/GetItemAvailable.php" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

最佳答案

这不应该是

//string sttest = ia.id[1].ToString();
string sttest = ia[0].item_id;

关于c# - 在 C# 中读取 SOAP 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3772858/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com