2012-02-24 3 views
2

私はsavonとSOAPの初心者です。RubyとSavonのエラー:このURLではPOSTメソッドがサポートされていません

netsuite wsdlサービスへのリクエストを作成しようとしています。私はそれを実行すると、私は次のエラーを取得:

D, [2012-02-23T15:05:08.714815 #2284] DEBUG -- : HTTPI executes HTTP POST using the httpclient adapter 
    D, [2012-02-23T15:05:19.670815 #2284] DEBUG -- : SOAP response (status 405): 
    c:/Ruby187/lib/ruby/gems/1.8/gems/savon-0.9.9/lib/savon/soap/response.rb:107:in 
    `raise_errors': HTTP error (405): HTTP method POST is not supported by this URL 
    (Savon::HTTP::Error) 

を私がポストの代わりにgetを使用する必要があるようですが、私は、getする要求を設定する方法を見つけ出すことはできません。どんな助けもありがとう。以下

client = Savon::Client.new do 
     wsdl.endpoint = "https://webservices.netsuite.com/wsdl/v2011_2_0" 
     wsdl.namespace = "urn:messages_2011_2.platform.webservices.netsuite.com" 
     wsdl.namespace = "urn:core_2011_2.platform.webservices.netsuite.com" 
    end 

    response = client.request(:body) do 
     soap.element_form_default = :qualified 
     soap.body = {"urn:login" => 
        { 
         "urn:passport" => 
         { 
         "urnl:email" => "[email protected]", 
         "urnl:password" => "foobar123", 
         "urnl:account" => "12345" 
         } 
        } 
        } 
    end 

SOAPUI

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"   xmlns:urn="urn:messages_2011_2.platform.webservices.netsuite.com"       xmlns:urn1="urn:core_2011_2.platform.webservices.netsuite.com"> 
     <soapenv:Header> 
      <urn:partnerInfo>  </urn:partnerInfo> 
      <urn:applicationInfo>  </urn:applicationInfo> 
     </soapenv:Header> 
     <soapenv:Body> 
      <urn:login> 
      <urn:passport> 
       <urn1:email>fo[email protected]</urn1:email> 
       <urn1:password>foobar123</urn1:password> 
       <urn1:account>12345</urn1:account> 
      </urn:passport> 
      </urn:login> 
     </soapenv:Body> 
    </soapenv:Envelope> 

おかげ

答えて

3

を見られるように、あなたがコードしている石鹸要求ではほとんど正しいです。私はSOAPエンドポイントを変更し、要求ブロック内でurn1名前空間を指定し、SOAPアクションを要求本体ハッシュから要求メソッドに移動しました。

client = Savon::Client.new do 
    wsdl.endpoint = "https://webservices.netsuite.com/services/NetSuitePort_2011_2" 
    wsdl.namespace = "urn:messages_2011_2.platform.webservices.netsuite.com" 
end 

response = client.request(:urn, :login) do 
    soap.namespaces["xmlns:urn1"] = "urn:core_2011_2.platform.webservices.netsuite.com" 
    soap.body = { 
    "urn1:passport" => { 
     "urn1:email" => "[email protected]", 
     "urn1:password" => "foobar123", 
     "urn1:account" => "12345" 
    } 
    } 
end 

乾杯、
ダニエル

+0

おかげでダニエル、これは私が行きました。また、私はurn1の代わりにurnlを使用したことに気付かず、それは最後に文字Lではなく数字の1であった。 – yannb

+0

NetSuite SOAP API(SuiteTalk)を使用する場合は、[netsuite gem](https://github.com/revolutionprep/netsuite)をチェックして、すべてのsavonの処理を行い、モデルさまざまなNetSuiteオブジェクト用です。 – iloveitaly