SOAP Magento Error on Customer.Create - magento

I am trying to create a customer from the Magja project and the AxisFault i am getting is a 100 "Customer email is required." . I am passing over the correct minimum required params from the 1.7 documentation. Long story my fault code is saying i am not including my email BUT it is clearly there (not putting the sensitive info on SO...so you just have to trust me :) ). Any Ideas?
Stack
org.eclipse.debug.core.DebugException: com.sun.jdi.ClassNotLoadedException: Type has not been loaded occurred while retrieving component type of array.
//soapclient line 208
result = sender.sendReceive(method) -> method variable
<mag:call xmlns:mag="urn:Magento" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-XML="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<sessionId>9be685563680f52c1ab5375bec545dfe</sessionId>
<resourcePath>customer.create</resourcePath>
<args SOAP-ENC:arrayType="xsd:ur-type[1]" xsi:type="SOAP-ENC:Array">
<item SOAP-ENC:arrayType="xsd:ur-type[1]" xsi:type="SOAP-ENC:Array">
<item xsi:type="SOAP-XML:Map">
<item>
<key xsi:type="xsd:string">email</key>
<value xsi:type="xsd:string">MY EMAIL</value>
</item>
<item>
<key xsi:type="xsd:string">password_hash</key>
<value xsi:type="xsd:string">4cb9c8a8048fd02294477fcb1a41191a</value>
</item>
<item>
<key xsi:type="xsd:string">group_id</key>
<value xsi:type="xsd:int">1</value>
</item>
<item>
<key xsi:type="xsd:string">store_id</key>
<value xsi:type="xsd:int">1</value>
</item>
<item>
<key xsi:type="xsd:string">lastname</key>
<value xsi:type="xsd:string">LName</value>
</item>
<item>
<key xsi:type="xsd:string">firstname</key>
<value xsi:type="xsd:string">Fname</value>
</item>
<item>
<key xsi:type="xsd:string">website_id</key>
<value xsi:type="xsd:int">1</value>
</item>
</item>
</item>
</args>
</mag:call>
//magentosoapclient line 215
throw axisFault (axisfault -> message)
<?xml version='1.0' encoding='utf-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>100</faultcode>
<faultstring>Customer email is required</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

