2017-03-21 8 views
0

石鹸サービスを作成しようとしましたが、何とかそのwsdl URLが機能していません。以下のコードは次のとおり - API/CustomapitInterface.phpMagento2石鹸サービスが動作しない

namespace W3solver\Customapi\Api; 

interface CustomapiInterface 
{ 
    /** 
    * Returns greeting message to user 
    * 
    * @api 
    * @param string $name Users name. 
    * @return string Greeting message with users name. 
    */ 
    public function name($name); 
} 

モデル/ Customapi.php

<?php 
namespace W3solver\Customapi\Model; 
use W3solver\Customapi\Api\CustomapiInterface; 

class Customapi implements CustomapiInterface 
{ 
    /** 
    * Returns greeting message to user 
    * 
    * @api 
    * @param string $name Users name. 
    * @return string Greeting message with users name. 
    */ 
    public function name($name) { 
     return "Hello, " . $name; 
    } 
} 

など/ 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"> 
    <preference for="W3solver\Customapi\Api\CustomapiInterface" type="W3solver\Customapi\Model\Customapi" /> 
</config> 

など/ module.xml

<?xml version="1.0"?> 
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> 
    <module name="W3solver_Customapi" setup_version="1.0.0" /> 
</config> 

など/ webapi。 XML

​​

私はhttp://inchoo.net/magento/api-magento/magento-2-custom-api/からrefrenceを使用してこれを作成しました。私はこれが間違っているところではなかった。以下は

私が使用しようとしていますURLです: - http://magento2.local/index.php/soap/default?wsdl&services=w3solverCustomapiV1

答えて

1

Magentoの2は、デフォルトでは無効に匿名のAPIへのAPIアクセスを持っている、あなたはバックエンドの管理パネルから、これを有効にする必要があります。

この機能を無効にするには、管理パネルにログインし、店舗>設定>サービス> Magento Web API> Web APIセキュリティに移動します。次に、[匿名のゲストアクセスを許可する]メニューから[はい]を選択します。

詳細については、devのガイドラインhereを参照してください。

+0

http://inchoo.net/magento/api-magento/magento-2-custom-api/と同じモジュールをたどったときに動作していたのですが、わかりませんでした – arushi

+0

あなたはアクセスしましたかおそらく認証を使用していたいくつかのAPIですか?この設定は 'mine'または' anonymous'リソースを使用しているAPIにのみ適用されるためです。 – oirad

関連する問題