English 中文(简体)
Successfully calling a WCF Service from Ruby? Anyone?
原标题:

I m trying to integrate a rails application with a WCF service. I ve tried soap4r and Savon with no love at all. As far as I can tell, none of the Ruby libraries support the newest version of SOAP.

The error that I was getting was:

Cannot process the message because the content type text/xml;charset=UTF-8 was not the expected type application/soap+xml; charset=utf-8 . application/soap+xml; charset=utf-8 .

I managed to beat this error by changing the WCF service binding from wsHttpBinding to basicHttpBinding, but then received the new error:

The message with Action 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). (SOAP::FaultError)

Now, this error leaves me baffled because I don t see any way to configure endpoints in any of the Ruby libraries. Does anyone know?

Has anyone successfully called WCF services from Ruby? application/soap+xml; charset=utf-8 .

最佳回答

Please note that I got this working...after I changed the web.config for the service to basicHttpBinding, Savon is able to send and receive messages. It is only soap4r that is unable to still and throws the Action error.

问题回答

this may not be what you want t hear but I ve recently been interacting with SOAP in Ruby.... It s not fun at all, none of the gems available are complete, stable or well documented and all seem to fall down when you add a tiny bit of complexity (passing an object containing some values instead of just passing a integer or string).

I ended up sniffing the request made by a .net client, then building objects that have a .to_xml method, taking a XML Builder object and adding it s own stuff..

That takes care of the request and then each service request method is custom made to extract the information needed for the result.

Very manual way to do it, and have to add more for every method i need to use but at least it works!

Some other guys I work with had success using JRuby and Axis. I stayed away from this as I wanted a pure Ruby solution.

Sorry I couldn t be of more help.. if you d like I ll post my code to build the soap request...

I was running into the same issue with Savon with my WCF web service. The content error is because your service is expecting SOAP 1.2, but by default Savon sends the request as SOAP 1.1.

The Content-Type value for 1.1 is text/xml;charset=UTF-8 , but if the server is configured for 1.2 (which is what wsHttpBinding is), the Content-Type must be application/soap+xml; charset=utf-8 .

I found this method on the Savon website:

response = client.request :get_user do
  soap.version = 2
end




相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签