2017-09-18 13 views
0

私はこのhttp://example.com/index.php/api/v2_soap/?wsdl(それはMagentoのウェブサイトである)のような石鹸のリンクを持っている、ユーザ名・パスワードがabc、123Windowsフォームアプリケーションでmagento soap webserviceを呼び出す方法は?

は、私はちょうど(私がボタンを作成した名前がServiceReference1

あるソリューションエクスプローラでサービス参照を追加しましたコードは以下れるようvs2015、プロジェクト名はprintOrderである)を使用して:

private void button1_Click(object sender, EventArgs e) 
    { 

    } 

のapp.configは以下の通りです:

<?xml version="1.0" encoding="utf-8" ?> 
     <configuration> 
      <startup> 
       <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> 
      </startup> 
      <system.serviceModel> 
       <bindings> 
        <basicHttpBinding> 
         <binding name="Binding" /> 
        </basicHttpBinding> 
       </bindings> 
       <client> 
        <endpoint address="http://example.com/index.php/api/v2_soap/index/" 
         binding="basicHttpBinding" bindingConfiguration="Binding" 
         contract="ServiceReference1.PortType" name="Port" /> 
       </client> 
      </system.serviceModel> 
    </configuration> 

だから、
1)どのようにユーザー名とパスワードで石鹸クライアントオブジェクトを作成するには?
2)作成されたSOAPクライアントオブジェクトの後、どのようにWebサービスを呼び出すのですか?

iは

誰もがどのようにそれを知っている......グーグルで話題の多くを探索したが、私の場合とは異なり、小さな存在であるようだきましたか?

私がやりたい同じことが

$cs = getSesstion(); 
$result = $cs['client']->salesOrderShipmentInfo($cs['session'], '200001811'); 

$complexFilter = array(
    'complex_filter' => array(
     array(
      'key' => 'orderIncrementId', 
      'value' => array('key' => 'in', 'value' => '100004496') 
     ) 
    ) 
); 
var_dump($cs); 
//$result = $cs['client']->salesOrderInfo($cs['session'],'100004496'); 
//var_dump($result); 

function getSesstion() { 

    $client = new SoapClient('http://example.com/index.php/api/v2_soap/?wsdl'); 

    $username = 'vtec'; 
    $apikey= 'Abcd1234'; 


    $session = $client->login($username, $apikey); 
    $cs = array(); 
    $cs['client'] = $client; 
    $cs['session'] = $session; 
    return $cs; 

} 

---------------------------- answer--ですあなたが持っている場合は--------------------------- Regie Baqueroの助けを借りて
、私が見つけた右のコードは

 ServiceReference1.PortTypeClient client = new ServiceReference1.PortTypeClient(); 
     string session = client.login("vtec","Abcd1234"); 

     Console.WriteLine(session); 
     //client.(session, "product_stock.list", "qqaz"); 
     var result = client.salesOrderInfo(session, "145000037"); 

     //client.endSession(session); 
     Console.WriteLine(result.increment_id.ToString()); 

答えて

0

ですあなたのソープサービスを既に追加しました。あなたのコードにあなたのコードに宣言することです:

`ServiceReference1.Service service variable = new ServiceReference1.Service();` 

にアクセスして、ソープサービス内のメソッドまたは関数にアクセスします。あなたのコードは次のようになりますのVisual Studio C#であなたのSOAPサービスを書かれている場合

サンプルコード:

[WebMethod] 
public bool Password_Verification(string password) 
{ 
     if(password=="12345") 
    { 
     return true; 
    } 
} 

はあなたが

 `ServiceReference1.Service service variable = new ServiceReference1.Service();` 
      bool verify = service variable.Password_Verification("12345"); 

は同じ使用してアクセスすることができますが、WSDLファイルとなります。そのソープサービスで実装されている関数/メソッドを知る必要があります。

.........................

+0

https://s26.postimg.org/5hz6xjg09/soap.pngはできませんServiceReference1を使用してオブジェクトを作成 – hkguile

+0

https://s26.postimg.org/80kvy81qh/soap2.png ServiceReference1内の内容を確認 – hkguile

+0

サービス変数は、それを読みやすくするための図です。変数にはスペースを入れないでください。 –

関連する問題