开发者

Magento create category with soap v2

I want to crate categories in Magento with a webservice request (soap v2). I use Magento 1.4.2.0 and as I said the v2 of magentos soap api.

If I send the request I get the following error as response:

<?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>103</faultcode> 
  <faultstring>Attribute "include_in_menu" is required.</faultstring> 
  </SOAP-ENV:Fault>
  </SOAP-ENV:Body>
  </SOAP-ENV:Envelope>

The problem is, that the xml tag "include_in_menu" is not available in the request. If I add this tag manually it will be ignored.

What can I do, if I don't want to use soap v.1?

Greetings LStrike

PS: This is my request:

<?xml version="1.0" encoding="UTF-8"?><?xe.source ../../../Common/Data/login_response.xml#Envelope?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="xml" media-type="text/xml"></xsl:output>
  <xsl:template match="/">
    <soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:urn="urn:Magento" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soapenv:Header></soapenv:Header>
      <soapenv:Body>
        <urn:catalogCategoryCreate soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
          <sessionId xsi:type="xsd:string">
   开发者_如何学运维         <xsl:value-of select="soapenv:Envelope/soapenv:Body/urn:loginResponse/loginReturn"></xsl:value-of>
          </sessionId>
          <parentId xsi:type="xsd:int">
            <xsl:value-of select="'3'"></xsl:value-of>
          </parentId>
          <categoryData xsi:type="urn:catalogCategoryEntityCreate">
            <!--You may enter the following 19 items in any order-->
            <!--Optional:-->
            <name xsi:type="xsd:string">
              <xsl:value-of select="'TestKategorie'"></xsl:value-of>
            </name>
            <!--Optional:-->
            <is_active xsi:type="xsd:int">
              <xsl:value-of select="'1'"></xsl:value-of>
            </is_active>
            <!--Optional:-->
            <position xsi:type="xsd:int"></position>
            <!--Optional:-->
            <available_sort_by soapenc:arrayType="xsd:string[2]" xsi:type="ns1:ArrayOfString">
              <item xsi:type="xsd:string">name</item>
              <item xsi:type="xsd:string">price</item>
            </available_sort_by>
            <!--Optional:-->
            <custom_design xsi:type="xsd:string"></custom_design>
            <!--Optional:-->
            <custom_design_apply xsi:type="xsd:int"></custom_design_apply>
            <!--Optional:-->
            <custom_design_from xsi:type="xsd:string"></custom_design_from>
            <!--Optional:-->
            <custom_design_to xsi:type="xsd:string"></custom_design_to>
            <!--Optional:-->
            <custom_layout_update xsi:type="xsd:string"></custom_layout_update>
            <!--Optional:-->
            <default_sort_by xsi:type="xsd:string"><xsl:value-of>name</xsl:value-of></default_sort_by>
            <!--Optional:-->
            <description xsi:type="xsd:string"></description>
            <!--Optional:-->
            <display_mode xsi:type="xsd:string"></display_mode>
            <!--Optional:-->
            <is_anchor xsi:type="xsd:int"></is_anchor>
            <!--Optional:-->
            <landing_page xsi:type="xsd:int"></landing_page>
            <!--Optional:-->
            <meta_description xsi:type="xsd:string"></meta_description>
            <!--Optional:-->
            <meta_keywords xsi:type="xsd:string"></meta_keywords>
            <!--Optional:-->
            <meta_title xsi:type="xsd:string"></meta_title>
            <!--Optional:-->
            <page_layout xsi:type="xsd:string"></page_layout>
            <!--Optional:-->
            <url_key xsi:type="xsd:string"></url_key>

            <!-- selbst definierte Felder -->
            <include_in_menu xsi:type="xsd:int">1</include_in_menu>


          </categoryData>
          <storeView xsi:type="xsd:string">
            <xsl:value-of select="'default'"></xsl:value-of>
          </storeView>
        </urn:catalogCategoryCreate>
      </soapenv:Body>
    </soapenv:Envelope>
  </xsl:template>
</xsl:stylesheet>


You have 4 ways.

First - Change app/code/core/Mage/Catalog/etc/wsdl.xml after line 188 add

<element name="include_in_menu" type="xsd:int" minOccurs="0" />

Second - Change logic of Api Model app/code/core/Mage/Catalog/Model/Category/Api/V2.php in code add this attribute to the new object.

Third - Report bug to the magento and wait until it resolved (near 1-2 month)

Fourth - And least create you extension where you just override app/code/core/Mage/Catalog/etc/wsdl.xml add your paramters to the WSDL file, change API model in your extensions for additional parameters.

My proposal use 4th way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