You'll need to trace/log the data on the Magento end of things. Somehow email's getting lost and/or munged in the process. The PHP code that's called for a customer creation is at
#File: app/code/core/Mage/Customer/Model/Customer/Api.php
public function create($customerData)
{
$customerData = $this->_prepareData($customerData);
try {
$customer = Mage::getModel('customer/customer')
->setData($customerData)
->save();
} catch (Mage_Core_Exception $e) {
$this->_fault('data_invalid', $e->getMessage());
}
return $customer->getId();
}
and the specific exception being sent back to your SOAP client is at
#File: app/code/core/Mage/Customer/Model/Resource/Customer.php
protected function _beforeSave(Varien_Object $customer)
{
parent::_beforeSave($customer);
if (!$customer->getEmail()) {
throw Mage::exception('Mage_Customer', Mage::helper('customer')->__('Customer email is required'));
}
There's something about your client call and/or the specific Magento system you're using that makes Magento think there's no customer email set. A few calls to Mage::Log should set you on the right path.

Related

Properly add new columns to sales order grid in Magento 2

I created a module to add 2 columns in sales grid, shipping_information and tracking number.
The columns appears but when I tried to filter by Order ID in admin order page, example with 973, I got this error
main.CRITICAL: Item (Magento\Framework\View\Element\UiComponent\DataProvider\Document\Interceptor) with the same ID "6245" already exists. {"exception":"[object] (Exception(code: 0): Item (Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\Document\\Interceptor) with the same ID \"6245\" already exists. at /home/xxxx/public_html/vendor/magento/framework/Data/Collection.php:404)"}
Also this error
Integrity constraint violation: 1052 Column 'created_at' in order clause is ambiguous
But when I tried with another ID, the error disappear
In Vendor/Module/Model/ResourceModel/Order/Grid/Collection.php
namespace Wetag\AdditionalOrderFields\Model\ResourceModel\Order\Grid;
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
use Magento\Framework\Event\ManagerInterface as EventManager;
use Magento\Sales\Model\ResourceModel\Order\Grid\Collection as OriginalCollection;
use Psr\Log\LoggerInterface as Logger;
/**
* Order grid extended collection
*/
class Collection extends OriginalCollection
{
protected $helper;
public function __construct(
EntityFactory $entityFactory,
Logger $logger,
FetchStrategy $fetchStrategy,
EventManager $eventManager,
$mainTable = 'sales_order_grid',
$resourceModel = \Magento\Sales\Model\ResourceModel\Order::class
)
{
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);
}
protected function _renderFiltersBefore()
{
$joinTable = $this->getTable('sales_order');
$joinTable_track = $this->getTable('sales_shipment_track');
$this->getSelect()->joinLeft($joinTable, 'main_table.entity_id = sales_order.entity_id', ['shipping_information'])->distinct();
$this->getSelect()->joinLeft($joinTable_track, 'sales_order.entity_id = sales_shipment_track.order_id', ['track_number'])->distinct();
parent::_renderFiltersBefore();
}
protected function _initSelect() {
$this->addFilterToMap('increment_id', 'main_table.increment_id');
$this->addFilterToMap('status', 'main_table.status');
parent::_initSelect();
return $this;
}
}
In Vendor/Module/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="sales_order_grid_data_source" xsi:type="string">Vendor\Module\Model\ResourceModel\Order\Grid\Collection</item>
</argument>
</arguments>
</type>
<type name="Vendor\Module\Model\ResourceModel\Order\Grid\Collection">
<arguments>
<argument name="mainTable" xsi:type="string">sales_order_grid</argument>
<argument name="resourceModel" xsi:type="string">Magento\Sales\Model\ResourceModel\Order</argument>
</arguments>
</type>
</config>
In etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Vendor_Module" setup_version="1.0.0">
<sequence>
<module name="Magento_sales" />
</sequence>
</module>
</config>
In Vendor/Module/view/adminhtml/ui_component/sales_order_grid.xml
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<column name="shipping_information">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Shipping method</item>
</item>
</argument>
</column>
<column name="track_number">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Tracking number</item>
</item>
</argument>
</column>
</columns>
</listing>
I like to use the field shipping_information in order_sales_grid table, I didn’t get it without making a left join, I like to select this field without join
I solved the issue by grouping by entity_id ->group('main_table.entity_id') to remove duplicaded rows and delete LeftJoin to Sales_order table since shipping_information already exists in sales_order_grid table
protected function _renderFiltersBefore()
{
$joinTable_track = $this->getTable('sales_shipment_track');
$this->getSelect()->joinLeft($joinTable_track, 'main_table.entity_id = sales_shipment_track.order_id', ['track_number'])->group('main_table.entity_id');
parent::_renderFiltersBefore();
}

Magento soap error

I'm developing an iOS app that should integrate Magento e-commerce.
Actually I'm trying to put objects into the cart, when I try to do that my app sends to server this WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:Magento" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<call>
<sessionId xsi:type="xsd:string">e976c086bf862d23fcc98e59fb23b499</sessionId>
<resourcePath xsi:type="xsd:string">cart_product.add</resourcePath>
<args xsi:type="SOAP-ENC:Array">
<item xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">quoteId</key>
<value xsi:type="xsd:int">85</value>
</item>
<item>
<key xsi:type="xsd:string">products</key>
<value xsi:type="SOAP-ENC:Array">
<item xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">product_id</key>
<value xsi:type="xsd:string">1</value>
</item>
<item>
<key xsi:type="xsd:string">qty</key>
<value xsi:type="xsd:int">1</value>
</item>
</item>
</value>
</item>
</item>
</args>
</call>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I tried it with this extension for Google Chrome, when I try to run the WSDL
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>1</faultcode>
<faultstring>SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
What's wrong in my request? Can anyone help me?
Solved now I'm sending this:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:Magento" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<call>
<sessionId xsi:type="xsd:string">38fd5af2c7fcfd55884b73ffded29225</sessionId>
<resourcePath xsi:type="xsd:string">cart_product.add</resourcePath>
<args xsi:type="SOAP-ENC:Array">
<item xsi:type="xsd:int">142</item>
<item xsi:type="SOAP-ENC:Array">
<item xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">product_id</key>
<value xsi:type="xsd:string">2</value>
</item>
<item>
<key xsi:type="xsd:string">qty</key>
<value xsi:type="xsd:int">1</value>
</item>
</item>
</item>
</args>
</call>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I was formatting wrong the request, indeed, if you compare the 2 request you will see the difference: I was sending the key "quoteId", but it's not necessary.

