2012-01-26 1 views
4

동일한 XML 메시지를 복사하여 붙여 넣을 때 Savon Ruby Gem에서 SOAP API 호출이 실패하는 문제가 발생했습니다. SOAP-UI로 성공합니다. 이 API (원격 웹 카메라 구성)에Savon SOAP 클라이언트로 API 호출 EndpointDispatcher에서 ContractFilter가 일치하지 않음 오류

<?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> 

:

나는이 메시지를 보내 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 알려진 문제입니다 : 나는 그의 응답이 실마리를 제공 할 수 있다고 생각? 아니면 내가 만나는이 문제입니까?

답변

5

디버깅하여 Savon이 불행히도 올바른 SOAPAction HTTP 헤더를 보내지 않는다는 것을 알았습니다. 참고 사항 : 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 

이 당신을 위해 일하는 희망 :

여기에 완벽한 예입니다!

+1

작동하는 것처럼 보입니다. 고맙습니다. 디버깅 할 시간을 내 주셔서 진심으로 감사 드리며 매우 친절합니다. 그리고 비누 UI 팁 주셔서 감사합니다. – Frank

+0

당신은 환영합니다 :) – rubiii

+1

와우, 이것이 내 정확한 문제였습니다. 게시 해 주셔서 감사합니다. 이것이 Savon의 버그 또는 어떤 종류의 상호 운용성 문제입니까? –