Я пытаюсь перечислить все мои продукты с интерфейсом SOAP v2 в C # (.Net 4.0, VS 2010), используя WS-I-совместимую версию интерфейса SOAP, созданную WSDL в Magento 1.6.1.0.
Я могу обычно получать товары с помощью своего кода (см. Приложение ниже), когда у меня менее 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;
}
Кто-нибудь знает, почему это происходит?
Большое спасибо!