Building in-game editor, need assistance with Load and Save

I've been working on a game project with a small group for a bit now and we've hit a block. One of the features of this game is the ability for users to generate their own levels through the use of an in-game editor. The editor creates a Level object which stores the length and width of the level and a two-dimensional array of Tile objects. We've successfully implemented the camera system and can edit together a simple concept level without too much difficulty, but the process of successfully saving the level and loading it back up later is a concept that's proving difficult, and I was hoping one of you could offer some guidance to get the intended functionality down.
In its current state, when the user presses the 'S' key, our LevelManager class runs the SaveLevel method below:
public static void SaveLevel()
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
using (XmlWriter writer = XmlWriter.Create("example.xml", settings))
{
IntermediateSerializer.Serialize(writer, CurrentLevel, null);
}
}
Which serializes our level (CurrentLevel) into an XML file in the project (We'll worry about saving to different files after we get this basic setup working.) I ran the program, created a small map and saved it, and here's the output in the resulting XML file:
<?xml version="1.0" encoding="utf-8"?>
<XnaContent>
<Asset Type="LevelEditorPrototype.Level">
<TileGrid>
<Item>
<Item Type="LevelEditorPrototype.TileFloor">
<X>0</X>
<Y>0</Y>
<Width>32</Width>
<Height>32</Height>
<Origin>0 0</Origin>
<Depth>0</Depth>
<Tint>FFFFFFFF</Tint>
</Item>
<Item Type="LevelEditorPrototype.TileBlock">
<X>0</X>
<Y>32</Y>
<Width>32</Width>
<Height>32</Height>
<Origin>0 0</Origin>
<Depth>0</Depth>
<Tint>FF0000FF</Tint>
</Item>
<Item Type="LevelEditorPrototype.TileVoid">
<X>0</X>
<Y>64</Y>
<Width>32</Width>
<Height>32</Height>
<Origin>0 0</Origin>
<Depth>0</Depth>
<Tint>FFFF0000</Tint>
</Item>
<Item Type="LevelEditorPrototype.TileFloor">
<X>0</X>
<Y>96</Y>
<Width>32</Width>
<Height>32</Height>
<Origin>0 0</Origin>
<Depth>0</Depth>
<Tint>FFFFFFFF</Tint>
</Item>
</Item>
<Item>
<Item Type="LevelEditorPrototype.TileVoid">
<X>32</X>
<Y>0</Y>
<Width>32</Width>
<Height>32</Height>
<Origin>0 0</Origin>
<Depth>0</Depth>
<Tint>FFFF0000</Tint>
</Item>
<Item Type="LevelEditorPrototype.TileFloor">
<X>32</X>
<Y>32</Y>
<Width>32</Width>
<Height>32</Height>
<Origin>0 0</Origin>
<Depth>0</Depth>
<Tint>FFFFFFFF</Tint>
</Item>
<Item Type="LevelEditorPrototype.TileBlock">
<X>32</X>
<Y>64</Y>
<Width>32</Width>
<Height>32</Height>
<Origin>0 0</Origin>
<Depth>0</Depth>
<Tint>FF0000FF</Tint>
</Item>
<Item Type="LevelEditorPrototype.TileVoid">
<X>32</X>
<Y>96</Y>
<Width>32</Width>
<Height>32</Height>
<Origin>0 0</Origin>
<Depth>0</Depth>
<Tint>FFFF0000</Tint>
</Item>
</Item>
<Item>
<Item Type="LevelEditorPrototype.TileBlock">
<X>64</X>
<Y>0</Y>
<Width>32</Width>
<Height>32</Height>
<Origin>0 0</Origin>
<Depth>0</Depth>
<Tint>FF0000FF</Tint>
</Item>
<Item Type="LevelEditorPrototype.TileVoid">
<X>64</X>
<Y>32</Y>
<Width>32</Width>
<Height>32</Height>
<Origin>0 0</Origin>
<Depth>0</Depth>
<Tint>FFFF0000</Tint>
</Item>
<Item Type="LevelEditorPrototype.TileFloor">
<X>64</X>
<Y>64</Y>
<Width>32</Width>
<Height>32</Height>
<Origin>0 0</Origin>
<Depth>0</Depth>
<Tint>FFFFFFFF</Tint>
</Item>
<Item Type="LevelEditorPrototype.TileBlock">
<X>64</X>
<Y>96</Y>
<Width>32</Width>
<Height>32</Height>
<Origin>0 0</Origin>
<Depth>0</Depth>
<Tint>FF0000FF</Tint>
</Item>
</Item>
<Item>
<Item Type="LevelEditorPrototype.TileFloor">
<X>96</X>
<Y>0</Y>
<Width>32</Width>
<Height>32</Height>
<Origin>0 0</Origin>
<Depth>0</Depth>
<Tint>FFFFFFFF</Tint>
</Item>
<Item Type="LevelEditorPrototype.TileBlock">
<X>96</X>
<Y>32</Y>
<Width>32</Width>
<Height>32</Height>
<Origin>0 0</Origin>
<Depth>0</Depth>
<Tint>FF0000FF</Tint>
</Item>
<Item Type="LevelEditorPrototype.TileVoid">
<X>96</X>
<Y>64</Y>
<Width>32</Width>
<Height>32</Height>
<Origin>0 0</Origin>
<Depth>0</Depth>
<Tint>FFFF0000</Tint>
</Item>
<Item Type="LevelEditorPrototype.TileFloor">
<X>96</X>
<Y>96</Y>
<Width>32</Width>
<Height>32</Height>
<Origin>0 0</Origin>
<Depth>0</Depth>
<Tint>FFFFFFFF</Tint>
</Item>
</Item>
</TileGrid>
</Asset>
</XnaContent>
So at the very least we do have data information on the tiles generated in the level, so that's something. We'd like our users to be able to load up saved levels during runtime as well, so we mapped the 'L' key to load that saved XML file, and that's where the problem shows up. Our read looks like this:
public static void LoadLevel()
{
using (FileStream stream = new FileStream("example.xml", FileMode.Open))
{
using (XmlReader reader = XmlReader.Create(stream))
{
currentLevel = IntermediateSerializer.Deserialize<Level>(reader, null);
}
}
}
When we try testing that functionality, we get this error:
System.MethodAccessException was unhandled
HResult=-2146233072
Message=Attempt by method 'DynamicClass.ReflectionEmitUtils(System.Object, System.Object)' to access method 'DynamicClass.ReflectionEmitUtils(System.Object, System.Object)' failed.
I have a sneaking suspicion that the IntermediateSerializer doesn't quite work how we want it to work, but I'm not sure how else to parse and store the data effectively. Is there a different setup I should be using here?
The most effective way to be 100% sure of saving and loading tile-based levels have, in my experience, to use BinaryWriter and BinaryReader.
Our level-structure has been a lot different from yours, though; We have many layers. Each layer uses a tileset and consists of instances of Tile. Tile holds its position (Vector2D) and a TileId (index of the tile in the tileset-texture).
The way we put objects in levels are with tilesets that are replaced by real objects on loading.
Anyways, a suitably generic way to save and load data is by letting your classes have a contructor that can take a BinaryReader as an argument, and a method to write itself to a BinaryWriter.
like this:
public Tile(BinaryReader reader)
{
Position.X = reader.ReadFloat();
Position.Y = reader.ReadFloat();
TileId = reader.ReadInt32();
}
public void WriteToStream(BinaryWriter writer)
{
writer.Write(Position.X);
writer.Write(Position.Y);
writer.Write(TileId);
}
if you only have one class to load, you can then simply:
for loading:
var tiles = new List<Tile>();
var reader = new BinaryReader(File.Open("level.bin"));
while (reader.BaseStream.Position < reader.BaseStream.Length)
{
var tile = new Tile(reader);
tiles.Add(tile);
}
reader.Close();
For saving:
var tiles; //lets pretend this is the level
var writer = new BinaryWriter(File.Create("level.bin"));
foreach (var tile in tiles)
{
tile.WriteToStream(writer);
}
writer.Flush(); //IMPORTANT!!!
writer.Close();
If, however, your list contains items of different types, you need to store the type also.
A pretty generic way to do this is by inserting:
writer.Write(tile.GetType().FullName);
before tile.WriteToStream(writer);
and then on loading you need to:
var tileType = Type.GetType(reader.ReadString()); //Read the type from the stream
var constructor = tileType.GetConstructor(new [] { typeof(BinaryReader)}); //get a constructor that can use a binaryreader
var tile = constructor.Invoke(new [] { reader }); //use said constructor to create an instance
Hope this helps. And note that I am writing this out of memory, so syntax errors are probable....

Parsing complex soap XML in windows phone 7

I have complex soap XML like below.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<MessageHeader>
<From>
<Type>string</Type>
</d3p1:From>
<d3p1:To>
<Role>string</Role>
</d3p1:To>
</MessageHeader>
<Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/sxvt">
<StrongToken>string</StrongToken>
</Security>
</soap:Header>
<soap:Body>
<FunctionResponse xmlns="http://www.yyy.com/webservices">
<FunctionRS TimeStamp="dateTime">
<Message>string<Message>
<Success>
<SuccessMessage>string</SuccessMessage>
</Success>
<Warnings>
<Warning Type="string" Text="string" />
<Warning Type="string" Text="string" />
</Warnings>
<Errors>
<Error Type="string" Text="string" />
<Error Type="string" Text="string" />
</Errors>
<Items>
<Item SequenceNo="Int" ">
<SamplePrice>
<Prices>
<Price>
<ToatlPrice>
<ItemNo>Int </ItemNo>
<ItemPrice>Int </ItemPrice>
</ToatlPrice>
</Price>
</Prices>
</SamplePrice >
</Item>
<Item SequenceNo="Int" ">
<SamplePrice>
<Prices>
<Price>
<ToatlPrice>
<ItemNo>Int </ItemNo>
<ItemPrice>Int </ItemPrice>
</ToatlPrice>
</Price>
</Prices>
</SamplePrice >
</Item>
</Items>
<Info>
<CurrencyCode>
<string>string</string>
<string>string</string>
</CurrencyCode>
</Infor>
</FunctionRS>
</FunctionResponse>
</soap:Body>
</soap:Envelope>
here i want the results of FunctionRS tag. I have created the class for the FunctionRS tag.
I have created FunctionRS class.
var result = resultNewDataSet.Descendants("FunctionRS").Select(t => new FunctionRS
{
Message = t.Descendants("Message").First().Value,
//Success = t.Descendants("Success").First().Value
});
using the above code i am able to get Message tag, but i am not able get the array lists (like Success, warnings,Items,etc) and class (like Info).
How can i Serialize the above xml using LINQ to XML.
Thanks in advance.
Elements you are looking for are in http://www.yyy.com/webservices namespace however in your query you are not using namespaces. I am not sure how FunctionRS or Message could be found as you are looking for them in the empty namespace. Try the following:
var resultNewDataSet = XDocument.Parse(
#"<?xml version=""1.0"" encoding=""utf-8""?>
<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:d3p1=""unknownnamespace"">
<soap:Header>
<MessageHeader>
<d3p1:From>
<Type>string</Type>
</d3p1:From>
<d3p1:To>
<Role>string</Role>
</d3p1:To>
</MessageHeader>
<Security xmlns=""http://schemas.xmlsoap.org/ws/2002/12/sxvt"">
<StrongToken>string</StrongToken>
</Security>
</soap:Header>
<soap:Body>
<FunctionResponse xmlns=""http://www.yyy.com/webservices"">
<FunctionRS TimeStamp=""dateTime"">
<Message>string</Message>
<Success>
<SuccessMessage>string</SuccessMessage>
</Success>
<Warnings>
<Warning Type=""string"" Text=""string"" />
<Warning Type=""string"" Text=""string"" />
</Warnings>
<Errors>
<Error Type=""string"" Text=""string"" />
<Error Type=""string"" Text=""string"" />
</Errors>
<Items>
<Item SequenceNo=""Int"">
<SamplePrice>
<Prices>
<Price>
<ToatlPrice>
<ItemNo>Int </ItemNo>
<ItemPrice>Int </ItemPrice>
</ToatlPrice>
</Price>
</Prices>
</SamplePrice >
</Item>
<Item SequenceNo=""Int"">
<SamplePrice>
<Prices>
<Price>
<ToatlPrice>
<ItemNo>Int </ItemNo>
<ItemPrice>Int </ItemPrice>
</ToatlPrice>
</Price>
</Prices>
</SamplePrice >
</Item>
</Items>
<Info>
<CurrencyCode>
<string>string</string>
<string>string</string>
</CurrencyCode>
</Info>
</FunctionRS>
</FunctionResponse>
</soap:Body>
</soap:Envelope>");
XNamespace webServicesNs = "http://www.yyy.com/webservices";
var result = resultNewDataSet
.Descendants(webServicesNs + "FunctionRS")
.Select(t => new
{
Message = (string)t.Descendants(webServicesNs + "Message").First(),
Success = (string)t.Descendants(webServicesNs + "Success").First(),
Warnings = t
.Element(webServicesNs + "Warnings")
.Elements(webServicesNs + "Warning")
.Select(w => new
{
#Type = (string)w.Attribute("Type"),
#Text = (string)w.Attribute("Text")
})
});
foreach (var r in result)
{
Console.WriteLine(r);
foreach (var w in r.Warnings)
{
Console.WriteLine(w);
}
}
(I included the Xml since the one you provided was broken and I had to fix it to make it possible to load to XDocument).
Here is the result I got:
{ Message = string, Success = string, Warnings = System.Linq.Enumerable+WhereSel
ectEnumerableIterator`2[System.Xml.Linq.XElement,<>f__AnonymousType0`2[System.St
ring,System.String]] }
{ Type = string, Text = string }
{ Type = string, Text = string }

How to parse SOAP XML in ruby?

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="https://extranet.mcs.be/DEV_QUALITY_API/modules/quality/services/soap/quality.php"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:getQuestionnairesListResponse>
<return SOAP-ENC:arrayType="ns1:QuestionnaireListItem[34]"
xsi:type="ns1:ArrayOfQuestionnaireListItem">
<item xsi:type="ns1:QuestionnaireListItem">
<ID xsi:type="xsd:string">0000000022</ID>
<Code xsi:type="xsd:string">Interest PubTransp</Code>
<Reference xsi:type="xsd:string">Check Employees Interest in Public
Transport</Reference>
</item>
<item xsi:type="ns1:QuestionnaireListItem">
<ID xsi:type="xsd:string">0000000008</ID>
<Code xsi:type="xsd:string">CS SRE North 2003</Code>
<Reference xsi:type="xsd:string">Customer Satisfaction SRE North 2003</Reference>
</item>
<item xsi:type="ns1:QuestionnaireListItem">
<ID xsi:type="xsd:string">0000000006</ID>
<Code xsi:type="xsd:string">CS SRE South 2003</Code>
<Reference xsi:type="xsd:string">Customer Satisfaction SRE South 2003</Reference>
</item>
.
.
.
I want to parse the above soap String (I actually want to get items from the above soap). How could I do this?
There's a gem called Savon that's specifically made for dealing with SOAP in Ruby.
There's good documentation on the web site, once you looked into that and have more specific questions I'm sure we can help you.

Resources