2015-06-22 88 views
1

我試圖將我的rails應用程序與基於SOAP的Web服務集成。作爲SOAP的新手,我提到了this來開始。Ruby(2.0)&Savon(2)SOAP客戶端 - 返回nil SOAP操作

我的第一步是使用創建客戶端薩翁: client = Savon.client(wsdl: "https://xxxx.xxxx.xxxx/Reg/ABCRegService.svc?wsdl")

現在,當我做client.operations,我得到一個[]

的WSDL看起來是這樣的(我已經屏蔽了安全值字段)

<wsdl:definitions name="some_name" targetNamespace="some_targetNamespace"> 
<wsdl:import namespace="some_Namespace1" location="some_nameService.svc?wsdl=wsdl0"/> 
<wsdl:types> 
    <xsd:schema targetNamespace="some_targetNamespaceImports"> 
     <xsd:import schemaLocation="http://example.net/some_name/some_Service.svc?xsd=xsd0" namespace="some_targetNamespace"/> 
    </xsd:schema> 
</wsdl:types> 
<wsdl:message name="some_name_RegisterTool_InputMessage"> 
    <wsdl:part name="parameters" element="tns:RegisterTool"/> 
</wsdl:message> 
<wsdl:message name="some_name_RegisterTool_OutputMessage"> 
    <wsdl:part name="parameters" element="tns:RegisterToolResponse"/> 
</wsdl:message> 
<wsdl:message name="UnregisterToolRequest"> 
    <wsdl:part name="parameters" element="tns:UnregisterToolRequest"/> 
</wsdl:message> 
<wsdl:message name="UnregisterToolRequest_Headers"> 
    <wsdl:part name="AuthenticationHeader" element="tns:AuthenticationHeader"/> 
</wsdl:message> 
<wsdl:message name="UnregistrationResult"> 
    <wsdl:part name="parameters" element="tns:UnregistrationResult"/> 
</wsdl:message> 
<wsdl:portType msc:usingSession="false" name="some_name"> 
    <wsdl:operation name="RegisterTool"> 
     <wsdl:input wsaw:Action="some_targetNamespacesome_name/RegisterTool" message="tns:some_name_RegisterTool_InputMessage"/> 
     <wsdl:output wsaw:Action="some_targetNamespacesome_name/RegisterToolResponse" message="tns:some_name_RegisterTool_OutputMessage"/> 
    </wsdl:operation> 
    <wsdl:operation name="UnregisterTool"> 
     <wsdl:input wsaw:Action="some_targetNamespacesome_name/UnregisterTool" name="UnregisterToolRequest" message="tns:UnregisterToolRequest"/> 
     <wsdl:output wsaw:Action="some_targetNamespacesome_name/UnregisterToolResponse" name="UnregistrationResult" message="tns:UnregistrationResult"/> 
    </wsdl:operation> 
</wsdl:portType> 
<wsdl:service name="some_name"> 
    <wsdl:port name="WSHttpBinding_some_name" binding="i0:WSHttpBinding_some_name"> 
     <soap12:address location="https://example.net/Dcsome_name/some_nameService.svc"/> 
     <wsa10:EndpointReference> 
      <wsa10:Address>https://example.net/Dcsome_name/some_nameService.svc</wsa10:Address> 
      <Identity> 
       <Dns>localhost</Dns> 
      </Identity> 
     </wsa10:EndpointReference> 
    </wsdl:port> 
</wsdl:service> 

我看着相似的疑問句例如this。當我試圖在建議的方式

client = Savon.client(
endpoint: 'proper_endpoint', 
soap_action: "proper_soap_action", 
namespace: 'proper_namespace', 
convert_request_keys_to: :camelcase, 
env_namespace: :soapenv 

創建客戶端,我得到:

:在`method_missing的「:未知全局選項:soap_action(薩翁:: UnknownOptionError)。

任何想法如何通過這個?

環境:

  • 操作系統:Windows 7(使用RailsInstaller安裝導軌)
  • 紅寶石版本:2.0.0
  • 薩翁:2
  • 滑軌4.1.8

更新: 我試着從SOAPUI命中同一個WSDL。 ,使其在SOAPUI工作, 我不得不

  • 設置WS-Addressing屬性true
  • 檢查複選框Add default wsa:to
  • 使用<![CDATA[]>傳遞標識符參數。

有關如何在創建Savon客戶端時設置這些內容的任何線索?

回答

0

的問題是,由於WSDL不正確的解析。在芥末寶石,線136上的lib/parser.rb,目前XPATH搜索:

wsdl:definitions/wsdl:binding/wsdl:operation', 'wsdl' => WSDL 

不過,我指的是已舉辦元素不同的WSDL,我不得不上述線路調整至:

'wsdl:definitions/wsdl:portType/wsdl:operation', 'wsdl' => WSDL 

這裏是在GitHub上的同一個問題的鏈接:https://github.com/savonrb/savon/issues/702

1

您檢索wsdl的操作過程是完全正確的。我檢查了'Soap UI'中的wsdl &它似乎是WSDL有一些錯誤。這就是爲什麼你沒有得到任何操作,因爲wsdl沒有提供任何定義。

Error loading [https://xx.xxxx.xxx/DcRegistration/DCRegistrationService.svc?wsdl=wsdl0]: java.io.IOException: Attempted read from closed stream

+0

但是當我試圖用SOAPUI(讀取更新的一部分),通過你的建議,我能夠打服務,並得到適當的迴應。 – Manitude