2015-06-22 89 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