5

By each SOAP agent am getting this response "error 500".

I am using SOAP v2 with WS-I compliance mode.

<?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>SOAP-ENV:Server</faultcode>
            <faultstring>SOAP-ERROR: Encoding: object has no 'results' property</faultstring>
        </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

WSDL.xml looks like

<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * my
 *
 * @category my
 * @package my AP-Plus
 */-->
<definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"
             name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
    <message name="myApplusSyncParseRequest">
        <part name="sessionId" type="xsd:string" />
        <part name="xmlString" type="xsd:string" />
    </message>
    <message name="myApplusSyncParseResponse">
        <part name="results" type="xsd:string" />
    </message>
    <portType name="{{var wsdl.handler}}PortType">
        <operation name="myApplusSyncParse">
            <documentation>List of products</documentation>
            <input message="typens:myApplusSyncParseRequest" />
            <output message="typens:myApplusSyncParseResponse" />
        </operation>
    </portType>
    <binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
        <operation name="myApplusSyncParse">
            <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
            <input>
            <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
            </input>
            <output>
                <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
            </output>
        </operation>
    </binding>
    <service name="{{var wsdl.name}}Service">
        <port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
            <soap:address location="{{var wsdl.url}}" />
        </port>
    </service>
</definitions>

wsi.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * my
 * @category my
 * @package my AP-Plus
 */-->
<wsdl:definitions xmlns:typens="urn:{{var wsdl.name}}"
                  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                  name="{{var wsdl.name}}"
                  targetNamespace="urn:{{var wsdl.name}}">
    <wsdl:types>
        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:{{var wsdl.name}}">
            <xsd:element name="myApplusSyncParseRequestParam">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string"/>
                        <xsd:element minOccurs="1" maxOccurs="1" name="xmlString" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="myApplusSyncParseResponseParam">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element minOccurs="1" maxOccurs="1" name="results" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:schema>
    </wsdl:types>
    <wsdl:message name="myApplusSyncParseRequest">
        <wsdl:part name="parameters" element="typens:myApplusSyncParseRequestParam"/>
    </wsdl:message>
    <wsdl:message name="myApplusSyncParseResponse">
        <wsdl:part name="parameters" element="typens:myApplusSyncParseResponseParam"/>
    </wsdl:message>
    <wsdl:portType name="{{var wsdl.handler}}PortType">
        <wsdl:operation name="myApplusSyncParse">
            <wsdl:documentation>Parse data provided by APPlus</wsdl:documentation>
            <wsdl:input message="typens:myApplusSyncParseRequest"/>
            <wsdl:output message="typens:myApplusSyncParseResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="myApplusSyncParse">
            <soap:operation soapAction=""/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="{{var wsdl.name}}Service">
        <wsdl:port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
            <soap:address location="{{var wsdl.url}}"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

api.xml

<?xml version="1.0"?>
<!--
/**
 * my
 * @category my
 * @package my AP-Plus
 */-->

<config>
    <api>
        <resources>
            <my_applus translate="title" module="my_applus">
                <model>my_applus/sync_api</model>
                <title>my AP-Plus</title>
                <acl>my_applus/sync</acl>
                <methods>
                    <parse translate="title" module="my_applus">
                        <title>Parse Xml</title>
                        <method>parseXml</method>
                    </parse>
                </methods>
            </my_applus>
        </resources>
        <resources_alias>
            <sync>my_applus</sync>
        </resources_alias>
        <v2>
            <resources_function_prefix>
                <sync>myApplusSync</sync>
            </resources_function_prefix>
        </v2>
        <acl>
            <resources>
                <my_applus translate="title" module="my_applus">
                    <title>Sync AP-Plus</title>
                    <sort_order>5</sort_order>
                    <product translate="title" module="my_applus">
                        <title>Sync AP-Plus</title>
                    </product>
                </my_applus>
            </resources>
        </acl>
    </api>
</config>

app/code/local/My/Applus/Model/Sync/Api/v2.php

<?php

class My_Applus_Model_Sync_Api_V2 extends my_Applus_Model_Sync_Api
{
    const XML_NODE_Articles = 'Articles';
    const XML_NODE_Categories = 'CATEGORIES';
    const XML_NODE_Customers = 'Customers';

    /**
     * here we start
     * @param $xmlString
     * @return bool|string
     */
    public function parseXml($xmlString)
    {
        Mage::log($xmlString, Zend_Log::DEBUG, 'My_Sync_Api_parseXml.log');

        $xml = simplexml_load_string($xmlString);
        $ids = $this->checkDataType($xml);

        return $ids;
    }
}

where $this->checkDataType($xml) returns a string value of comma separated updated or added products' IDs.

  • 1
    try to replace return $ids with return array('results' => $ids);. I'm shooting in the dark here. – Marius Nov 3 '16 at 15:41
  • thanks! already tested it before, even as an object didn't work – M.haj-Salem Nov 4 '16 at 7:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.