gpt4 book ai didi

ruby - 使用 Savon SOAP 客户端的 API 调用导致 EndpointDispatcher 错误中的 ContractFilter 不匹配

转载 作者:数据小太阳 更新时间:2023-10-29 07:30:51 26 4
gpt4 key购买 nike

我遇到了 Savon Ruby Gem 生成失败的 SOAP API 调用的问题,但是当我将完全相同的 XML 消息复制并粘贴到 SOAP-UI 时,它成功了。

我发送此消息:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tem="http://tempuri.org/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:vis="http://schemas.datacontract.org/2004/07/Vision.SecureOriginCommand.ServiceContracts">
<soapenv:Body>
<tem:CameraConfiguration>
<tem:request>
<vis:ClientToken>5555</vis:ClientToken>
<vis:DeviceID>26219</vis:DeviceID>
<vis:Enabled>1</vis:Enabled>
<vis:Interval>60</vis:Interval>
</tem:request>
</tem:CameraConfiguration>
</soapenv:Body>

对于此 API(远程网络摄像头配置): https://oapqa.onasset.com/Services/SecureOriginCommand.svc?wsdl

但它失败并显示此消息:

 SOAP response (status 500):
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</faultcode>
<faultstring xml:lang="en-US">The message with Action 'oapSetSentryReportingIntervalRequest' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None)</faultstring>
</s:Fault>
</s:Body>

我的第一个想法是,我一定是在操作名称中打错了字。但不,当我在 SOAP-UI 中尝试完全相同的消息时,我得到以下信息成功:

  <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<CameraConfigurationResponse xmlns="http://tempuri.org/">
<CameraConfigurationResult xmlns:a="http://schemas.datacontract.org/2004/07/Vision.SecureOriginCommand.ServiceContracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:Error/>
<a:Result>true</a:Result>
</CameraConfigurationResult>
</CameraConfigurationResponse>
</s:Body>
</s:Envelope>

这让我相信问题不是由格式引起的我的 xml 消息,但使用我配置客户端的方式。这是实际的代码:

Savon.configure do |config|
config.log = :debug
config.env_namespace = :soapenv
config.raise_errors = false
end

# TODO Enable ssl certficate verification
client = Savon::Client.new do
wsdl.document = TARGET_SO_WSDL
http.auth.ssl.verify_mode = :none
end

resp = client.request 'tem', 'CameraConfiguration' do
soap.namespaces['xmlns:vis'] = 'http://schemas.datacontract.org/2004/07/Vision.SecureOriginCommand.ServiceContracts'
soap.namespaces['xmlns:tem'] = 'http://tempuri.org/'
soap.body = {
'tem:request' => {
'vis:ClientToken' => ON_ASSET_API_KEY,
'vis:DeviceID' => webcam.gps_device.device_id,
'vis:Enabled' => 1,
'vis:Interval' => webcam.report_interval
}
}
end

我已经和维护我正在尝试的 API 的开发人员谈过使用权。我认为他的回答可以提供线索:

Binding on the RemoteSentryService was set to mexHttpBinding instead of mexHttpsBinding.


I don’t think this should give you a fault exception, because its working on .NET simulator client I have. And this endpoint is only used to generate the wsdl (MetaExchange Binding). But, given you are using a different client, I would still give it a shot.

I also regenerated the proxy from wsdl and updated my sample simulator and it looks good.

这个问题是 Savon 和 Microsoft SOAP 的已知问题吗端点还是 HTTPS?或者这个问题只是我遇到的?

最佳答案

调试它并注意到 Savon 很遗憾没有发送正确的 SOAPAction HTTP header 。仅供引用:通过 soapUI 发送 SOAP 请求后,您可以单击“RAW”选项卡(在请求窗口上垂直对齐)以进一步调查。

这是完整的例子:

client = Savon::Client.new do
wsdl.document = TARGET_SO_WSDL
http.auth.ssl.verify_mode = :none
end

resp = client.request 'tem', 'CameraConfiguration' do
# Notice, that the SOAPAction needs to the wrapped in double quotes:
http.headers['SOAPAction'] = %("http://tempuri.org/ISecureOriginCommand/CameraConfiguration")
soap.namespaces['xmlns:vis'] = 'http://schemas.datacontract.org/2004/07/Vision.SecureOriginCommand.ServiceContracts'
soap.body = {
'tem:request' => {
'vis:ClientToken' => 5555,
'vis:DeviceID' => 26219,
'vis:Enabled' => 1,
'vis:Interval' => 60
}
}
end

希望对你有用!

关于ruby - 使用 Savon SOAP 客户端的 API 调用导致 EndpointDispatcher 错误中的 ContractFilter 不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9012412/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com