I created a custom method to the Magento SOAP API and it worked well so far. Now I want to create the same method to the Magento SOAP API V2.
I created the WSDL.xml and the V2.php Class files (below), and when I try call my method in V2 API, I got this error:
Uncaught SoapFault exception: [Client] Function ("pacoteCreatelink") is not a valid method for this service in [...]
Although the error be clear, it seems to me that my new method in soap v2 is not being recognized. I must pass something. Any Ideas?
Files:
Company
Bundleapi
etc
config.xml
api.xml
wsdl.xml
Model
Pacote
Api
V2.php
Api.php
V2.php:
<?php
class Company_Bundleapi_Model_Pacote_Api_V2 extends Company_Bundleapi_Model_Pacote_Api
{
public function createlink($message)
{
return $message;
}
}
api.xml:
<?xml version="1.0"?>
<config>
<api>
<resources>
<bundle_link translate="title" module="company_bundleapi">
<title>Create Bundle link</title>
<model>bundleapi/pacote_api</model>
<methods>
<createlink translate="title" module="company_bundleapi">
<title>Create link Options Bundle</title>
</createlink>
<cleanlink translate="title" module="company_bundleapi">
<title>Clean link beetwen Bundle and Simple Products</title>
</cleanlink>
</methods>
</bundle_link>
</resources>
<resources_alias>
<pacote>bundle_link_pacote</pacote>
</resources_alias>
<v2>
<resources_function_prefix>
<bundle_link>pacote</bundle_link>
</resources_function_prefix>
</v2>
</api>
</config>
wsdl.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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}}">
<types>
</types>
<message name="pacoteCreatelinkRequest">
<part name="sessionId" type="xsd:string"/>
<part name="message" type="xsd:string" />
</message>
<message name="pacoteCreatelinkResponse">
<part name="result" type="xsd:string" />
</message>
<portType name="{{var wsdl.handler}}PortType">
<operation name="pacoteCreatelink">
<documentation>Create Link to Bundle Products</documentation>
<input message="typens:pacoteCreatelinkRequest" />
<output message="typens:pacoteCreatelinkResponse" />
</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="pacoteCreatelink">
<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>
config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Company_Bundleapi>
<version>0.1.0</version>
</Company_Bundleapi>
</modules>
<global>
<models>
<bundleapi>
<class>Company_Bundleapi_Model</class>
</bundleapi>
</models>
</global>
</config>
v2inapi.xml. It is explained in the first link you said you tried. – Marius Sep 08 '14 at 08:01api.xmlwith tagv2, but it's still not working. I edited question too. Thanks – Denis Spalenza Sep 08 '14 at 08:17Mage_Api_Model_Server_V2_Handler::__call. See how the$apiKeyvariable looks like before calling the actual method. If it looks ok to you you can continue the debuggin g process inMage_Api_Model_Server_Handler_Abstract::call– Marius Sep 08 '14 at 08:34resources_aliastag inapi.xml. – Marius Sep 08 '14 at 08:35resources_aliastag. I used the name of resource and de Model's name, looks like your code in your question. But still did not work. I'm starting to debug hot to you said. Thanks for your help. – Denis Spalenza Sep 08 '14 at 14:53resources_aliasare leaving me confused. It seems that the error happens before, but my WSDL seems to be correct. Thanks for your help. – Denis Spalenza Sep 08 '14 at 16:21<resources_alias> <pacote>pacote</pacote> </resources_alias>– Marius Sep 09 '14 at 05:37v2tag. Aboutresources_alias, this alias system helps ensure API backward compatibility without code duplication. More Info – Denis Spalenza Sep 09 '14 at 06:33