this is my first post so I am sorry if I make something messier...
I am trying to create a new API Method in Magento 1.8 in order to allow simple products to be assigned to bundle products. I followed some different guides but each example gives me the same error:
SoapFault Object
(
[message:protected] => Function ("blinkAssign") is not a valid method for this service
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => C:\wamp\www\customer\sincro\test.php
[line:protected] => 27
[trace:Exception:private] => Array
(
[0] => Array
(
[file] => C:\wamp\www\customer\sincro\test.php
[line] => 27
[function] => __call
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => blinkAssign
[1] => Array
(
[0] => stdClass Object
(
[sessionId] => fe0b90725878bf1e8fac34ebf7a64137
[message] => test
)
)
)
)
[1] => Array
(
[file] => C:\wamp\www\customer\sincro\test.php
[line] => 27
[function] => blinkAssign
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => stdClass Object
(
[sessionId] => fe0b90725878bf1e8fac34ebf7a64137
[message] => test
)
)
)
)
[previous:Exception:private] =>
[faultstring] => Function ("blinkAssign") is not a valid method for this service
[faultcode] => Client
[faultcodens] => http://schemas.xmlsoap.org/soap/envelope/
)
And these are my files:
/Interdigital/Bundleapi/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Interdigital_Bundleapi>
<version>0.1.0</version>
</Interdigital_Bundleapi>
</modules>
<global>
<helpers>
<bundleapi>
<class>Interdigital_Bundleapi_Helper</class>
</bundleapi>
</helpers>
<models>
<bundleapi>
<class>Interdigital_Bundleapi_Model</class>
</bundleapi>
</models>
</global>
</config>
/Interdigital/Bundleapi/etc/api.xml
<?xml version="1.0"?>
<config>
<api>
<resources>
<bundleapi_blink translate="title" module="bundleapi">
<title>Bundleapi</title>
<model>bundleapi/blink_api</model>
<acl>bundleapi/blink</acl>
<methods>
<assign translate="title" module="bundleapi">
<title>Assign</title>
<acl>bundleapi/blink/assign</acl>
</assign>
</methods>
</bundleapi_blink>
</resources>
<resources_alias>
<blink>bundleapi_blink</blink>
</resources_alias>
<v2>
<resources_function_prefix>
<blink>blink</blink>
</resources_function_prefix>
</v2>
<acl>
<resources>
<bundleapi translate="title" module="bundleapi">
<title>Bundleapi</title>
<sort_order>1</sort_order>
<blink translate="title" module="bundleapi">
<title>Blink</title>
<sort_order>2000</sort_order>
<assign translate="title" module="bundleapi">
<title>Assign</title>
</assign>
</blink>
</bundleapi>
</resources>
</acl>
</api>
</config>
/Interdigital/Bundleapi/etc/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>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
</schema>
</types>
<message name="blinkAssignRequest">
<part name="sessionId" type="xsd:string"/>
<part name="message" type="xsd:string" />
</message>
<message name="blinkAssignResponse">
<part name="result" type="xsd:string" />
</message>
<portType name="{{var wsdl.handler}}PortType">
<operation name="blinkAssign">
<documentation>this is an example of api method...</documentation>
<input message="typens:blinkAssignRequest" />
<output message="typens:blinkAssignResponse" />
</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="blinkAssign">
<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>
/Interdigital/Bundleapi/Model/Blink/Api.php
<?php
class Interdigital_Bundleapi_Model_Blink_Api extends Mage_Api_Model_Resource_Abstract
{
public function assign($message)
{
return "This is the message: ".$message;
}
}
/Interdigital/Bundleapi/Model/Blink/Api/V2.php
<?php
class Interdigital_Bundleapi_Model_Blink_Api_V2 extends Interdigital_Bundleapi_Model_Blink_Api
{
//empty
}
I also have the wsi.xml file inside /etc but it is the same as the wsdl.xml one but adding the wsdl: to the tags...
I am making the call like this:
$proxy = new SoapClient('http://local.domain/api/v2_soap/?wsdl');
$sessionId = $proxy->login((object)array('username' => 'interdigital', 'apiKey' => 'pruebaeltaller'));
try{
$resultretun = $proxy->blinkAssign((object)array('sessionId' => $sessionId->result, 'message' => 'test'));
}catch(SoapFault $e){
echo "<pre>";print_r($e);echo "</pre>";
}
print_r($resultretun);
$proxy->endSession((object)array('sessionId' => $sessionId->result));
I would appreciate any kind of help, because that's making me crazy... Thanks!
Solution by OP.
I found the problem... it was with the wsi.xml file so I am pasting the one working here:
<?xml version="1.0" encoding="UTF-8"?>
<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="blinkAssignRequestParam">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
<xsd:element minOccurs="1" maxOccurs="1" name="message" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="blinkAssignResponseParam">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="blinkAssignRequest">
<wsdl:part name="parameters" type="typens:blinkAssignRequestParam"/>
</wsdl:message>
<wsdl:message name="blinkAssignResponse">
<wsdl:part name="parameters" type="typens:blinkAssignResponseParam" />
</wsdl:message>
<wsdl:portType name="{{var wsdl.handler}}PortType">
<wsdl:operation name="blinkAssign">
<wsdl:documentation>API method assign products to bundle</wsdl:documentation>
<wsdl:input message="typens:blinkAssignRequest" />
<wsdl:output message="typens:blinkAssignResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="blinkAssign">
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
<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>