Ruby(2.0) & Savon(2) SOAP 客户端 - 返回零 SOAP 操作

Ruby(2.0) & Savon(2) SOAP client - returning nil SOAP operation

我正在尝试将我的 rails 应用与基于 SOAP 的网络服务集成。 作为 SOAP 的新手,我参考 this 开始。

我的第一步是使用 Savon 创建一个客户端: 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

)

,我得到:

:in `method_missing': Unknown global option: :soap_action (Savon::UnknownOptionError).

关于如何解决这个问题有什么想法吗?

环境:

Update: I tried hitting the same WSDL from SOAPUI. To make it work in SOAPUI, I had to

关于在创建 Savon 客户端时如何设置这些东西的任何线索?

你的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

问题是由于 WSDL 解析不正确造成的。在wasabi gem, lib/parser.rb第136行,当前XPATH搜索是:

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

但是,我所指的 WSDL 的元素组织方式不同,我不得不将上面的行调整为:

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

这是 github 中同一问题的 link:https://github.com/savonrb/savon/issues/702