我想列出我所有的產品在C#中的SOAP接口V2(.NET 4.0,VS 2010),使用WS-I兼容,Magento 1.6.1.0中的WSDL生成的SOAP接口版本。無法取得產品在Magento 1.6.1.0的SOAP API的CatalogProductList當我有超過25個產品
我可以檢索產品通常與我的代碼(附在下面),當我有少於25種產品。然而,當我有25個產品以上,我得到一個錯誤:
Unhandled Exception: System.InvalidOperationException: There is an error in XML
document (333, 2). ---> System.Xml.XmlException: Unexpected end of file has occu
rred. The following elements are not closed: complexObjectArray, result, ns1:cat
alogProductListResponseParam, SOAP-ENV:Body, SOAP-ENV:Envelope. Line 333, positi
on 2.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ThrowUnclosedElements()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlReader.MoveToContent()
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderMagent
oService.Read32_catalogProductEntity(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderMagent
oService.Read121_Item()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer86.De
serialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, St
ring encodingStyle, XmlDeserializationEvents events)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, St
ring encodingStyle, XmlDeserializationEvents events)
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClie
ntMessage message, WebResponse response, Stream responseStream, Boolean asyncCal
l)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodN
ame, Object[] parameters)
at MagentoAPITest.mage.MagentoService.catalogProductList(String sessionId, fi
lters filters, String store) in ....\technology\c#\MagentoAPITest
\MagentoAPITest\Web References\mage\Reference.cs:line 1982
at MagentoAPITest.magentoHelper.GetProducts() in ....\technolo
gy\c#\MagentoAPITest\MagentoAPITest\magentoHelper.cs:line 62
at MagentoAPITest.Program.Main(String[] args) in ....g\technolo
gy\c#\MagentoAPITest\MagentoAPITest\Program.cs:line 30
Press any key to continue . . .
它似乎並不無論什麼樣的產品,我創造;我總是拋出這個錯誤。
我可以繼續添加產品;當我這樣做時,錯誤略微變爲(在50種產品的情況下)
Unhandled Exception: System.InvalidOperationException: There is an error in XML
document (666, 2). ---> System.Xml.XmlException: Unexpected end of file has occurred. The following elements are not closed: complexObjectArray, result, ns1:catalogProductListResponseParam, SOAP-ENV:Body, SOAP-ENV:Envelope. Line 666, position 2.
我相信,這意味着被Magento的發送適當的數據;然而,我懷疑C#沒有正確解析數據?
僅供參考,我找回我的產品通過:
public List<mage.catalogProductEntity> GetProducts()
{
//var result = ms.call(sessionID, "catalog_product.list", null);
// retrieve products
mage.filters filter = new mage.filters();
mage.catalogProductEntity[] products = new mage.catalogProductEntity[1];
try
{
products = ms.catalogProductList(sessionID, filter, "");
}
catch (System.InvalidOperationException e)
{
Console.WriteLine(e.Message);
System.Xml.XmlException xe = (System.Xml.XmlException) e.InnerException;
Console.WriteLine(xe.SourceUri);
throw;
}
foreach (mage.catalogProductEntity product in products)
{
Console.WriteLine(product.product_id + ", "
+ product.name + ", "
+ product.type + ", "
+ product.sku + ", "
+ product.set + "");
}
List<mage.catalogProductEntity> ProductsList = new List<mage.catalogProductEntity>(products);
return ProductsList;
}
有誰知道爲什麼發生這種情況?
非常感謝!